googleapis/mcp-toolbox · error

METHOD_NOT_FOUND

METHOD_NOT_FOUND

Error message

invalid method %s

What it means

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.

Source

Thrown at internal/server/mcp/v20250618/method.go:57

)

// ProcessMethod returns a response for the request.
func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, g group.Group, primitiveMgr *primitives.PrimitiveManager, body []byte, header http.Header) (any, error) {
	switch method {
	case INITIALIZE:
		return initializeHandler(ctx, id, body)
	case PING:
		return pingHandler(id)
	case TOOLS_LIST:
		return toolsListHandler(ctx, id, primitiveMgr, g, body)
	case TOOLS_CALL:
		return toolsCallHandler(ctx, id, g, primitiveMgr, body, header)
	case PROMPTS_LIST:
		return promptsListHandler(ctx, id, primitiveMgr, g, body)
	case PROMPTS_GET:
		return promptsGetHandler(ctx, id, g, primitiveMgr, body)
	default:
		err := fmt.Errorf("invalid method %s", method)
		return jsonrpc.NewError(id, jsonrpc.METHOD_NOT_FOUND, err.Error(), nil), err
	}
}

// InitializeResponse runs capability negotiation and protocol version agreement.
// This is the Initialization phase of the lifecycle for MCP client-server connections.
// Always start with the latest protocol version supported.
func initializeHandler(ctx context.Context, id jsonrpc.RequestId, body []byte) (any, error) {
	v, err := util.ToolboxVersionFromContext(ctx)
	if err != nil {
		return jsonrpc.NewError(id, jsonrpc.INTERNAL_ERROR, err.Error(), nil), err
	}

	var req InitializeRequest
	if err := json.Unmarshal(body, &req); err != nil {
		err = fmt.Errorf("invalid mcp initialize request: %w", err)
		return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. 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
  2. Verify your MCP client SDK protocol version matches the server's supported version (v20250618); upgrade the toolbox binary if your client needs newer methods
  3. Log the raw outgoing request body to confirm no middleware/proxy is altering the method string
  4. If you need resources/* or other methods, file/track support upstream — this server only implements tools and prompts

Example fix

// before
{"jsonrpc":"2.0","id":1,"method":"tools/ls","params":{}}
// after
{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}
Defensive patterns

Strategy: validation

Validate before calling

const allowed = new Set(["initialize","notifications/initialized","ping","tools/list","tools/call","prompts/list","prompts/get"]);
if (!allowed.has(request.method)) throw new Error(`unsupported MCP method: ${request.method}`);

Type guard

function isSupportedMethod(m: string): m is "initialize"|"tools/list"|"tools/call"|"prompts/list"|"prompts/get" {
  return ["initialize","tools/list","tools/call","prompts/list","prompts/get"].includes(m);
}

Try / catch

try { const res = await send(rpc); } catch (e) { if (e.code === -32601) { console.error(`method not supported: ${e.message}`); } else throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/8c404442f800a153. Report an issue: GitHub.