# _mcp_router

URL: /milo-cli/api/milo/_mcp_router/
Section: milo
Description: Shared MCP method dispatch for leaf servers and gateway.

---

> For a complete page index, fetch /milo-cli/llms.txt.

Open LLM text
(/milo-cli/api/milo/_mcp_router/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_mcp_router%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_mcp_router%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_mcp_router%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fmilo-cli%2Fapi%2Fmilo%2F_mcp_router%2Findex.txt)

Module

#
`_mcp_router`

Shared MCP method dispatch for leaf servers and gateway.

2Classes1Function

## Classes

`MethodNotFoundError`

0

▼

Raised when a JSON-RPC method is not implemented.

Raised when a JSON-RPC method is not implemented.

`MCPHandler`

7

▼

Protocol for MCP method handlers.

Implemented by the leaf MCP server (direct CLI calls) and the
ga…

Protocol for MCP method handlers.

Implemented by the leaf MCP server (direct CLI calls) and the
gateway (proxy to child processes). The router dispatches to the
appropriate method without duplicating the match/case structure.

#### Methods

`initialize`

1

`dict[str, Any]`

▼

`def initialize(self, params: dict[str, Any]) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`params`
`—`

##### Returns

`dict[str, Any]`

`list_tools`

1

`dict[str, Any]`

▼

`def list_tools(self, params: dict[str, Any]) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`params`
`—`

##### Returns

`dict[str, Any]`

`call_tool`

1

`dict[str, Any]`

▼

`def call_tool(self, params: dict[str, Any]) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`params`
`—`

##### Returns

`dict[str, Any]`

`list_resources`

1

`dict[str, Any]`

▼

`def list_resources(self, params: dict[str, Any]) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`params`
`—`

##### Returns

`dict[str, Any]`

`read_resource`

1

`dict[str, Any]`

▼

`def read_resource(self, params: dict[str, Any]) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`params`
`—`

##### Returns

`dict[str, Any]`

`list_prompts`

1

`dict[str, Any]`

▼

`def list_prompts(self, params: dict[str, Any]) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`params`
`—`

##### Returns

`dict[str, Any]`

`get_prompt`

1

`dict[str, Any]`

▼

`def get_prompt(self, params: dict[str, Any]) -> dict[str, Any]`

##### Parameters

Name
Type
Description

`params`
`—`

##### Returns

`dict[str, Any]`

## Functions

`dispatch`

3

`dict[str, Any] | None`

▼

Route an MCP method to the appropriate handler method.

Returns None for notifi…

`def dispatch(handler: MCPHandler, method: str, params: dict[str, Any]) -> dict[str, Any] | None`

Route an MCP method to the appropriate handler method.

Returns None for notification methods (no response required).
Raises ValueError for unknown methods.

##### Parameters

Name
Type
Description

`handler`
`MCPHandler`

`method`
`str`

`params`
`dict[str, Any]`

##### Returns

`dict[str, Any] | None`
