Module

gateway

Milo MCP gateway — one MCP server that proxies to all registered CLIs.

Register this once with your AI host:

claude mcp add milo -- uv run python -m milo.gateway --mcp

Then every CLI registered via--mcp-installis discoverable. Tools are namespaced:taskman.add, ghub.repo.list, etc.

Can also be run directly for debugging:

uv run python -m milo.gateway --mcp
uv run python -m milo.gateway --list
uv run python -m milo.gateway --doctor
uv run python -m milo.gateway --status

Classes

GatewayState 6
Bundled discovery results for the gateway.

Bundled discovery results for the gateway.

Attributes

Name Type Description
tools list[dict[str, Any]]
tool_routing dict[str, tuple[str, str]]
resources list[dict[str, Any]]
resource_routing dict[str, tuple[str, str]]
prompts list[dict[str, Any]]
prompt_routing dict[str, tuple[str, str]]
_GatewayHandler 8
MCPHandler implementation for the gateway (proxy to children).

MCPHandler implementation for the gateway (proxy to children).

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]
Internal Methods 1
__init__ 3
def __init__(self, clis: dict[str, dict[str, Any]], state: GatewayState, children: dict[str, ChildProcess]) -> None
Parameters
Name Type Description
clis
state
children

Functions

main 0 None
Entry point for ``python -m milo.gateway``.
def main() -> None
_print_registry 0 None
Print all registered CLIs.
def _print_registry() -> None
_print_status 0 None
Print gateway status (placeholder for F7 observability).
def _print_status() -> None
_run_gateway 0 None
Run the MCP gateway server with persistent child processes.
def _run_gateway() -> None
_idle_reaper 1 None
Periodically check and kill idle children.
def _idle_reaper(children: dict[str, ChildProcess]) -> None
Parameters
Name Type Description
children dict[str, ChildProcess]
_discover_one_child 2 tuple[str, list[dict], l…
Discover tools, resources, and prompts from a single child.
def _discover_one_child(cli_name: str, child: ChildProcess) -> tuple[str, list[dict], list[dict], list[dict]]
Parameters
Name Type Description
cli_name str
child ChildProcess
Returns
tuple[str, list[dict], list[dict], list[dict]]
_discover_all 2 GatewayState
Discover tools, resources, and prompts from all CLIs in parallel.
def _discover_all(clis: dict[str, dict[str, Any]], children: dict[str, ChildProcess]) -> GatewayState
Parameters
Name Type Description
clis dict[str, dict[str, Any]]
children dict[str, ChildProcess]
Returns
GatewayState
_proxy_call 3 dict[str, Any]
Proxy a tools/call to the appropriate child process.
def _proxy_call(children: dict[str, ChildProcess], tool_routing: dict[str, tuple[str, str]], params: dict[str, Any]) -> dict[str, Any]
Parameters
Name Type Description
children dict[str, ChildProcess]
tool_routing dict[str, tuple[str, str]]
params dict[str, Any]
Returns
dict[str, Any]
_proxy_resource 3 dict[str, Any]
Proxy a resources/read to the appropriate child process.
def _proxy_resource(children: dict[str, ChildProcess], resource_routing: dict[str, tuple[str, str]], params: dict[str, Any]) -> dict[str, Any]
Parameters
Name Type Description
children dict[str, ChildProcess]
resource_routing dict[str, tuple[str, str]]
params dict[str, Any]
Returns
dict[str, Any]
_proxy_prompt 3 dict[str, Any]
Proxy a prompts/get to the appropriate child process.
def _proxy_prompt(children: dict[str, ChildProcess], prompt_routing: dict[str, tuple[str, str]], params: dict[str, Any]) -> dict[str, Any]
Parameters
Name Type Description
children dict[str, ChildProcess]
prompt_routing dict[str, tuple[str, str]]
params dict[str, Any]
Returns
dict[str, Any]