AIP-77: MCP-GATEWAY (mcp-gateway/v1): dual-era MCP host gateway, server/discover, and extension negotiation
Specifies how an agentproto host serves its authenticated MCP gateway (/mcp) across both the legacy 2025-11-25 Streamable HTTP era and the stateless 2026-07-28 modern era: authentication-first dispatch, header and single-read body era routing, strict separation of accepted vs advertised protocol versions, server/discover and capabilities.extensions, error status mapping including -32021 (HTTP 400), shared tool-factory discovery modes (deferredTools/tool_search), unified session observability, and configuration rollback. Scope v1 covers /mcp only; /mcp/orchestrator and /mcp/imported/<id> stay on 2025-11-25. It also binds the beta MCP Skills extension (skills/list, skills/get, skill:// resources) and the transport of human input (permissions, questions, approvals, runs) as MRTR elicitation. Host primitives remain specified by their existing AIPs.
| Field | Value |
|---|---|
| AIP | 77 |
| Title | MCP-GATEWAY (mcp-gateway/v1): dual-era MCP host gateway, server/discover, and extension negotiation |
| Author | Jeremy André <[email protected]> |
| Status | Draft |
| Type | Schema |
| Requires | AIP-1 (process), AIP-46 (SESSION: host session tools and caller-identity boundaries exposed through the gateway) |
| Composes with | AIP-3 (SKILL), AIP-7 (GOVERNANCE), AIP-20 (WORK), AIP-32 (MCP driver), AIP-45 (HARNESS), AIP-58 (RUN), AIP-76 (EVENT) |
| Created | 2026-11-26 |
| Packages (ref-impl) | @agentproto/runtime (mcp-modern, http-server, mcp-session-observer) |
| Prior art | Model Context Protocol 2025-11-25 (Streamable HTTP) and 2026-07-28 (server/discover, stateless HTTP, caching hints, error codes) |
Abstract
An agentproto host exposes its tools, resources, prompts, and protocol extensions
over an authenticated MCP endpoint (/mcp). Existing clients speak the
2025-11-25 Streamable HTTP era (initialize handshake + SSE), while newer
clients speak the stateless 2026-07-28 era (server/discover, strict
MCP-Protocol-Version / Mcp-Method / Mcp-Name headers, resultType,
caching hints, and capabilities.extensions).
MCP-GATEWAY specifies how one authenticated /mcp endpoint serves both eras
side by side without breaking existing clients, duplicating authorization, or
drifting the tool surface. It fixes the dispatch order, the separation between
accepted and advertised protocol versions, the server/discover payload, error
status mapping, shared discovery filtering (deferredTools / tool_search),
unified observability, and the configuration switch to disable modern-era
routing.
It also binds two features served on that era: the MCP Skills extension, which
serves the host's skills (AIP-3), and the transport of human
input requests as multi-round tool results (InputRequiredResult with
elicitation/create).
Motivation
- Existing MCP clients and embedded SDKs negotiate
2025-11-25viainitialize. Advertising2026-07-28frominitializeor replacing the legacy transport breaks clients that expect a2025-11-25handshake. - Modern MCP capabilities (elicitation via multi-round tool requests, task
projections, skills catalogs, and event extensions) require
server/discoverand2026-07-28framing on the authenticated/mcpendpoint, not only on a dedicated unauthenticated origin. - Splitting the modern era onto a separate URL would duplicate authentication, caller-identity enforcement, tool allow/deny filters, and deferred discovery, creating drift between the two surfaces.
Scope
Version 1 of this specification covers the root authenticated host endpoint
/mcp only.
/mcp/orchestrator(scoped child-orchestrator sub-gateway) and/mcp/imported/<id>(per-import upstream passthrough) remain on the2025-11-25era. Bringing them to the modern era is separate work./mcp/events/<secret>(the public events origin defined in AIP-76) remains modern-only (supportedVersions: ["2026-07-28"]).- Host primitives (sessions, approvals, permissions, workboards, runs, skills, events) remain defined by their existing AIPs; this gateway does not replace or duplicate their semantics.
Design principles
- Auth before era. Authentication, origin checks, caller-identity enforcement, surface restrictions, and query-parameter parsing execute once, before deciding which protocol era handles the request.
- One tool factory. Both eras construct their server from the exact same
factory and query filters (
denyTools,allowTools,deferred,profile,surface). A moderntools/listand a legacytools/listfor the same caller and query return the same tool names. - Accepted versions are not advertised versions. The set of protocol
versions accepted by the modern handler (
protocolVersions) is distinct from the set advertised inserver/discoverand-32022errors (advertisedVersions). A request carrying a legacy version on the modern path MUST be rejected with-32022, never answered with2026-07-28shapes. - Read the request body once. Routing inspects HTTP headers first. When body inspection is needed, the stream is buffered once (capped at the body limit) and the parsed object is handed directly to whichever era runs.
- Additive and reversible. Legacy
initializeis unchanged and never advertises2026-07-28. A host configuration flag (mcp.modernEra: false) disables modern-era routing cleanly.
Specification
Protocol versions
A conformant dual-era /mcp gateway maintains two explicit version lists:
- Accepted modern versions (
protocolVersions):["2026-07-28"]. Only these versions are accepted by the modern validator. - Advertised versions (
advertisedVersions):["2026-07-28", "2025-11-25"]. Returned inserver/discover(result.supportedVersions) and in-32022(error.data.supported).
By contrast, a modern-only origin such as /mcp/events/<secret>
(AIP-76) advertises only ["2026-07-28"].
Legacy initialize continues to negotiate 2025-11-25 and MUST NOT advertise
2026-07-28.
Dispatch order on /mcp
Every request arriving at /mcp MUST pass through the following sequence in
order:
- Authorization and identity. Enforce host auth (loopback or bearer token),
Originvalidation, caller-identity attestation and enforcement, external session touch, query-parameter parsing (denyTools,allowTools,callerSessionId,origin,deferred,profile,surface), and surface restrictions (such as denying operator-only surfaces to daemon-spawned sessions). Ifmcp.modernEraisfalse, skip steps 2–4 and serve the request through the legacy transport. - Non-POST verbs (
GET,DELETE, etc.). Route to the modern handler if and only if theMCP-Protocol-Versionheader names a version inprotocolVersions(the modern handler responds405 Method Not AllowedwithAllow: POST). Otherwise serve through the legacy transport (GETSSE stream,DELETElegacy handling). POSTheader check (zero body read). If theMCP-Protocol-Versionheader names a version inprotocolVersions, buffer the body (enforcing the 1 MiB body limit with413) and route directly to the modern handler.POSTsingle-read body check. Otherwise, buffer the request body once (enforcing the gateway body limit with413).- If the body is not valid JSON: if the request appears to be a modern call
or cannot be parsed for dispatch, return HTTP
400with JSON-RPC-32700(Parse error,id: null). Never attempt to replay a drained stream into the legacy transport. - Route to the modern handler (passing the buffered raw body) when either:
body.methodis a modern-only method (server/discover, or an extension method added by subsequent gateway bindings that does not exist in2025-11-25), orbody.params._meta["io.modelcontextprotocol/protocolVersion"]names a version inprotocolVersions.
- If the body is not valid JSON: if the request appears to be a modern call
or cannot be parsed for dispatch, return HTTP
- Legacy fallback. Otherwise, hand the already-parsed JSON object to the
legacy Streamable HTTP transport (
handleRequest(req, res, parsedBody)). Legacy header coercion (rewriting newer unknownMCP-Protocol-Versionheaders down to2025-11-25for older SDK compatibility) MUST run only inside this legacy branch, never before step 2.
A request whose MCP-Protocol-Version header is 2025-11-25 while its body
_meta["io.modelcontextprotocol/protocolVersion"] is 2026-07-28 enters step 4
and is rejected by the modern validator with HTTP 400 -32020 (header
mismatch), never silently downgraded.
A request calling server/discover with both header and _meta set to
2025-11-25 enters step 4 and is rejected by the modern validator with HTTP
400 -32022 (Unsupported protocol version,
error.data.supported = ["2026-07-28", "2025-11-25"]), proving that
advertisedVersions does not widen the accepted modern set.
server/discover and capabilities.extensions
server/discover builds its response from a fresh server instance produced by
the shared factory (so capabilities reflect the caller's actual surface):
resultType:"complete".supportedVersions:advertisedVersions(["2026-07-28", "2025-11-25"]on/mcp).capabilities: the server's capabilities with the removedloggingkey stripped andlistChangedwithdrawn fromtools,resourcesandprompts(list-change notifications travel oversubscriptions/listen, which this gateway does not serve), plusextensionswhen at least one modern extension is enabled (omitted or empty when none are enabled)._meta["io.modelcontextprotocol/serverInfo"]:{ name, version }.ttlMsandcacheScope: required onserver/discoverand the other five cacheable operations (tools/list,prompts/list,resources/list,resources/templates/list,resources/read), defaulting to{ ttlMs: 0, cacheScope: "private" }when no host cache policy is supplied.
Per-request SSE responses
A modern request is normally answered with one application/json body. A
method whose answer is a run of messages (today only events/stream, see
AIP-76) is answered with a text/event-stream response owned
by that request: one data: <json> frame per JSON-RPC message, no id:
line, no SSE comment, closed when the method ends or the client goes away.
The modern core answers such a method itself, before the in-process server
bridge opens (the bridge only keeps replies to its own requests), and does
not decorate its final frame with ttlMs, cacheScope or serverInfo.
Validation errors are still plain JSON errors, and the method is in the
allowed set only while its extension is enabled (else -32601, HTTP 404).
There is no shared, session-wide SSE stream in the modern era.
Error mapping
The modern handler maps protocol errors to HTTP status codes as follows:
| JSON-RPC code | Meaning | HTTP status |
|---|---|---|
-32700 | Parse error | 400 |
-32600 | Invalid request (batch, response body, wrong verb/Accept/Content-Type) | 400 / 405 / 406 / 415 |
-32601 | Method not found (including removed legacy methods such as initialize, ping, logging/setLevel) | 404 |
-32602 | Invalid params raised by the gateway itself: a malformed request (missing required _meta fields, params not an object, a missing parameter a header must mirror), a refused MRTR input request (forbidden caller, or an altered, expired, replayed or foreign requestState), a Tasks request, a Skills request | 400 |
-32020 | Header mismatch (MCP-Protocol-Version, Mcp-Method, Mcp-Name) | 400 |
-32021 | Missing required client capability (error.data.requiredCapabilities) | 400 |
-32022 | Unsupported protocol version (error.data.supported, error.data.requested) | 400 |
| Handler errors | Tool or extension domain errors not listed above, including a -32602 raised by a tool's own handler (for example an unknown tool or invalid arguments to tools/call) and a deliberate -32603 raised by a handler (for example tasks/cancel on a turn the harness cannot cancel, data.reason: "cancel-unsupported") | 200 |
| Uncaught internal failure | An exception no handler turned into a JSON-RPC error, answered as -32603 without leaking internal details | 500 |
The 400 for -32602 follows the MCP specification only where it gives
one: "A request missing any required field is malformed; the server MUST
reject it with JSON-RPC error code -32602 (Invalid params). On HTTP, the
response status MUST be 400 Bad Request." (MCP 2026-07-28,
Base Protocol, Per-request protocol fields).
This AIP reads params that is not an object, and a missing parameter
that a header must mirror, as malformed requests of the same kind. The
Skills page fixes -32602 without an HTTP status, and the MRTR page
names neither a code nor a status (it asks only for "an appropriate
error code"); this AIP fixes both at -32602 with 400, as for a Tasks
request. Every other -32602, in particular one raised by a tool's
handler on tools/call (the Tools page's own example is "Unknown tool:
invalid_tool_name"), keeps HTTP 200, as the legacy era answers it.
Discovery modes and filtering
Query parameters that narrow or shape the tool catalog (?denyTools=,
?allowTools=, ?deferred=1, ?profile=, ?surface=) apply identically on
both eras because both invoke the same server factory. Deferred tool discovery
(deferredTools / tool_search) behaves identically on 2026-07-28 and
2025-11-25 so large tool surfaces do not bloat modern clients' context.
Observability
When the host records per-session MCP observations (keyed by the trusted caller session id), the modern branch MUST feed the same observation store as the legacy branch:
- Successful and failed
server/discoverandtools/listresults are recorded with the client'sMCP-Protocol-Version. - HTTP-level rejections (
status >= 400) on modern requests that never reach method execution are recorded as HTTP errors against the caller session.
Rollback configuration
Hosts expose a boolean configuration option mcp.modernEra (default true).
When set to false, /mcp bypasses the modern dispatch path completely and
serves all requests through the 2025-11-25 transport, including legacy version
header coercion.
Skills binding
This section binds the MCP Skills extension (io.modelcontextprotocol/skills,
beta) to the host. The skill format itself stays AIP-3; this
binding only says how skills the host already holds are served over the modern
era of /mcp.
- Declaration. When the binding is enabled, the host announces
capabilities.extensions["io.modelcontextprotocol/skills"] = {}inserver/discoverand also declaresresources(files are read throughresources/read). The optionaldirectoryReadcapability is not declared, andresources/directory/readis not served. - Source. Only the host's imported-skills registry is served. Files are read from the host's durable copy of each skill, not from the original source folder. Skills a host delivers to a session at spawn are unaffected by this binding.
skills/listreturns{ skills, nextCursor? }. Each entry is{ uri, frontmatter, resources }:uriisskill://<name>/SKILL.md,frontmatteris the parsed frontmatter ofSKILL.mdencoded as JSON (every key kept, no key renamed; YAML-only forms such as dates or anchors arrive as their JSON values), andresourceslists every file of the skill as{ uri, digest, size }. The cursor is opaque.skills/gettakes{ uri: "skill://<name>/SKILL.md" }and returns{ skill }with the same entry shape. Any other path is-32602.- Files.
skill://<name>/<path>is read throughresources/read, astextwhen the bytes are valid UTF-8 without a NUL byte, otherwise as a base64blob. - Caching hints.
skills/listandskills/getcarryttlMsandcacheScope, like the other cacheable operations.skills/getrequires noMcp-Nameheader;resources/readkeeps itsurione. - Naming. The
<name>segment is the skill's frontmattername(its registry id), never a display alias. A skill whose frontmatternamediffers from its registry id, or whosedescriptionis missing or empty, is not served. - Manifest and digests.
digestissha256:<hex>over the raw bytes of the file. It lets a client detect drift; it is not a trust anchor (it is unsigned and comes from the same server). A file whose bytes no longer match the manifest is re-checked against a rebuilt manifest before it is served. - Ceilings. A skill of more than 512 files or more than 16 MiB is not
served, and
skills/getsays why. - Path confinement. A
skill://path is split without URL normalization; empty,.,.., or encoded separator segments are-32602. A file that is not in the manifest is-32602. The real path of every file is checked to stay inside the skill folder before any byte is read, so a symbolic link that leaves the folder is neither listed nor readable. - Rollback. The binding has its own switch,
mcp.extensions.skills(defaulttrue);falsestops announcing and serving it.
Human input over MRTR
A host that already parks work on a human (an AIP-45
permission or question, an AIP-7 approval, an
AIP-58 run waiting for input) MAY expose that request to a
2026-07-28 client as an InputRequiredResult (resultType: "input_required") carrying one elicitation/create request. This is only a
transport: the existing judge of each primitive still decides, and an
elicitation never replaces it.
The host projects four surfaces:
| Surface | Observed on | Elicitation mode | Who is asked |
|---|---|---|---|
| Held permission | permissions_list, session_monitor, tasks/get of the session's turn (AIP-78) | form | the operator, or a session resolving one of its own descendants |
| Session question | same as above | form | same as above |
| Pending approval | approval_get, approval_wait | url | the caller of approval_get / approval_wait |
| Run waiting for input | workflow_status | form | the operator only |
Rules:
- Capability first. A surface is projected only to a client that declared the matching elicitation mode. A client that declared neither mode, or a surface that cannot be expressed, gets the tool's ordinary result. Nothing is ever lost: the primitive stays answerable through its own tools.
- Flat forms, no secrets. A
formis only produced from the flatrequestedSchemasubset. A field whose key or prompt points at a secret, a credential or payment data is never put in a form; such a request is not projected. - Approvals. The
urlis the host's configured approval page plus the approval id. Without a configured page, no approval elicitation is produced. A base that could carry a credential (userinfo, fragment, credential-like query key) is refused. Anacceptfrom the client only records that the page was shown: it neither decides nor consumes the approval. - No self-resolution. A session is never asked to resolve its own permission or question, and a spawned session can only resolve requests of sessions in its own subtree. Runs are observed by the operator only.
- Replay token. The
requestStateis signed by the host and binds the caller, the tool, a hash of the original arguments (without_meta,requestStateandinputResponses), the entity kind and id, an expiry and a single-use 128-bit nonce. A retry whose token is altered, expired, already used, issued to another caller, for another tool or for other arguments, or that names an unknown kind is rejected with-32602. A missing or incomplete answer produces a freshInputRequiredResult, not an error. - Durability. Approval and run tokens stay verifiable across a host
restart (the signing key and the consumed nonces are stored). Permission and
question tokens are bound to the host's boot: a token from a previous boot is
rejected with
-32602(data.reason: "input_unavailable"), it is not re-projected. - Not projected. A run waiting on an
escalatepolicy (it carries neither a question nor a schema); a run whose input schema is not flat (no console page exists to send it to);workflow_run_fileandapproval_request(workflow_statusandapproval_getare the observers). Aformfor a single choice that also allows free text loses itschoices, because the flat subset cannot express both. - Rollback.
mcp.humanGate(defaulttrue) switches every surface off;mcp.humanGateApprovalsandmcp.humanGateRuns(defaulttrue) switch the approval and run surfaces off on their own.
Security considerations
- No auth bypass. Modern routing happens strictly after
authorizeMcp,enforceCallerIdentity, and surface restriction checks. A modern client without a valid bearer token (when bearer auth is active) or with an untrustedOriginreceives the same401/403rejection as a legacy client. - No silent downgrade on mismatch. Conflicting header and
_metaprotocol versions are rejected (-32020) rather than coerced. - Bounded memory. Request bodies buffered for dispatch or modern handling
enforce the gateway size ceiling and reject oversized payloads with
413.
Conformance
A host conforms to mcp-gateway/v1 when:
/mcpservesserver/discover,tools/list,tools/call,resources/*,prompts/*, andevents/*under2026-07-28while continuing to serveinitializeand all existing methods under2025-11-25.server/discoveron/mcpadvertises["2026-07-28", "2025-11-25"], while a modern request carrying2025-11-25in both header and_metais rejected with HTTP400-32022.- Every auth check,
Origincheck, caller-identity check, and query filter (denyTools,allowTools,deferred,surface) produces identical enforcement on both eras. -32021maps to HTTP400;-32601maps to HTTP404;-32020and-32022map to HTTP400.- Modern
server/discover,tools/list, and HTTP errors update the host's session observation store. - Setting
mcp.modernEratofalserestores pure legacy routing on/mcp. - With the Skills binding enabled,
server/discoverannounces the extension andresources;skills/list,skills/getandresources/readonskill://serve only registry skills under theirname, with digests over raw bytes andttlMs/cacheScopeon both methods; a traversal segment or a file outside the manifest is-32602; a skill above 512 files or 16 MiB is not served. - With the human gate enabled, a held permission, a session question, a
pending approval (
url, only with a configured page) and a run waiting for input (operator only) are projected asInputRequiredResultto a client that declared the matching elicitation mode, and to no other client; a form never carries a secret field; an approvalacceptneither decides nor consumes; a session never resolves its own request; an altered, expired, replayed or foreign replay token is-32602.
See also
- AIP-1: process and RFC 2119 terminology
- AIP-3: SKILL, the format of the skills served by the Skills binding
- AIP-7, AIP-45, AIP-58: the approvals, permissions and questions, and runs whose human input is carried over MRTR
- AIP-46: SESSION, whose MCP tools are exposed through this gateway
- AIP-78: TURN-TASK, whose
tasks/getalso carries a session's pending input - AIP-76: EVENT and the
mcp-events/v1public origin
AIP-76: EVENT (event/v1): host event subscriptions and signed webhook delivery, with the mcp-events/v1 binding
Fixes how an agentproto host lets an external client watch it: event definitions (name, description, delivery, inputSchema, payloadSchema), subscription identity (RFC 8785 JCS-deterministic sub_<hex32>, idempotent subscribe/refresh/unsubscribe, ttlMs 60s..30d default 7d), the signed callback challenge (type:verification, single-use 64-hex) that must pass before any mutation, the {eventId, name, timestamp, data, cursor} wire envelope, webhook delivery as Standard Webhooks (whsec_ secrets 24-64 bytes, v1 signatures, 10-minute dual-sign rotation window), the delivery guarantees (one event per POST, 256 KiB clamp to {summary, subject}, 2xx = ack, exponential backoff bounded to 5 attempts, never retry 410/413), and the durable outbox that makes delivery at-least-once across restarts. EVENT is transport-neutral; this AIP also fixes its first binding, mcp-events/v1: three native JSON-RPC methods (events/list, events/subscribe, events/unsubscribe) on the authenticated MCP endpoint, the events:{} capability at initialize, and a public MCP 2026-07-28 events origin (POST /mcp/events/<secret>). The binding also carries the MCP Events extension (io.modelcontextprotocol/events, protocol 2026-07-28): events/poll over a durable journal, events/stream (SSE push with notifications/events/*), the official -32023..-32027 error codes and the Mcp-Name header. It fills AIP-60's frozen webhook target kind with its delivery contract and does not touch the inbound inbox path. There is no EVENT.md file.
AIP-78: TURN-TASK (turn-task/v1): projecting one session turn as an MCP task
Specifies how a host that serves the 2026-07-28 MCP era projects a single turn of an AIP-46 session as an MCP task: server-decided creation for agent_start and agent_prompt, an opaque unguessable taskId bound to a prompt ticket and to its creating principal through a durable ledger, the turn-to-task state mapping, tasks/get, tasks/update and tasks/cancel semantics, cooperative cancellation that ends the turn and not the session, retention, and error codes. It does not replace the AIP-20 work board and does not change the multi-turn lifecycle of AIP-46.