Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ubo-app MCP gateway

A standalone subprocess that aggregates every enabled MCP server the user has configured behind a single, token-gated HTTP endpoint. It is the network boundary for MCP in ubo-app: any client — the on-device assistant, Claude Desktop, hermes, OpenClaw, etc. — talks to this one endpoint instead of spawning/managing MCP servers itself.

Why it exists

MCP server management used to live inside the assistant service, so the tools were reachable only by the assistant. Extracting the gateway into its own service (ubo_app/services/090-mcp) decouples MCP from the assistant: the gateway owns the servers, and the assistant becomes just one more client of the aggregated endpoint.

How it works

                 ┌──────────────── ubo-app core (gRPC :50051) ───────────────┐
                 │  state.mcp slice  (servers, enabled set, metadata)         │
                 └─────────────▲──────────────────────────────┬──────────────┘
                               │ autorun subscription         │ query_secret
                               │ (enabled servers + metadata) │ (bearer token)
                 ┌─────────────┴──────────────────────────────▼──────────────┐
                 │  MCP gateway subprocess (this service)                     │
                 │                                                            │
                 │  state → build_mcp_config() → FastMCP proxy                │
                 │                              ├── backend: server A (stdio) │
                 │                              ├── backend: server B (sse)   │
                 │                              └── …                         │
                 │  served over  /mcp (Streamable HTTP)  +  /sse              │
                 │  guarded by   Bearer <token>                               │
                 └────────────────────────────▲───────────────▲─────────────┘
                                               │               │
                                    assistant client      external clients
                                    (Streamable HTTP)     (Claude Desktop, …)
  1. Startup (main.py) — connects to ubo-app's gRPC store, reads the gateway bearer token from secrets (MCP_GATEWAY_TOKEN_SECRET_ID). If no token is configured it logs and exits rather than serve an open endpoint.
  2. State → config (gateway.py) — subscribes via autorun to state.mcp.enabled_mcp_servers_with_metadata and translates each enabled server's betterproto config (the stdio_mcp_config / sse_mcp_config oneof) into a FastMCP {"mcpServers": {...}} config. Servers with an unrecognized/empty config are skipped with a warning.
  3. Serving (server.py) — builds a single FastMCP proxy from that config and exposes its aggregated tools over both transports: Streamable HTTP at /mcp and SSE at /sse. A pure-ASGI _BearerAuthMiddleware rejects any request without Authorization: Bearer <token> (pure ASGI so it doesn't buffer the streaming responses).

The persistent-socket rebuild (the one non-obvious bit)

FastMCP has no API to remove a backend from a running proxy. So whenever the enabled-server set changes, the whole proxy and its ASGI apps must be rebuilt.

To avoid dropping the port (and breaking connected clients) during a rebuild, GatewayServer owns a persistent listening socket that is created once and never closed. The serve loop:

  • builds the app for the current config and runs a uvicorn.Server on that shared socket;
  • waits on an asyncio.Event that the autorun callback sets when the desired config differs from the running one;
  • on change, signals should_exit, awaits the old server, and loops to rebuild — the listener stays bound the entire time, so the endpoint never disappears.

An empty config still serves a valid (tool-less) gateway rather than crashing.

Configuration

Environment is provided by the service's ubo_handle.py::binary_env_provider:

Variable Meaning Default
MCP_GATEWAY_TOKEN_SECRET_ID secret id holding the bearer token mcp_gateway_token
MCP_GATEWAY_LISTEN_ADDRESS bind address 0.0.0.0
MCP_GATEWAY_LISTEN_PORT bind port 4322
UBO_MCP_GATEWAY_LOG_LEVEL log level INFO
UBO_MCP_GATEWAY_LOG_PATH log file path ./ubo-mcp-gateway.log

Server definitions themselves live on disk under CONFIG_PATH/mcp_servers/ ({name}_{uuid}/config.json), owned by the core MCP service, not this subprocess. This subprocess never reads the filesystem — it only consumes the state.mcp slice over gRPC.

Boundaries

  • Source of truth is the store. This process is a pure projection of state.mcp; it dispatches nothing and persists nothing.
  • Stdio MCP backends are launched by FastMCP as child processes of this subprocess, so their runtimes (e.g. uvx, npx) must be on PATH here. See the runtime-provisioning note below / in the service-level docs.

Metadata

Release files for ubo-app-mcp-gateway 2.0.1.dev260702103101505650

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ubo-app-mcp-gateway 2.0.1.dev260702103101505650
File Size Uploaded
ubo_app_mcp_gateway-2.0.1.dev260702103101505650.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ubo-app-mcp-gateway 2.0.1.dev260702103101505650
File Interpreter ABI Platform
ubo_app_mcp_gateway-2.0.1.dev260702103101505650-py3-none-any.whl Python 3 none any Details

Total release size: 20.2 kB

Release files / ubo_app_mcp_gateway-2.0.1.dev260702103101505650.tar.gz

Download URL ubo_app_mcp_gateway-2.0.1.dev260702103101505650.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1f35c7bcb3495e1f417eb546e811964778cc3c75136514978376308ae568d2b9
BLAKE2b-256 checksum
How to use checksums
0bc647e2ad9c06ca713d4e97cca2c2dd5ea66c6cee0282ec097b278f07b52cef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / ubo_app_mcp_gateway-2.0.1.dev260702103101505650-py3-none-any.whl

Download URL ubo_app_mcp_gateway-2.0.1.dev260702103101505650-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
561e52b04360f5f2fb644fb34df452201ea86dd459c47c72118a32f74479f8cc
BLAKE2b-256 checksum
How to use checksums
82d299720c6a5da0497bdf7d2fe10ee141281eebf245c6afac9c60d0eb937c2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page