{"id":18532,"library":"mcp-echo-server","title":"MCP Echo Server","description":"A minimal Model Context Protocol (MCP) server template that provides an echo tool for testing and as a starting point for building custom MCP servers. Version 1.0.0 is the initial release. It uses the @modelcontextprotocol/sdk and is intended for developers creating MCP-compliant tools. Key differentiators: it is a barebones template with minimal dependencies, TypeScript support, and ready for npm publishing, unlike more complex starter kits.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","modelcontextprotocol","mcp","server","echo","template"],"install":[{"cmd":"npm install mcp-echo-server","lang":"bash","label":"npm"},{"cmd":"yarn add mcp-echo-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add mcp-echo-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to create MCP server and define tools.","package":"@modelcontextprotocol/sdk","optional":false}],"imports":[{"note":"ESM-only package; requires Node >=18 and 'type': 'module' in package.json.","wrong":"const { Server } = require('@modelcontextprotocol/sdk/server/index.js')","symbol":"Server","correct":"import { Server } from '@modelcontextprotocol/sdk/server/index.js'"},{"note":"Exported from a specific subpath, not the main entry.","wrong":"import { StdioServerTransport } from '@modelcontextprotocol/sdk'","symbol":"StdioServerTransport","correct":"import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'"},{"note":"Used for parameter schema validation; zod is a peer dependency of @modelcontextprotocol/sdk.","wrong":null,"symbol":"z","correct":"import { z } from 'zod'"},{"note":"Type for tool response; also available from the server module.","wrong":null,"symbol":"CallToolResultSchema","correct":"import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js'"}],"quickstart":{"code":"// src/index.ts (ESM)\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { z } from 'zod';\n\nconst server = new Server(\n  { name: 'mcp-echo-server', version: '1.0.0' },\n  { capabilities: { tools: {} } }\n);\n\nserver.tool(\n  'echo',\n  'Echoes back the message',\n  { message: z.string().describe('The message to echo') },\n  async ({ message }) => ({\n    content: [{ type: 'text', text: message }]\n  })\n);\n\nconst transport = new StdioServerTransport();\nawait server.connect(transport);\n","lang":"typescript","description":"Demonstrates creating a minimal MCP server with a single 'echo' tool using the @modelcontextprotocol/sdk."},"warnings":[{"fix":"Set 'type': 'module' in package.json or use dynamic import().","message":"ESM-only: The @modelcontextprotocol/sdk is ESM-only. Using require() will fail with ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use specific subpath imports: '@modelcontextprotocol/sdk/server/index.js', etc.","message":"Import paths are not from the package root; subpath exports are used.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always define tool handlers as async functions.","message":"The 'server.tool' method is async but callback can be sync; omitting async may cause unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use server.tool() method instead of manual handler registration.","message":"Some older versions of the SDK used 'server.setRequestHandler' directly; now tools are registered via 'server.tool'.","severity":"deprecated","affected_versions":"<0.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Switch to ES modules: add 'type': 'module' to your package.json or use dynamic import().","cause":"Using CommonJS require() with ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /.../@modelcontextprotocol/sdk/... from ... not supported."},{"fix":"Run: npm install @modelcontextprotocol/sdk","cause":"Missing @modelcontextprotocol/sdk in node_modules; not installed.","error":"Cannot find module '@modelcontextprotocol/sdk' or its corresponding type declarations."},{"fix":"Use a specific subpath like '@modelcontextprotocol/sdk/server/index.js'.","cause":"Using a bare import '@modelcontextprotocol/sdk' without subpath.","error":"Error: No matching export for import \"@modelcontextprotocol/sdk\"."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}