{"record":{"id":"19e3e2521dadaee5","repo":"googleapis/mcp-toolbox","slug":"method-not-found-19e3e2","errorCode":"METHOD_NOT_FOUND","errorMessage":"invalid method %s","messagePattern":"invalid method (.+?)","errorType":"http","errorClass":"jsonrpc.Error","httpStatus":null,"severity":"error","filePath":"internal/server/mcp/v20241105/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/v20241105/method.go#L39-L75","documentation":"ProcessMethod for protocol version 2024-11-05 dispatches known MCP methods (initialize, tools/list, tools/call, prompts/list, prompts/get); an unrecognized method falls through to the default case and returns a JSON-RPC METHOD_NOT_FOUND error \"invalid method <name>\".","triggerScenarios":"Calling an RPC method the server does not implement (e.g. resources/list, sampling, logging/setLevel, ping) or misspelling a method name (\"tools/list \" with whitespace, wrong case) on the 2024-11-05 endpoint.","commonSituations":"Clients written for newer MCP specs calling methods this protocol version doesn't support; typos in hand-rolled JSON-RPC bodies; probes/health checks assuming methods Toolbox doesn't implement; protocol version mismatch making the client use a newer method set.","solutions":["Use only supported methods: initialize, tools/list, tools/call, prompts/list, prompts/get.","Check the method string spelling and casing in your JSON-RPC body.","Upgrade the toolbox server (or negotiate a newer protocol version) if your client requires methods beyond 2024-11-05's set.","Remove or gate client features (resources, sampling, notifications-as-requests) that this server version lacks."],"exampleFix":"// before: calling an unsupported method\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"resources/list\"}\n// after: use a supported method\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set([\"initialize\",\"tools/list\",\"tools/call\",\"prompts/list\",\"prompts/get\"]);\nif (!SUPPORTED.has(method)) throw new Error(`Method not supported by server: ${method}`);","typeGuard":"function isSupportedMethod(m) {\n  return [\"initialize\",\"tools/list\",\"tools/call\",\"prompts/list\",\"prompts/get\"].includes(m);\n}","tryCatchPattern":"if (res.error && res.error.code === -32601 /* METHOD_NOT_FOUND */) {\n  console.warn(\"Falling back to tools/list; method unsupported:\", res.error.message);\n}","preventionTips":["Gate client features on the negotiated protocol version's capability list from the initialize result","Centralize RPC method names as constants to avoid typos","Pin the client to the method set documented for the server's protocol version"],"tags":["mcp","jsonrpc","method-not-found","protocol"],"backgroundTag":"rpc-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"}