#!/usr/bin/env node /** * Example MCP Server * * This is a minimal MCP server demonstrating the structure. * Replace with your actual MCP server implementation. */ const { Server } = require('@modelcontextprotocol/sdk/server/index.js'); const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js'); const server = new Server( { name: 'example-mcp-server', version: '1.0.0', }, { capabilities: { tools: {}, }, } ); // Register example tool server.setRequestHandler('tools/list', async () => { return { tools: [ { name: 'example_tool', description: 'An example tool that echoes input', inputSchema: { type: 'object', properties: { message: { type: 'string', description: 'Message to echo', }, }, required: ['message'], }, }, ], }; }); server.setRequestHandler('tools/call', async (request) => { if (request.params.name === 'example_tool') { const message = request.params.arguments?.message || 'Hello, World!'; return { content: [ { type: 'text', text: `Echo: ${message}`, }, ], }; } throw new Error(`Unknown tool: ${request.params.name}`); }); // Start server async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error('Example MCP server running on stdio'); } main().catch(console.error);