Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method not found #13

Open
liu-collab opened this issue Feb 27, 2025 · 3 comments
Open

Method not found #13

liu-collab opened this issue Feb 27, 2025 · 3 comments

Comments

@liu-collab
Copy link

liu-collab commented Feb 27, 2025

import { FastMCP } from "fastmcp";
import { z } from "zod";

const server = new FastMCP({
  name: "My Server",
  version: "1.0.0",
});

server.addTool({
  name: "add",
  description: "Add two numbers",
  parameters: z.object({
    a: z.number(),
    b: z.number(),
  }),
  execute: async (args) => {
    return String(args.a + args.b);
  },
});

server.start({
  transportType: "sse",
  sse: {
    endpoint: "/sse",
    port: 8080,
  },
});

$ node fastmcp-demo.js
server is running on SSE at http://localhost:8080/sse
[warning] FastMCP could not infer client capabilities
[warning] FastMCP could not infer client capabilities
Error connecting to server: McpError: MCP error -32601: Method not found
at Server._onresponse (file:///C:/workspace/MCP/calculate/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js:156:27)
at _transport.onmessage (file:///C:/workspace/MCP/calculate/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js:45:22)
at SSEServerTransport.handleMessage (file:///C:/workspace/MCP/calculate/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js:93:71)
at SSEServerTransport.handlePostMessage (file:///C:/workspace/MCP/calculate/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js:72:24)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Server. (file:///C:/workspace/MCP/calculate/node_modules/mcp-proxy/dist/chunk-A5VUTWBC.js:194:7) {
code: -32601,
data: undefined
}
node:_http_server:344
throw new ERR_HTTP_HEADERS_SENT('write');
^

Error [ERR_HTTP_HEADERS_SENT]: Cannot write headers after they are sent to the client
at ServerResponse.writeHead (node:_http_server:344:11)
at Server. (file:///C:/workspace/MCP/calculate/node_modules/mcp-proxy/dist/chunk-A5VUTWBC.js:175:15)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}

Node.js v22.11.0

@LanfordCai
Copy link

Same here

@punkpeye
Copy link
Owner

Please use dev or inspect to start the server.

# Test the addition server example using CLI:
npx fastmcp dev src/examples/addition.ts
# Test the addition server example using MCP Inspector:
npx fastmcp inspect src/examples/addition.ts

If server cannot detect client capabilities, it cannot fully boot.

@liu-collab
Copy link
Author

liu-collab commented Feb 28, 2025

$ npx fastmcp inspect  fastmcp-demo.js 
Starting MCP inspector...
Proxy server listening on port 3000

🔍 MCP Inspector is up and running at http://localhost:5173 🚀
New SSE connection
Query parameters: { transportType: 'sse', url: 'http://localhost:3000/sse' }
sse transportType
SSE transport: url=http://localhost:3000/sse, headers=
New SSE connection
Invalid transport type: undefined
Query parameters: {}
undefined transportType
undefined transportType
Error in /sse route: Error: Invalid transport type specified
    at createTransport (file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:74:15)
    at file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:82:44
    at Layer.handle [as handle_request] (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\route.js:149:13)
    at Route.dispatch (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\route.js:119:3)
    at Layer.handle [as handle_request] (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:284:15  
    at Function.process_params (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:346:12)
    at next (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:280:10)
    at cors (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\cors\lib\index.js:188:7)      
Error in /sse route: SseError: SSE error: Non-200 status code (500)
    at _eventSource.onerror (file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:69:31)
    at EventSource.failConnection_fn (file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:234:53)
    at file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:76:74
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  code: 500,
  event: {
    type: 'error',
    message: 'Non-200 status code (500)',
    code: 500,
    defaultPrevented: false,
    cancelable: false,
    timeStamp: 4538.1117
  }
}

It looks like the second connection parameter is gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants