{"record":{"id":"8c404442f800a153","repo":"googleapis/mcp-toolbox","slug":"method-not-found-8c4044","errorCode":"METHOD_NOT_FOUND","errorMessage":"invalid method %s","messagePattern":"invalid method (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/mcp/v20250618/method.go","lineNumber":57,"sourceCode":")\n\n// ProcessMethod returns a response for the request.\nfunc ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, g group.Group, primitiveMgr *primitives.PrimitiveManager, body []byte, header http.Header) (any, error) {\n\tswitch method {\n\tcase INITIALIZE:\n\t\treturn initializeHandler(ctx, id, body)\n\tcase PING:\n\t\treturn pingHandler(id)\n\tcase TOOLS_LIST:\n\t\treturn toolsListHandler(ctx, id, primitiveMgr, g, body)\n\tcase TOOLS_CALL:\n\t\treturn toolsCallHandler(ctx, id, g, primitiveMgr, body, header)\n\tcase PROMPTS_LIST:\n\t\treturn promptsListHandler(ctx, id, primitiveMgr, g, body)\n\tcase PROMPTS_GET:\n\t\treturn promptsGetHandler(ctx, id, g, primitiveMgr, body)\n\tdefault:\n\t\terr := fmt.Errorf(\"invalid method %s\", method)\n\t\treturn jsonrpc.NewError(id, jsonrpc.METHOD_NOT_FOUND, err.Error(), nil), err\n\t}\n}\n\n// InitializeResponse runs capability negotiation and protocol version agreement.\n// This is the Initialization phase of the lifecycle for MCP client-server connections.\n// Always start with the latest protocol version supported.\nfunc initializeHandler(ctx context.Context, id jsonrpc.RequestId, body []byte) (any, error) {\n\tv, err := util.ToolboxVersionFromContext(ctx)\n\tif err != nil {\n\t\treturn jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err\n\t}\n\n\tvar req InitializeRequest\n\tif err := json.Unmarshal(body, &req); err != nil {\n\t\terr = fmt.Errorf(\"invalid mcp initialize request: %w\", err)\n\t\treturn jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err\n\t}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/server/mcp/v20250618/method.go#L39-L75","documentation":"ProcessMethod dispatches an incoming MCP JSON-RPC request to the handler for its method (initialize, tools/list, tools/call, prompts/*). When the method name does not match any known case in the switch, the server returns a JSON-RPC METHOD_NOT_FOUND error wrapping the message 'invalid method %s'. This guards the MCP protocol lifecycle so only supported spec methods are accepted.","triggerScenarios":"Sending a JSON-RPC request whose method field is not one of initialize, tools/list, tools/call, prompts/list, prompts/get, notifications/initialized, or ping — e.g. misspelled method 'tools/ls', an unsupported future spec method like 'resources/list' (not enabled in this build), or a method from a newer MCP protocol version than v20250618.","commonSituations":"Clients written against a newer MCP spec (with resources or logging methods) hitting an older toolbox server; typos in method names in hand-rolled MCP clients; proxy or gateway code rewriting the method field; testing with curl and guessing method names.","solutions":["Check the method field in your JSON-RPC request; it must be exactly one of: initialize, notifications/initialized, ping, tools/list, tools/call, prompts/list, prompts/get","Verify your MCP client SDK protocol version matches the server's supported version (v20250618); upgrade the toolbox binary if your client needs newer methods","Log the raw outgoing request body to confirm no middleware/proxy is altering the method string","If you need resources/* or other methods, file/track support upstream — this server only implements tools and prompts"],"exampleFix":"// before\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/ls\",\"params\":{}}\n// after\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\",\"params\":{}}","handlingStrategy":"validation","validationCode":"const allowed = new Set([\"initialize\",\"notifications/initialized\",\"ping\",\"tools/list\",\"tools/call\",\"prompts/list\",\"prompts/get\"]);\nif (!allowed.has(request.method)) throw new Error(`unsupported MCP method: ${request.method}`);","typeGuard":"function isSupportedMethod(m: string): m is \"initialize\"|\"tools/list\"|\"tools/call\"|\"prompts/list\"|\"prompts/get\" {\n  return [\"initialize\",\"tools/list\",\"tools/call\",\"prompts/list\",\"prompts/get\"].includes(m);\n}","tryCatchPattern":"try { const res = await send(rpc); } catch (e) { if (e.code === -32601) { console.error(`method not supported: ${e.message}`); } else throw e; }","preventionTips":["Use an official MCP client SDK rather than hand-building JSON-RPC","Keep client and server MCP protocol versions aligned","Refresh your client's tool/method list after server upgrades"],"tags":["mcp","jsonrpc","protocol","method-not-found"],"backgroundTag":"jsonrpc-method-not-found","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}