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.
| Field | Value |
|---|---|
| AIP | 76 |
| Title | EVENT (event/v1): host event subscriptions and signed webhook delivery, with the mcp-events/v1 binding |
| Author | Jeremy André <[email protected]> |
| Status | Draft |
| Type | Schema |
| Requires | AIP-1 (process), AIP-60 (SENTINEL: the store, providers, subjects, and the frozen webhook target kind this AIP gives a delivery contract) |
| Composes with | AIP-32 (MCP driver: the client side of the same protocol family), AIP-46 (SESSION: subscriptions created from a session reach the host surface through the same session primitives) |
| Bindings | mcp-events/v1 (this AIP, §Binding: mcp-events/v1). Other transports are future bindings of the same contract. |
| Created | 2026-11-21 |
| Packages (ref-impl) | @agentproto/mcp-server (native method dispatch), @agentproto/runtime (mcp-events adapter, webhook-egress, events origin), @agentproto/sentinel (store, outbox) |
| Prior art | OpenAI, "MCP Events – plugins" (developers.openai.com/plugins/build/mcp-events); MCP Events extension, SEP-3415 (github.com/modelcontextprotocol/ext-events, specification/beta/events/events.mdx); Standard Webhooks 1.0; MCP HTTP-Streamable 2025-11-25 / MCP 2026-07-28 server/discover |
Abstract
A host that can be watched by an external client needs three things: to say
which events exist (list), to let that client subscribe with a callback and a
secret (subscribe), and to stop on request (unsubscribe). EVENT fixes the
transport-neutral contract behind those three operations: event definitions,
deterministic subscription identity, the signed challenge that must pass
before a subscription mutates anything, the wire envelope of a delivered
event, the Standard Webhooks signature and retry rules of delivery, and the
durable outbox that makes the whole chain at-least-once across host restarts.
It then fixes the first binding, mcp-events/v1, which exposes the three
operations as native MCP JSON-RPC methods (events/list, events/subscribe,
events/unsubscribe) on the authenticated MCP endpoint, plus a public,
path-secret MCP 2026-07-28 origin that serves server/discover. EVENT is
the outbound twin of AIP-60: AIP-60 delivers watched events
into a session's inbox; this AIP defines the webhook target kind AIP-60
left as a frozen shape.
Motivation
- The official OpenAI plugin contract ("MCP Events") requires the three
native methods on the same endpoint as tools, an
events:{}capability atinitialize, signed challenge verification, and Standard Webhooks delivery with bounded retry. An agentproto host that wants its plugins to push events to a ChatGPT conversation has to satisfy all of it exactly. - AIP-60 froze the
webhooktarget "without delivery"; shipping code now exists and an audit (2026-11-21) confirms it conforms to the upstream page on every mechanism. The spec is the missing half: no AIP today tells a second implementer what to build. - The details that make or break interop (JCS-deterministic subscription
ids,
whsec_secret format, 256 KiB clamp, 410/413 terminal statuses, ack-after-terminal persistence) are exactly the kind of contract that drifts when unspecified. - Most of that contract does not depend on MCP. Splitting the generic EVENT contract from its MCP binding lets a second transport (plain HTTP, A2A, a session tool surface) reuse identity, challenge, envelope, delivery and outbox without re-specifying them.
Design principles
- Same wire as upstream. The envelope, headers, and method shapes are the upstream doc's verbatim, not a local dialect. Deviations are listed as deviations (§Known deviations), not smuggled into the contract.
- Contract once, bindings many. Everything a receiver can observe (identity, challenge, envelope, signatures, retry, outbox) is defined by EVENT. A binding only maps the three operations, their errors, and the capability advertisement onto one transport.
- Identity over lookup. A subscription id is derived from the subscription's identity (RFC 8785 canonical JSON), never minted. This makes subscribe idempotent, refresh the same operation, and unsubscribe recomputable by anyone who knows the identity.
- Verify before mutate. No store mutation happens before the callback challenge passes; a failed remote renewal leaves the previous grant intact.
- Serialize once, sign per attempt. The envelope bytes are computed
once per event; each delivery attempt signs those exact bytes with a
fresh timestamp. A redelivered event is byte-identical and the
requestIdmakes it a consumer no-op. - Persist the delivery, not the intent. A durable outbox row holds the exact bytes and is acked only when terminal; a crash re-dispatches the same row.
Terminology
- EVENT contract (
events/v1): the transport-neutral rules of this AIP (§Specification up to §Errors). - Binding: the mapping of the three operations (list, subscribe,
unsubscribe), their errors and the capability advertisement onto one
transport.
mcp-events/v1is the binding this AIP defines. - Host events surface: the operations of a binding plus its capability
advertisement; in
mcp-events/v1it is theevents/*methods plusevents:{}on the authenticated/mcpendpoint, sharing the transport with tools. - Public events origin: in
mcp-events/v1, a separate, unauthenticated-by-token originPOST /mcp/events/<secret>(MCP 2026-07-28 era only) where the path secret is the auth; the only server ever mounted there is the events surface. - Inbound vs outbound: AIP-60's sentinel pipeline (providers, poll, inbox
delivery) is inbound. This AIP's outbound path is a
webhook-target sentinel whose events are projected to the EVENT envelope and POSTed out. - Delivery guarantee here means: signed webhook + bounded retry + durable
outbox restart-safety, not the internal session delivery ledger
(
delivery-ledger.jsonl, which traces inbox deliveries and is out of scope).
Specification
Event definitions and list
An event definition is exactly {name, description, delivery, inputSchema, payloadSchema}. The list operation returns pages of definitions plus
nextCursor: string | null; it never returns payloads. Definitions are
registered per subject scheme (GitHub in v1) and carry an authorization gate
per principal (see §Known deviations for the v1 single-tenant gate).
delivery is the array of modes the host actually offers for that
definition on the surface that answers: a subset of "poll", "push",
"webhook" (§Binding: mcp-events/v1 fixes which surface offers which).
list result: { events: EventDefinition[], nextCursor?: string }nextCursor is omitted on the last page; it is never null.
Subscribe (and renewal by the same operation)
subscribe params: {
name: string,
arguments: object, // validated against inputSchema
delivery: { mode: "webhook", url: string, secret: string },
ttlMs?: number | null, // omitted → default 7d; null → no expiry
cursor?: string | null, // a cursor from a pull read (§Pull and push reads)
maxAgeMs?: number
}
subscribe result: { id: "sub_<hex32>", refreshBefore: string | null,
cursor: null, truncated: boolean }- Secret MUST be
whsec_+ standard base64 decoding to 24..64 bytes (else the binding's invalid-params error withreason: invalid_secret). The secret is the receiver's Standard Webhooks signing secret; the host never generates it. - TTL:
ttlMsomitted → default 7 days; number → grantedmin(max(requested, 60s), 30d); null →untilnever (no expiry).refreshBeforein the result is the granted expiration itself (ISO-8601 ofuntil.at), not a pre-expiry hint;nullwhen there is no expiry. Expiration stops delivery: the expiry sweep flips the sentinel toexpiredand cancels the provider side. - Identity and idempotence: the subscription id is
sub_<hex32>= sha256 (first 128 bits) of the RFC 8785 (JCS) canonical JSON of{principal, callbackUrl, eventName, args}. A second subscribe with the same identity is a renewal/refresh (see rule 4); identity is shared by unsubscribe minus the secret. - Refresh semantics: on a same-identity subscribe, the host renews the
backing remote FIRST (
provider.renew); only then rotates the stored secret if the submitted one differs and moves the local TTL. A renewal failure raisesBackingSubscriptionErrorand leaves the previous grant fully intact (state, TTL, secret): local never outlives remote. - Verify before mutate: the callback challenge (next section) MUST pass before any store mutation. The verification cache is keyed on sha256(secret), so a new secret always forces a fresh challenge.
- Cursor on subscribe: a submitted
cursoris decoded exactly like a pull-read cursor (unreadable: invalid paramsinvalid_cursor; issued to another principal: forbiddencursor_principal_mismatch). Webhook delivery never replays past events in v1, so a non-null cursor makes the result carrytruncated: true(on create and on refresh): the single signal that delivery starts later than the position the client supplied. Without a cursor,truncatedisfalse. The resultcursorstaysnull(§Known deviations). - Callback URL shape: a
delivery.urlthat is not an absolutehttps:URL is rejected as invalid params (invalid_callback_url) before any network call. Unsubscribe does not apply this check, so a subscription created with any URL can always be removed.
Callback verification (the challenge)
- The host POSTs to the callback URL a body
{"type": "verification", "challenge": "<fresh 64-hex>"}withwebhook-id: msg_verification_<24-hex>, a freshwebhook-timestamp,webhook-signature(Standard Webhooks, the submitted secret), andX-MCP-Subscription-Id: <id>. - The receiver MUST answer 2xx with JSON echoing the challenge; the echo
comparison is constant-time. A failed fetch, status or shape is a
CallbackEndpointError. Itsreasonis one of the sixlastErrorcategories of the MCP Events extension:connection_refused,timeout,tls_error,http_4xx,http_5xx,challenge_failed. An SSRF refusal (private target, redirect) is reported asconnection_refused, so the error never tells the client why a URL was refused. The error message is a fixed sentence per category: it never repeats the endpoint's host, address, status or response text, so the challenge is not an oracle on the endpoint. (The internal challenge outcome keeps a finer vocabulary,non_https,challenge_failed,ssrf_blocked,timeout,non_2xx, used by the host's own sentinel webhook surface; a binding translates it at its boundary.) - A successful verification is cached (10 minutes, bounded cache, keyed on the secret hash, per callback URL) so subsequent subscribes to the same (principal, url, secret) skip the POST. A rotating secret invalidates it.
- The callback URL MUST be
https://and pass the egress SSRF gate, the same gate as delivery (§Delivery).
The delivered envelope
{ "eventId": string, "name": string, "timestamp": string,
"data": object, "cursor": null }- Wire shape is upstream-verbatim:
eventId(thewebhook-idheader carries it, so a receiver's dedup key is free),name,timestamp,data,cursor. Webhook delivery is non-replayable in v1:cursorisnullin every delivered webhook envelope, and thegap/terminatedcontrol envelopes are never sent over the webhook. Pull and push reads (§Pull and push reads) carry real cursors. - 256 KiB clamp: if the serialized envelope exceeds 262 144 bytes,
datais replaced by{summary, subject}and the envelope gains the extension fieldtruncated: true(§Known deviations for why this is an extension). The clamp happens before any signature: the clamped bytes are what every attempt signs.
Delivery (one event = one signed POST)
- Serialization invariance: the envelope is serialized exactly once; each attempt re-signs the same bytes with a fresh timestamp. Between the attempts the body bytes are bitwise identical.
- Signature (Standard Webhooks):
webhook-id=eventId,webhook-timestamp= fresh Unix seconds per attempt,webhook-signature= space-separatedv1,<base64 HMAC-SHA256 over "id.timestamp." + body>, one segment per signing secret. During a secret rotation (subscribe submitted a different secret), the previous secret is kept for a 10-minute dual-sign window and the row carries both signatures, so a receiver rotating at its own pace stays verifiable. - Headers:
Content-Type: application/json,webhook-id,webhook-timestamp,webhook-signature,X-MCP-Subscription-Id. - Outcome per attempt:
2xx= delivered (acked).410(Gone) and413(Payload Too Large) are terminal, never retried. Everything else (other 4xx, 5xx, 3xx, network error) retries with exponential backoff 250ms base doubling, capped at 4000ms, at most 5 attempts (delivery timeout 15s per attempt). After 5 failed attempts the event is dead and surfaced as such. - SSRF gate: the POST targets a URL that MUST be
https://on a publicly routable address: DNS resolution then validation then a pinned connection IP (closing TOCTOU/DNS-rebinding), original hostname preserved for TLS/SNI, no HTTP redirects followed. The same gate serves challenge and delivery.
Persistence and restart (at-least-once)
- Subscriptions persist in
sentinels.json(mode 0600, atomic writes); webhook secrets live in a separate store and never appear in sentinel records, views, or tool results. - Outbox: the webhook fire path appends a durable row BEFORE
dispatch:
{sentinelId, requestId, eventId, bodyBytes (utf-8 base64 of the exact wire bytes), cursor: null, deliveryState, status: pending|delivered|dead}.requestIdis deterministic over(sentinelId, eventId), so a restart-redelivery is a receiver-side no-op on that key, while the wirewebhook-idheader stays the event's own id. - Ack after terminal: the backing sentinel event is acked to its
provider ONLY when the outbox row reaches terminal status (
delivered, ordeadper retry cap, subscription expiry, or removal). A dispatch that crashed stayspendingand the event un-acked; a restart re-dispatches by the stored exact bytes. - Ordering across events of one subscription is never assumed (single
pending row at a time is not a guarantee); receivers dedup on
eventId/requestId. Delivered rows are reaped after 24h; pending rows age out dead after 7 days. - Expiry stops delivery: the startup/per-tick sweep flips an expired
subscription to
expired(cancels the provider side); a gone subscription's pending rows godeadwith a reason.
Pull and push reads (the journal)
Besides webhook delivery, a host MAY offer two reads of the same events: pull (the client asks for what happened after a cursor) and push (the host keeps one response open and writes events as they land). Both read one journal, and neither is a new source of events.
- Journal: one append-only journal per
(name, arguments)key, fed by a shared provider watch (a lease). Each entry has a monotonic sequence number; an event already journaled is never journaled twice (dedup oneventId). When the host cannot prove continuity (a new watch after a restart, a provider gap), it journals a gap entry. - Lease: the first read of a key opens the provider watch; later reads reuse it. A lease nobody reads is released after an idle TTL, so an abandoned key never leaves an orphan watch. An open push read holds its lease: a held lease is never released for idleness.
- Retention: entries older than the retention window, and journals no lease feeds any more, are purged periodically, not only at host start.
- Cursor: opaque to the client, bound to the principal that received it (a cursor presented by another principal is forbidden), and interchangeable between pull and push: a pull cursor resumes a push read and the reverse.
- Catch-up entries: a catch-up (a redelivery, or a snapshot diff after
an outage) feeds the journal like any other source. The entries it adds
copy the
replayed: trueattribute of the event (AIP-60SentinelEvent) and never reopen a closed session. The journal itself dedups oneventIdonly, as in item 1. The natural-key check that tells two ids for one fact apart runs before the journal, in the feed (AIP-60 §Natural key andreplayed); an event it drops never reaches the journal, and when both checks apply the natural key decides first,eventIdsecond. The feed (shared subscription, health, fallback) is defined in AIP-60, which refers to this journal, lease and gap rather than redefining them. truncated: a read that starts later than the cursor it was given (retention,maxAgeMs, a gap, a replaced journal) saystruncated: trueand returns what remains; it is never an error.- Push framing (protocol-level details in the binding): the first
message confirms the read and states the granted heartbeat; then one
message per event, each with the cursor positioned after it; a
heartbeat with the head cursor after every silence of the heartbeat
interval; a gap mid-read re-confirms with
truncated: trueand the read goes on; a provider failure is reported as a category (never the provider's raw message) and the read stays open. Every validation error is answered before the first message, as an ordinary error. A client that goes away is the end of the read: the host releases the hold and writes nothing more.
Unsubscribe
- Unsubscribe recomputes the same identity (minus the secret) and is
idempotent: a second call, or a first call with no live record,
returns an empty success (
{}). - Removal first persists a tombstone (drop local deliveries, then cancel remote; the sweep retries the cancel until it 404/204s), so a dead-but-retried remote watch cannot resurrect deliveries.
Errors
| Error | reason (examples) |
|---|---|
| Invalid params | invalid_arguments, invalid_secret, invalid_ttl, invalid_cursor, invalid_callback_url, identity_conflict |
| NotFound | unknown_event (with kind: "event") |
| Forbidden | unauthorized, cursor_principal_mismatch |
| ResourceExhausted | poll_watch_quota (with limit, max); the stream cap (with limit: "streams", max) |
| Unsupported | unsupported_delivery_mode (with feature: "deliveryMode", value), provider_unavailable |
| CallbackEndpointError | connection_refused, timeout, tls_error, http_4xx, http_5xx, challenge_failed |
| BackingSubscriptionError | backing_renew_failed, backing_subscription_expired |
A binding MUST map each error to a distinct transport error and carry the
reason verbatim; it never turns a typed error into a generic one.
Binding: mcp-events/v1
mcp-events/v1 maps the EVENT contract onto MCP. It is the binding the
OpenAI "MCP Events" plugin contract consumes.
Surfaces and origins
- Authenticated
/mcpendpoint, both eras of AIP-77: the host mountsevents/list,events/subscribe,events/unsubscribeand, when the extension is on,events/pollas native JSON-RPC request handlers (nottools/call), and announcesevents: {}in capabilities atinitialize(2025-11-25) and inserver/discover(2026-07-28).events/streamis served on the 2026-07-28 era only. - Public events origin
POST /mcp/events/<secret>: mounted only when a secret of ≥ 32 characters is configured; it serves the MCP 2026-07-28 era (server/discoverwithsupportedVersionsandevents:{}, stateless resultresultType: "complete"), mounts only the events surface (no tools, resources, or prompts without a security review), and gates subscribe, poll and stream against an optional repo allowlist (-32024, checked before any watch or stream is opened). - The two origins are alternates for the same contract; a client uses either.
Method mapping
| EVENT operation | JSON-RPC method | Params / result |
|---|---|---|
| list | events/list | §Event definitions and list |
| subscribe | events/subscribe | §Subscribe |
| unsubscribe | events/unsubscribe | §Unsubscribe; result {}. delivery.mode may be omitted. |
| pull read | events/poll | {name, arguments, cursor?, maxAgeMs?, maxEvents?} → {events, cursor, truncated, hasMore, nextPollMs} |
| push read | events/stream | §events/stream |
Extension advertisement
When the extension is on (mcp.eventsExtension, default on), the host
declares capabilities.extensions["io.modelcontextprotocol/events"] = { listChanged: false } alongside events: {}: same methods, two ways
for a client to find them. The event registry is static, so no
notifications/events/list_changed is ever sent and subscriptions/listen
is not served. For the same reason the 2026-07-28 server/discover does not
advertise listChanged on tools, resources or prompts.
delivery in events/list names what the answering surface serves:
["poll", "push", "webhook"] on the 2026-07-28 era while events/stream is
served, ["poll", "webhook"] on 2025-11-25 and when the stream is switched
off (mcp.eventsStream: false), ["webhook"] when the extension is off.
Headers (2026-07-28 era)
events/subscribe, events/unsubscribe, events/poll and events/stream
carry Mcp-Name equal to params.name; a missing or different value is
-32020 (HTTP 400). events/list carries none.
events/stream
request events/stream { name, arguments, cursor?: string | null, maxAgeMs?, heartbeatMs? }
headers Mcp-Method: events/stream ; Mcp-Name: <params.name> ;
Accept: application/json, text/event-stream
response Content-Type: text/event-stream ; one "data: <json>" frame per JSON-RPC message ;
no "id:" line, no SSE comment
messages notifications/events/active { cursor, truncated, heartbeatMs } first, and after a gap
notifications/events/event { eventId, name, timestamp, data, cursor }
notifications/events/heartbeat { cursor }
notifications/events/error { error: { code, message, data? } } stream stays open
notifications/events/terminated { error: { code, message, data? } } stream ends
final { jsonrpc, id, result: { resultType: "complete", _meta } } only when the host closes- Every message carries
params._meta["io.modelcontextprotocol/subscriptionId"]= the JSON-RPCidof the request, unchanged (string or number). heartbeatMsdefaults to 30 000 and is clamped to [5 000, 60 000]; the granted value is the one inactive. The heartbeat is anotifications/events/heartbeatframe carrying the head cursor, not an SSE comment (a comment cannot carry the cursor).AcceptMUST allowtext/event-stream(*/*andtext/*do), else HTTP 406. Every validation error of the request itself (-32602,-32023,-32024,-32025,-32026, raised while opening the stream) is a plainapplication/jsonJSON-RPC error with HTTP status200, and no stream is opened: these are handler errors in the sense of AIP-77 §Error mapping, like the same codes onevents/poll. Protocol-level rejections keep their AIP-77 status: header mismatch (-32020) is400, an unacceptedAcceptis406,events/streamwhile the stream is switched off is-32601404, and an uncaught failure is-32603500.- A type whose
deliverylacks"push"is-32026withdata: { feature: "deliveryMode", value: "push" }. - At most 32 streams are open at once (
-32025,data: { limit: "streams", max: 32 }); no general cap on concurrent requests applies to streams. When the shared watch pool is full the answer is the same asevents/poll:-32025,data: { reason: "poll_watch_quota", limit: "pollWatches", max }. - A provider failure is
notifications/events/errorwithcode: -32603,message: "UpstreamError",data.reasona category; the stream stays open. notifications/events/terminatedends the stream when its type leaves the registry or the principal is no longer authorized at a periodic re-check, then the final frame is sent. With the static registry and the single-tenantauthorizeof v1 it does not fire in practice.- Client abort (closing the HTTP response) ends the stream with no result frame; host shutdown writes the final frame, then closes. A write that does not drain within 10 s closes the stream; the client resumes from its cursor.
- The response is not decorated: the final frame carries no
ttlMs,cacheScopeorserverInfo.
Upstream events from an imported server (added 2026-12-02, per AIP-53)
Everything above is the host serving events to a client. An MCP server that an app imports (AIP-53) can also be the source: the host is then the client, and the server announces events of the app. This is the consumer direction, and it reuses the same envelope.
- The notification. The server MAY send
notifications/events/eventwith params{ eventId, name, timestamp, data, cursor }, exactly the envelope of "The delivered envelope", on its connection to the host, without the host having openedevents/streamor sentevents/subscribe(a notification with noio.modelcontextprotocol/subscriptionIdin_metais an unsolicited event).cursorisnulland ignored: this direction has no replay, so an event sent while the host is not connected is lost. - Names are the app's.
nameis a name the importing app declared in itsevents:(AIP-53 App events), without theapp:prefix. The host accepts only declared names, validatesdataagainst the declaration'spayloadSchema, drops aneventIdit already routed for that app, bounds the rate, and drops an envelope over 256 KiB (it cannot be clamped to a valid payload). Everything else is dropped and logged, never routed. - Routing is the host's. An accepted event is published on the host
event bus as
app:<appId>/<name>(AIP-37 App events). The server cannot address a consumer; it names an event, and whoever the app's declarations and the host's bindings connect to it receives it. - No capability needed on the server side beyond sending. A server that never sends the notification is unchanged, and a host that does not accept it ignores the notification, as MCP requires of an unknown notification.
- Not the push or poll surface. This direction is not an
events/*method: it creates no subscription, no lease and no journal, and an event received this way does not enter the journal of "Pull and push reads".
Error mapping
| EVENT error | JSON-RPC code | Carried as |
|---|---|---|
| Invalid params | -32602 | data.reason |
| NotFound | -32023 | data.reason, data.kind |
| Forbidden | -32024 | data.reason |
| ResourceExhausted | -32025 | data.reason, data.limit, data.max |
| Unsupported | -32026 | data.reason, data.feature, data.value |
| CallbackEndpointError | -32027 | data.reason (the six categories), data.legacyReason and data.legacyCode: -32015 for one release |
| BackingSubscriptionError | -32603 | data.kind: "backing_subscription", data.reason, data.legacyCode: -32016 for one release |
The transport surfaces adapter errors verbatim (code + data). -32015 and
-32016 were the pre-standard codes of this binding; they survive only as
data.legacyCode.
Known deviations (v1, deliberate, listed here so they are not lost)
- Single tenant, no stop-on-revoke. Upstream asks a host to re-check
the subscribing user's access during the subscription's lifetime and
stop delivery on revocation. v1 grants every principal (exactly two:
bearer-daemon and trusted-session) the same scope, and
authorizeis a constant. On the public origin this means any path-secret holder gets the same scope, mitigated by an optional repo allowlist. This is the largest known gap to a multi-tenant host; tracked as future work (per-auth-profile principals + periodic recheck + stop-on-revoke). - No read tool after the clamp. The spec-recommended "large records →
summary + read tool" is implemented as the summary only; the payloads
behind a
{summary, subject}clamp are not re-readable through any tool. Adding anevents_payload_readtool is the matching follow-up. - Top-level
truncated: trueon a clamped envelope is a wire extension: upstream documentstruncatedinside subscribe/replay results, not on the event envelope. Low risk (tolerant receivers), but strictly spec-shaped receivers may reject it; keep it in mind on strict conformance testing. initializenever advertises the 2026-07-28 era on/mcp. Deliberate: advertising it there made 2025-11-25-only clients switch eras and fail. The 2026-07-28 era of/mcpis selected per request (AIP-77 routing: theMCP-Protocol-Versionheader or the body_metaprotocol version), and that era servesserver/discover.- Webhook
cursoris alwaysnull(envelope and subscribe result), and a webhook subscription never replays past events: a supplied cursor only yieldstruncated: true. The MCP Events extension asks a type that ever returns a non-null cursor to always do so; pull and push reads do, webhook does not yet. - Unsubscribe is idempotent: an unsubscribe with no matching
subscription returns
{}, not-32023NotFound. The extension lists NotFound for this case without a MUST and calls unsubscribe an eager cleanup; this AIP keeps idempotence (§Unsubscribe). - No
deliveryStatusin the subscribe/refresh result (optional in the extension), and nogap/terminatedcontrol envelopes over the webhook. tls_erroris never emitted: the egress gate does not tell a TLS failure apart from a refused connection, so both areconnection_refused.events/streamis served over Streamable HTTP only (no stdio transport, hence nonotifications/cancelledhandling), on the 2026-07-28 era only. Behind a tunnel that buffers a streamed response until it ends, push delivers nothing; useevents/pollthere.subscriptions/listenis not served, so no list-change notification exists (listChanged: falseeverywhere).
Rationale
- Why EVENT, with MCP as a binding: identity, challenge, envelope,
signatures, retry and outbox are what a receiver depends on, and none of
them is MCP-specific. Naming the IP after the capability (
events/v1) and the MCP mapping after its transport (mcp-events/v1) lets a second binding reuse the contract instead of forking it, and keeps the MCP binding diffable line by line against the upstream OpenAI page. - Why native methods, not tools (
mcp-events/v1): the upstream contract (and any compliant client) dispatchesevents/*as JSON-RPC methods on the auth endpoint; atools/calltranslation cannot produce the needed capability advertisement, and the host has no reason to fake one. - Why JCS-deterministic ids: subscribe-by-identity makes the whole trio idempotent without a lookup, lets a principal re-derive the id without a subscription registry at hand, and lets unsubscribe stay correct after a restart moved things; JCS (RFC 8785) is the one canonical JSON form that survives numeric and key-order differences.
- Why challenge-before-mutation with a per-secret cache key: a subscription that never verified would be a spam relay; a cache keyed on the secret (and not just URL/principal) means a leaked or rotated secret can never inherit a previous verification.
- Why serialize-once + sign-per-attempt: both Standard Webhooks
verification and receiver-side dedup are simplest when the body never
changes across retries; a fresh
webhook-timestampper attempt keeps the receiver's staleness check meaningful. - Why 410/413 are terminal: the receiver told us the subscription is gone (Gone) or this receiver will never take this size (Payload Too Large); retrying would only be harassment, and terminal statuses carry a positive signal the sender can audit.
- Why an outbox row with exact bytes + ack-after-terminal: the alternative (in-process delivery with mark-seen-first) loses an event to a crash in the gap; requestId determinism caps the receiver-side cost of the worst case (restart-redelivery) at one no-op.
- Why the public origin is a separate, minimal, path-secret origin:
the host must be reachable without exposing the daemon's bearer token to
the wider world. The path secret is the only thing validated, the
surface is the events surface alone, and a tunnel must forward only
/mcp/events/, nothing else. - Adjacency (extend, don't fork): the MCP binding is the upstream MCP Events wire, profiled, not a competing dialect; delivery is Standard Webhooks 1.0 unchanged. This AIP only adds what those documents leave to the host: identity, persistence, restart safety, and the link to AIP-60.
Reference Implementation
Single implementation: agentproto/ts @ 765660d (2026-11-21 audit:
conforms to the upstream OpenAI page on every audited mechanism; a
conformance suite of 36 checks passes with 0 failures; two transports
covered; deviations listed above).
| Concern | Source (in agentproto/ts) |
|---|---|
Native method dispatch, events:{} at initialize, era notes | packages/mcp-server/src/events-methods.ts:26 (protocol version const), :69-72 (capability), :75-81 (no server/discover on /mcp, the deviation), :86-92 (request handlers) |
| Adapter (list/subscribe/refresh/unsubscribe, TTL, errors) | packages/runtime/src/mcp-events/adapter.ts:10-19 (v1 invariants), :48-51 (60s/7d/30d TTL bounds), :58-59 (refreshBefore = granted expiry), :68-73 (untilForTtl), :104-105 (-32015), :117-122 (-32016), :245-254 (events/list), :259-358 (subscribe; :276-281 secret gate, :282-300 verify-before-mutation), :303-340 (refresh path), :364-415 (idempotent unsubscribe + tombstones), :421-431 (envelope) |
JCS identity (sub_<hex32>) | packages/runtime/src/mcp-events/subscription-id.ts:49 (RFC 8785 canonicalize), :76-84 (id derivation) |
| Event definitions per scheme; principals | packages/runtime/src/mcp-events/events-registry.ts:36-44 (principals), :46-60 (EventDefinition), :174+ (inputSchema validation), :245-247 (single-tenant authorize, the deviation), :366-368 (tenantScope) |
| Challenge | packages/runtime/src/webhook-egress/challenge.ts:115-183 (verifyCallback; :139 fresh 64-hex, :141 msg_verification_*, :131-137 cache keyed on sha256(secret), :65 10-min TTL, :149 X-MCP-Subscription-Id) |
| Standard Webhooks signing | packages/runtime/src/webhook-egress/signing.ts:28-33 (header shape), :51-64 (whsec_ 24..64 byte decode), :72-91 (HMAC-SHA256 v1,, multi-secret space-join) |
| Delivery loop | packages/runtime/src/webhook-egress/delivery.ts:22-31 (envelope verbatim + truncated extension), :108-115 (clamp 256 KiB, 5 attempts, 250→4000ms backoff), :119 (410/413 terminal), :126-140 (clamp → {summary, subject}), :142-205 (the loop; serialize once :152, fresh timestamp per attempt, headers :181, 15s timeout :182) |
| SSRF gate | packages/runtime/src/webhook-egress/ssrf-fetch.ts:66 (isPubliclyRoutable), :240 (ssrfFetch), :277-286 (resolve → validate → pin IP, servername SNI) |
| Events-only public surface + allowlist | packages/runtime/src/mcp-events-surface.ts:24-42 (:27-41: events surface, events_ping, repoAllowlist gate) |
| Public origin route + MCP 2026-07-28 | packages/runtime/src/http-server.ts:1245-1247 (route + tunnel rule), :1923, :2900 (handleModernRequest), :3439-3442 (path-secret match); packages/runtime/src/mcp-modern/index.ts:121-133 (server/discover); gate packages/runtime/src/index.ts:5226-5234 (AGENTPROTO_MCP_EVENTS_SECRET ≥ 32 chars, AGENTPROTO_MCP_EVENTS_REPOS allowlist) |
| Durable outbox + ack-after-terminal + expiry sweep | packages/sentinel/src/sentinel-webhook-outbox.ts:1-34 (design: row shape, ack-after-terminal, ordering, 24h/7d reaping), :52-58 (row), :173 (webhookRequestId deterministic over (sentinelId, eventId)), :364 (use); packages/sentinel/src/sentinel-runtime.ts:377-399 (expiry sweep), :415-473 (fire path + ackAfterTerminalRow) |
| Subscription + secret persistence, rotation | packages/sentinel/src/sentinel-store.ts:123-132 (SentinelWebhookSecret, 10-min prevSecret window), :209 (sentinels.json) |
| End-to-end tests | packages/runtime/src/__tests__/mcp-events-e2e.test.ts, mcp-events-principal.test.ts, mcp-events-route.test.ts, mcp-events-surface.test.ts, sentinel-delivery-apply.test.ts, external-sentinel-delivery.test.ts; packages/mcp-server/src/__tests__/events-methods.test.ts |
| Conformance suite | scripts/mcp-events-conformance/ (36 PASS / 0 FAIL at 765660d) |
The rows above are the 2026-11-21 audit at 765660d; their line numbers
are exact at that commit and drift on later ones. On current main, use
the table below. The MCP Events extension (pull and push reads, official
codes, Mcp-Name) landed later; the rows below cite agentproto/ts @
ac2fe639a (agentproto/ts#2891 merged, after agentproto/ts#2887). The
cited files are unchanged from that commit to 3eb5bd1bd.
| Concern | Source (in agentproto/ts) |
|---|---|
Extension advertised alongside events:{}, events/poll registered | packages/mcp-server/src/events-methods.ts:55 (io.modelcontextprotocol/events), :88-91 (capabilities), :114 (events/poll handler) |
Official codes, data discriminants, -32027 categories and fixed messages | packages/runtime/src/mcp-events/adapter.ts:101 (EVENTS_ERR), :117-144 (NotFound kind, ResourceExhausted limit/max, Unsupported feature/value), :175-205 (callbackEndpointReason, callbackEndpointError, legacyReason, legacyCode), :209 (https check on subscribe) |
nextCursor omitted on the last page; delivery filtered per surface | packages/runtime/src/mcp-events/adapter.ts:383-401 (eventsList, pollEnabled, pushEnabled); packages/runtime/src/mcp-events/events-registry.ts:264 (["poll", "push", "webhook"]) |
Cursor on subscribe (truncated: true), unsubscribe without mode | packages/runtime/src/mcp-events/adapter.ts:438 (truncated), :495, :513 (results), :529 (modeOptional) |
| Pull read and cursor | packages/runtime/src/mcp-events/adapter.ts:601-602 (maxEvents 100 / 1000), :619-625 (result), :632-659 (cursor bound to the principal), :667 (eventsPoll) |
| Journal and lease | packages/runtime/src/mcp-events/poll-journal.ts:42-43 (24 h, 5000 entries), :230 (subscribe, wake on append and gap); packages/runtime/src/mcp-events/poll-lease.ts:27-31 (idle TTL 5 min, pump 15 s, 64 leases, purge every 10 min), :222 (retain), :239 (onPumpError), :258 (a held lease is never swept) |
| Push read engine | packages/runtime/src/mcp-events/stream.ts:24-33 (subscription id key, heartbeat bounds, 32 streams, 10 s back-pressure, re-check), :138 (openEventsStream) |
events/stream answered before the in-process bridge; SSE writer | packages/runtime/src/mcp-modern/index.ts:358 (branch before openBridge), :204-210 (listChanged withdrawn from server/discover); packages/runtime/src/mcp-modern/validate.ts:59 (Accept), :169-171 (Mcp-Name); packages/runtime/src/http-server.ts:3110 (writeModernResponse), :3133 (one data: frame per message), :6661 (final frame on shutdown) |
| Allowlist on the public origin | packages/runtime/src/mcp-events-surface.ts:21 (isSubscriptionPermitted), :42, :50 (subscribe, poll), :63 (guardEventsStream) |
| Switches | packages/runtime/src/mcp-config.ts:17-18 (mcp.eventsExtension, mcp.eventsStream, both default on) |
| Tests | packages/runtime/src/__tests__/mcp-events-poll.test.ts, mcp-events-codes.test.ts, mcp-events-stream.test.ts, mcp-events-stream-http.test.ts, mcp-events-surface.test.ts, mcp-modern-contract-live.test.ts; fixtures __tests__/fixtures/mcp-2026-07-28/events-*.json (copied from the extension text) |
Backwards Compatibility
Additive everywhere. A host that does not mount an events surface exposes
no events/* methods and no public origin; existing clients see no change.
AIP-60's frozen webhook target kind gains a delivery contract, so a
conformant host that previously rejected target.kind: "webhook" keeps
rejecting it unless it implements this AIP; the reserved-kinds rule of
AIP-60 (reject with not_implemented until a delivery is defined) is what
this AIP activates for webhook. No existing schema field changes. No AIP
is replaced.
Security Considerations
- Secret handling:
whsec_secrets are validated (standard base64 after a fixed prefix, 24..64 raw bytes) before use, stored in a separate 0600 store from the sentinel record, never logged (only the prefix shape appears in errors), never echoed in views or tool results. During rotation the previous secret lives for exactly one 10-minute window. - Challenge: single-use (fresh 32 random bytes hex), constant-time comparison, bounded cache keyed on the secret hash (a new secret always re-verifies), and the signed challenge POST gives the receiver the same HMAC guarantee as a real delivery.
- Egress SSRF: both challenge and delivery go through the shared gate
(HTTPS-only, public-routable only, resolve-then-pin, SNI preserved,
no redirects), so a hostile
delivery.urlcannot probe the host's private network or loop back into the host's own inbound routes. - Public origin (
mcp-events/v1): mounted only on an explicit ≥ 32-char secret; the events surface is the only server there (no tools), subscribe is allowlist-gated, and a tunnel is documented to forward only/mcp/events/: the origin has deliberately minimal surface. - Clamp: two effects, both security-adjacent: the summary replaces a payload the receiver may never see (leak minimization), and the size cap protects the receiver from a giant POST its client billed per token.
- Unsubscribe: identity is recomputable without a secret, but the challenge gate is on subscribe; the remote cancel is retried via tombstone so a stuck provider watch cannot continue delivering as a ghost.
Conformance
A host is conformant to events/v1 when:
- Challenge verification runs before any subscription mutation and never caches a verification across a secret change.
- Every delivered envelope is upstream-shaped
(
{eventId, name, timestamp, data, cursor}),cursorisnull, and the signature body matches the sent bytes per attempt. - 2xx acks, 410/413 are terminal, retry is bounded exponential ≤ 5
attempts, and a serialized body over 256 KiB is only ever sent as
{summary, subject}(+ the documented deviation if any). - The outbox persists exact bytes before dispatch and acks the backing event only after terminal status; a mid-delivery restart re-dispatches identical bytes and delivers at-least-once, never more than one distinct envelope per event.
- Subscription identity is JCS-deterministic over (principal, callbackUrl, eventName, args), subscribe is idempotent up to renewal, and unsubscribe returns an empty success for any state.
A host is additionally conformant to mcp-events/v1 when events:{} is
advertised at initialize, and events/list, events/subscribe,
events/unsubscribe are native JSON-RPC methods on the same authenticated
endpoint as tools, with the error codes of §Error mapping.
A host that declares the io.modelcontextprotocol/events extension is
additionally conformant when: events/poll and events/stream read one
journal with interchangeable, principal-bound cursors; truncated: true
marks every read that starts later than its cursor; events/stream sends
notifications/events/active first, answers every validation error before
any frame, keeps a heartbeat frame carrying the cursor, and releases its
watch on client abort; delivery lists only the modes the answering
surface serves; and Mcp-Name is enforced on the four named methods.
A named deviation (truncated top-level, single-tenant authorize, no read
tool, no server/discover on the root) is conformant only if listed in
the implementation's deviation list.
Open questions
- Read tool post-clamp: the matching follow-up tool to the
{summary, subject}clamp; spec-recommended upstream, dropped in v1 by the implementation plan (§Known deviations 2). What ground it covers (a full payload read? a paginated re-read?) is open. - Multi-tenant principals + stop-on-revoke: the answer to §Known deviations 1; needs an operator-approved auth-profile shape before it can be a MUST here.
truncatedfield placement: keep the top-level extension with a registered note (receiver tolerance means it ships today), or move it intodata(strict-spec shape) pending a conformance test on the real upstream consumer.- Frozen wire schemas: publish
resources/aip-76/draft/(envelope.schema.json,EventDefinition.schema.json) in a follow-up PR, or stay prose-only like AIP-75. This PR ships prose only. - Second binding: which transport earns the next binding of the
EVENT contract (plain HTTP for non-MCP clients, A2A, a session tool
surface over AIP-46). Pull and push reads now exist in
mcp-events/v1; whether they belong in the transport-neutral contract as MUSTs is open. - Webhook replay: replaying a webhook subscription from its cursor
(and returning a safe watermark as the subscribe
cursor) would close §Known deviations 5; it needs the webhook path to hold a journal lease. - Second implementer: the 2-implementer rule for Final. The conformance suite in the reference implementation is the starting point; extracting a portable one is a blocker on the path from Draft to Final, not to Draft.
See also
- AIP-1: process, RFC 2119, adjacency clause (why this extends MCP rather than forks it: the wire is upstream-verbatim)
- AIP-32: the MCP driver, the client side of the same protocol family; a host may be both a client (AIP-32) and a watched server (this AIP)
- AIP-60: SENTINEL, subjects, providers, and the inbound
inbox delivery; the
webhooktarget kind this AIP gives a delivery contract to, and the store/runtime this AIP composes with - AIP-46: SESSION, the inbox AIP-60 delivers into (the inbound direction; nothing here changes it)
- Upstream: OpenAI "MCP Events – plugins" page (the wire contract the
mcp-events/v1binding profiles); Standard Webhooks 1.0 (signature format); RFC 8785 (JCS, subscription identity)
AIP-75: VOICE (voice/v1): speech provider contracts and the voice session
Fixes how a product talks to voice providers: three provider contracts (SttProvider, TtsProvider, RealtimeProvider) declared with defineVoiceProvider, one VoiceSession with two engines (realtime and cascade) and why interruption differs between them, the environment variables that choose them and the rule that orders those variables, and the usage record that is the only thing a voice session hands to billing. There is no VOICE.md.
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.