{"record":{"id":"a89f489792b9aebc","repo":"googleapis/mcp-toolbox","slug":"method-not-found-a89f48","errorCode":"METHOD_NOT_FOUND","errorMessage":"invalid method %s","messagePattern":"invalid method (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/server/mcp/v20251125/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/v20251125/method.go#L39-L75","documentation":"ProcessMethod dispatches JSON-RPC requests by method name; if the method does not match any known MCP method for protocol version 2025-11-25, this METHOD_NOT_FOUND error is returned. It indicates the client requested a method this server/version does not support.","triggerScenarios":"Sending a JSON-RPC request whose params.method is misspelled, belongs to a different MCP protocol version, or is an extension method (e.g. sampling, resources on a server without resource support).","commonSituations":"Client negotiated a different protocol version than 2025-11-25 and sends newer method names; typos like 'tools/call' vs 'toolsCall'; custom clients invoking methods not in the MCP spec subset implemented by the server.","solutions":["Check the exact method string in the request against the supported methods (initialize, tools/list, tools/call, prompts/list, prompts/get).","Ensure the client negotiated protocol version 2025-11-25; if using an older client, upgrade it or point it at the matching protocol-version server.","Fix typos in the method name in your client code.","If the method is genuinely unsupported (e.g. resources/*), remove the call or use a supported server."],"exampleFix":"// before\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/listAll\"}\n// after\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['initialize','tools/list','tools/call','prompts/list','prompts/get'];\nif (!SUPPORTED.includes(method)) {\n  throw new Error(`method ${method} not supported by this server/version`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await rpc.call(method, params);\n} catch (e) {\n  if (e.code === -32601) {\n    // invalid method: re-negotiate initialize and use only supported methods\n  } else throw e;\n}","preventionTips":["Complete the initialize handshake and honor the negotiated protocol version.","Keep a whitelist of supported methods in custom client code.","Match client SDK version to the server's protocol version (2025-11-25)."],"tags":["mcp","json-rpc","method-not-found","protocol-version"],"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"}