You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Registering a second resource or tool fails with:
Error: A request handler for tools/list already exists, which would be overridden
at Server.assertCanSetRequestHandler (/Users/antontroynikov/Projects/CascadeProjects/panopticon/node_modules/@modelcontextprotocol/sdk/src/shared/protocol.ts:521:13)
at McpServer.setToolRequestHandlers (/Users/antontroynikov/Projects/CascadeProjects/panopticon/node_modules/@modelcontextprotocol/sdk/src/server/mcp.ts:85:17)
at McpServer.tool (/Users/antontroynikov/Projects/CascadeProjects/panopticon/node_modules/@modelcontextprotocol/sdk/src/server/mcp.ts:536:10)
at Object.<anonymous> (/Users/antontroynikov/Projects/CascadeProjects/panopticon/src/mcp/index.ts:19:8)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module.m._compile (/Users/antontroynikov/Projects/CascadeProjects/panopticon/node_modules/ts-node/src/index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Object.require.extensions.<computed> [as .ts] (/Users/antontroynikov/Projects/CascadeProjects/panopticon/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
To Reproduce
The following code in index.ts:
import{McpServer}from"@modelcontextprotocol/sdk/server/mcp.js";import{z}from"zod";// Create an MCP serverconstserver=newMcpServer({name: "Demo",version: "1.0.0"});// Add an addition toolserver.tool("add",{a: z.number(),b: z.number()},async({ a, b })=>({content: [{type: "text",text: String(a+b)}]}));// Simple tool with parametersserver.tool("calculate-bmi",{weightKg: z.number(),heightM: z.number()},async({ weightKg, heightM })=>({content: [{type: "text",text: String(weightKg/(heightM*heightM))}]}));// Async tool with external API callserver.tool("fetch-weather",{city: z.string()},async({ city })=>{constresponse=awaitfetch(`https://api.weather.com/${city}`);constdata=awaitresponse.text();return{content: [{type: "text",text: data}]};});
Followed by npm run mcp
Expected behavior
It should run
The text was updated successfully, but these errors were encountered:
Describe the bug
Registering a second resource or tool fails with:
To Reproduce
The following code in index.ts:
Followed by
npm run mcp
Expected behavior
It should run
The text was updated successfully, but these errors were encountered: