Registry / http-networking / mcp-echo-server

mcp-echo-server

JSON →
library0.1.1jsnpmunverified

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.

npm install mcp-echo-server
INSTALL
IMPORT
SIG · MCP-ECHO-SERVER
M
mcp-echo-server
http-networkingjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Server
import { Server } from '@modelcontextprotocol/sdk/server/index.js'
const { Server } = require('@modelcontextprotocol/sdk/server/index.js')
ESM-only package; requires Node >=18 and 'type': 'module' in package.json.
StdioServerTransport
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk'
Exported from a specific subpath, not the main entry.
z
import { z } from 'zod'
Used for parameter schema validation; zod is a peer dependency of @modelcontextprotocol/sdk.
CallToolResultSchema
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js'
Type for tool response; also available from the server module.

Demonstrates creating a minimal MCP server with a single 'echo' tool using the @modelcontextprotocol/sdk.

// src/index.ts (ESM) import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { z } from 'zod'; const server = new Server( { name: 'mcp-echo-server', version: '1.0.0' }, { capabilities: { tools: {} } } ); server.tool( 'echo', 'Echoes back the message', { message: z.string().describe('The message to echo') }, async ({ message }) => ({ content: [{ type: 'text', text: message }] }) ); const transport = new StdioServerTransport(); await server.connect(transport);
Debug
Known issues
breakingESM-only: The @modelcontextprotocol/sdk is ESM-only. Using require() will fail with ERR_REQUIRE_ESM.
fix
Set 'type': 'module' in package.json or use dynamic import().
affects: >=1.0.0
gotchaImport paths are not from the package root; subpath exports are used.
fix
Use specific subpath imports: '@modelcontextprotocol/sdk/server/index.js', etc.
affects: >=1.0.0
gotchaThe 'server.tool' method is async but callback can be sync; omitting async may cause unexpected behavior.
fix
Always define tool handlers as async functions.
affects: >=1.0.0
deprecatedSome older versions of the SDK used 'server.setRequestHandler' directly; now tools are registered via 'server.tool'.
fix
Use server.tool() method instead of manual handler registration.
affects: <0.5.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /.../@modelcontextprotocol/sdk/... from ... not supported.
Using CommonJS require() with ESM-only package.
fix
Switch to ES modules: add 'type': 'module' to your package.json or use dynamic import().
Cannot find module '@modelcontextprotocol/sdk' or its corresponding type declarations.
Missing @modelcontextprotocol/sdk in node_modules; not installed.
fix
Run: npm install @modelcontextprotocol/sdk
Error: No matching export for import "@modelcontextprotocol/sdk".
Using a bare import '@modelcontextprotocol/sdk' without subpath.
fix
Use a specific subpath like '@modelcontextprotocol/sdk/server/index.js'.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
@modelcontextprotocol/sdkrequiredRequired to create MCP server and define tools.
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
mcp-echo-server — npm install mcp-echo-server · libregistry