Transport-level routing for MCP/ACP protocols
We appreciate your patience. The service is temporarily operating in an external runtime environment.
Transport-level routing for MCP/ACP protocols
We appreciate your patience. The service is temporarily operating in an external runtime environment.
TypeScript MCP server example for testing Model Context Protocol integration with stdio Bus.
The MCP Echo Server is a reference implementation of an MCP (Model Context Protocol) server that provides simple tools for testing MCP integration. It demonstrates how to build MCP servers that can be used with the ACP Worker or MCP-to-ACP Proxy.
Key Features:
The MCP Echo Server serves multiple purposes:
The MCP Echo Server provides five tools for testing different scenarios:
Echoes back the input text.
Parameters:
text (string, required) - Text to echo backExample:
{"method": "tools/call","params": {"name": "echo","arguments": {"text": "Hello, world!"}}}
Response:
{"content": [{"type": "text","text": "Echo: Hello, world!"}]}
Reverses the input text.
Parameters:
text (string, required) - Text to reverseExample:
{"method": "tools/call","params": {"name": "reverse","arguments": {"text": "Hello"}}}
Response:
{"content": [{"type": "text","text": "olleH"}]}
Converts input text to uppercase.
Parameters:
text (string, required) - Text to convertExample:
{"method": "tools/call","params": {"name": "uppercase","arguments": {"text": "hello world"}}}
Response:
{"content": [{"type": "text","text": "HELLO WORLD"}]}
Echoes text after a specified delay (useful for testing cancellation).
Parameters:
text (string, required) - Text to echoms (number, required) - Delay in millisecondsExample:
{"method": "tools/call","params": {"name": "delay","arguments": {"text": "Delayed message","ms": 5000}}}
Response (after 5 seconds):
{"content": [{"type": "text","text": "Delayed: Delayed message"}]}
Always returns an error (useful for testing error handling).
Parameters:
message (string, optional) - Custom error messageExample:
{"method": "tools/call","params": {"name": "error","arguments": {"message": "Test error"}}}
Response:
{"error": {"code": -32000,"message": "Test error"}}
Run the MCP Echo Server directly:
node node_modules/@stdiobus/workers-registry/workers/mcp-echo-server/dist/index.js
The server will start and listen on stdin for MCP protocol messages.
The MCP Echo Server can be used with the ACP Worker to test MCP server integration:
ACP Worker configuration:
{"pools": [{"id": "acp-registry","command": "npx","args": ["@stdiobus/workers-registry","acp-worker"],"instances": 1,"env": {"MCP_SERVERS": "echo-server"}}]}
MCP server configuration (mcp-servers.json):
{"echo-server": {"command": "node","args": ["./node_modules/@stdiobus/workers-registry/workers/mcp-echo-server/dist/index.js"]}}
Use the MCP Echo Server through the MCP-to-ACP Proxy for IDE integration:
IDE MCP configuration:
{"mcpServers": {"echo-server": {"command": "node","args": ["./node_modules/@stdiobus/workers-registry/workers/mcp-echo-server/dist/index.js"]}}}
Minimal configuration for running the MCP Echo Server:
{"command": "node","args": ["./node_modules/@stdiobus/workers-registry/workers/mcp-echo-server/dist/index.js"]}
Configure logging and behavior:
{"command": "node","args": ["./node_modules/@stdiobus/workers-registry/workers/mcp-echo-server/dist/index.js"],"env": {"LOG_LEVEL": "debug","NODE_ENV": "development"}}
cd node_modules/@stdiobus/workers-registry/workers/mcp-echo-servernpm installnpm run build
mcp-echo-server/├── src/│ ├── index.ts # Main entry point│ ├── server.ts # MCP server implementation│ └── tools/ # Tool implementations│ ├── echo.ts│ ├── reverse.ts│ ├── uppercase.ts│ ├── delay.ts│ └── error.ts├── dist/ # Compiled JavaScript├── package.json└── tsconfig.json
Add new tools by implementing the MCP tool interface:
import { Tool } from '@modelcontextprotocol/sdk/types.js';export const myTool: Tool = {name: 'my-tool',description: 'Description of my tool',inputSchema: {type: 'object',properties: {param1: {type: 'string',description: 'Parameter description'}},required: ['param1']}};export async function handleMyTool(args: any) {// Tool implementationreturn {content: [{type: 'text',text: `Result: ${args.param1}`}]};}
Test that tools execute correctly:
# Start MCP Echo Servernode node_modules/@stdiobus/workers-registry/workers/mcp-echo-server/dist/index.js# Send tool call (via stdin)echo '{"jsonrpc":"2.0","id":"1","method":"tools/call","params":{"name":"echo","arguments":{"text":"test"}}}' | node ...
Test error handling with the error tool:
# Call error toolecho '{"jsonrpc":"2.0","id":"1","method":"tools/call","params":{"name":"error","arguments":{"message":"Test error"}}}' | node ...# Verify error response format
Test cancellation with the delay tool:
# Start long-running operationecho '{"jsonrpc":"2.0","id":"1","method":"tools/call","params":{"name":"delay","arguments":{"text":"test","ms":10000}}}' | node ...# Send cancellation requestecho '{"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":"1"}}' | node ...
Test tool listing:
# List available toolsecho '{"jsonrpc":"2.0","id":"1","method":"tools/list"}' | node ...# Verify all 5 tools are listed
The MCP Echo Server demonstrates key MCP protocol patterns:
import { Server } from '@modelcontextprotocol/sdk/server/index.js';import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';const server = new Server({name: 'mcp-echo-server',version: '1.0.0'},{capabilities: {tools: {}}});
server.setRequestHandler('tools/list', async () => {return {tools: [{name: 'echo',description: 'Echoes back the input text',inputSchema: {type: 'object',properties: {text: {type: 'string',description: 'Text to echo'}},required: ['text']}}// ... other tools]};});
server.setRequestHandler('tools/call', async (request) => {const { name, arguments: args } = request.params;switch (name) {case 'echo':return {content: [{type: 'text',text: `Echo: ${args.text}`}]};// ... other toolsdefault:throw new Error(`Unknown tool: ${name}`);}});
const transport = new StdioServerTransport();await server.connect(transport);
When using the MCP Echo Server as a reference:
Symptom: MCP Echo Server fails to start
Solutions:
node --version (must be ≥20.0.0)Symptom: Tool calls return errors
Solutions:
Symptom: MCP Echo Server not working with ACP Worker
Solutions: