Skip to content

MCP ingress

Last updated: 2026-11-27T14:16:11-03:00 (UTC-3)

The MCP ingress makes the gateway an MCP server. Any MCP client that speaks protocol revision 2025-11-25 over Streamable HTTP (an IDE, an agent framework, the official SDKs) connects to /v1/mcp/servers/{id}/mcp with a gateway key and uses the tools that key may run on that server. It is the standard-protocol counterpart of the REST tool facade: every listing and call goes through the same handler, grants, approvals, drift quarantine, upstream credentials, admission limit and execution trail. The ingress adds sessions and the protocol, never authorization of its own. With mcp_protocol_2026_07_28 the same endpoint also serves revision 2026-07-28 statelessly; see MCP protocol revision 2026-07-28.

Flag Default What it turns on
mcp_ingress false The ingress routes and PostgreSQL sessions; requires mcp_execution and mcp_registry; a public resource right (mcp_ingress) under plan entitlements, besides mcp_execution
Message Behavior
initialize Opens a session owned by the calling key and returns its token in the Mcp-Session-Id header. The answer always names 2025-11-25; a client that cannot speak it disconnects. Capabilities: tools only (listChanged: false)
notifications/initialized Accepted (202)
ping Empty result
tools/list The tools the key may run on the server, exactly as GET /v1/mcp/servers/{id}/tools. One page; a cursor is refused with -32602
tools/call Exactly as POST /v1/mcp/servers/{id}/tools/call: arguments validated against the reviewed schema, sent once, never retried. An Idempotency-Key header on the HTTP request is honored as on the REST route
notifications/cancelled Cancels an in-flight tools/call of the same session on the same replica; the call answers -32800 and, if it was already sent, its record is uncertain
anything else JSON-RPC error -32601. Resources, prompts, sampling, completion, logging and elicitation are not advertised and not served

Transport rules: one JSON-RPC message per POST (batches are refused), at most 72 KiB; every answer is one application/json message; GET answers 405 (no server-initiated stream); DELETE with Mcp-Session-Id ends the session. The Origin header, when present, must match the host, which protects local clients from DNS rebinding.

A session belongs to the key that opened it and to one server. After initialize each message must carry Mcp-Session-Id, MCP-Protocol-Version: 2025-11-25 and the same key; the key is authenticated again on every message. A session presented with another key, for another server, terminated or expired answers HTTP 404, which tells a client to initialize again; a leaked session token is useless without its key. Revoking or deleting the key stops its sessions at the next message (401). Initialize is refused with 404 for a server the key cannot reach, so it never reveals other servers.

A session also ends 24 hours after initialize, however active it is; the client then initializes again. Ending a session with DELETE cancels its calls running on that replica. The ingress serves servers whose ID matches [A-Za-z0-9_.-]{1,128}; any other path answers 404.

Sessions are stored in PostgreSQL as the SHA-256 of their token, with a public ID (mcs_…) that the execution trail records; replicas share them, so a client may land on any replica. Cancellation is the exception: it reaches only a call running on the replica that receives the notification; elsewhere the call runs to its 30-second bound.

Situation JSON-RPC error
Invalid params, invalid arguments, a tool the key may not run -32602
Refused before sending: per-user OAuth not connected (data.connect_url), quarantined tool, repeated Idempotency-Key, busy gateway (mcp_busy), unwritable execution record -32001
Server unavailable to the key -32002
Upstream failure or timeout (not retried) -32603
Cancelled -32800

data carries code (the REST problem code), http_status and, with the trail on, execution_id. Messages are the gateway’s own text, never upstream content.

A 401 carries WWW-Authenticate: Bearer. When public_url is set it names the RFC 9728 protected-resource metadata, served at /.well-known/oauth-protected-resource/v1/mcp/servers/{id}/mcp:

{"resource": "https://gateway.example.com/v1/mcp/servers/weather/mcp", "bearer_methods_supported": ["header"], "resource_name": "m7gtw MCP ingress"}

The bearer is a gateway key issued by the gateway’s own administration, so no authorization server is advertised. Without public_url nothing is published: the request Host never becomes an authority.

Boot configuration under mcp_execution.ingress, read-only in GET /api/v1/admin/config (mcp_execution.ingress, with protocol_versions and session_retention_days; it was a top-level mcp_ingress) and the console. A restart applies a change.

features:
mcp_execution: true
mcp_ingress: true
mcp_execution:
protocol_version: "2025-11-25"
ingress:
session_ttl_seconds: 3600 # 60-86400
max_sessions_per_key: 16 # 1-256
session_retention_days: 7 # 1-365
public_url: "https://gateway.example.com" # optional origin
Field Default Bounds Meaning
session_ttl_seconds 3600 60-86400 Idle lifetime; every message extends it, up to 24 hours after creation
max_sessions_per_key 16 1-256 Open sessions per key; a further initialize answers 429
session_retention_days 7 1-365 Ended sessions are kept this long for review, then deleted in bounded batches
public_url empty https origin, or http on loopback Origin for protected-resource metadata

The console (MCP registry → Connect an MCP client) shows each endpoint and a configuration with a key placeholder; it never holds a key. For example:

{
"mcpServers": {
"weather": {
"type": "http",
"url": "https://gateway.example.com/v1/mcp/servers/weather/mcp",
"headers": {"Authorization": "Bearer <gateway key with mcp:read and mcp:execute>"}
}
}
}

With the official Python SDK (mcp 1.30.0, the release line for 2025-11-25):

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async with streamablehttp_client(url, headers={"Authorization": f"Bearer {key}"}) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
result = await session.call_tool("lookup", {"city": "Lisbon"})

Migration 152 creates gateway_mcp_ingress_sessions. Upgrade every replica before turning the flag on; an older replica does not serve the ingress routes.

m7gtw[email protected]