Repository navigation
Description
Summary
The Events extension (io.modelcontextprotocol/events, SEP-3415) reached Beta: overview, specification. It lets a client subscribe to event types the server lists with events/list, and receive occurrences ({eventId, name, timestamp, data, cursor}) by poll (events/poll), push (events/stream) or webhook (events/subscribe / events/unsubscribe).
The everything server is the protocol showcase and already serves the Tasks extension on 2026-07-28 (server/tasks.ts). It should serve Events the same way, so that clients, the Inspector and the conformance Events suite (modelcontextprotocol/conformance#521) have a reference server to run against.
Where things stand
- SDK.
@modelcontextprotocol/server2.4.0 has no Events support. It does have what a hand-written implementation needs:setRequestHandler(method, { params, result }, handler)for custom methods,ctx.mcpReq.notifyfor notifications related to a request,ctx.mcpReq.signalfor cancellation, andcapabilities.extensions. This is howserver/tasks.tsserves Tasks. - Upstream work in progress:
- feat: Events extension (SEP-3415) typescript-sdk#3209 (draft): a full Events extension under
ext/events. - feat(server): let extensions honor subscriptions/listen filter fields and deliver events typescript-sdk#3203: lets extensions honor extra
subscriptions/listenfilter fields. TodaySubscriptionFilterSchemastrips unknown keys, soeventsListChangedis dropped. - [v2] Expose per-request stream end (onRequestStreamEnd) in RequestOptions for custom long-lived requests typescript-sdk#3060: per-request stream end for custom long-lived requests.
- feat: Events extension (SEP-3415) typescript-sdk#3209 (draft): a full Events extension under
- Era. The extension is defined for 2026-07-28 and later only. A 2025-era client must keep getting
-32601forevents/*.
Plan
Scope: poll and push now, webhook later
Webhook delivery is out of scope for this issue. The spec requires an authenticated principal for events/subscribe and events/unsubscribe (Forbidden otherwise), and says unauthenticated servers may offer poll and push but not webhook. The everything server has no auth. Webhook also brings HTTPS-only callbacks, SSRF hardening at delivery time, endpoint verification, Standard Webhooks HMAC signing and TTL bookkeeping. If we want it, it gets its own issue once there is a principal to key on.
listChanged is advertised as false (an empty settings object) until typescript-sdk#3203 lands, because the SDK drops the eventsListChanged filter field.
Event types
These are synthetic, deterministic and need no upstream service. Names follow the server's kebab-case convention. Together they cover both cursor models the spec defines.
clock-tick: a replayable type, delivered by["poll", "push"].- Tick k occurs at a fixed epoch + k × period, so every event can be computed from the clock. There is nothing to store, which matters because on 2026-07-28 HTTP every request gets a fresh server instance.
- The cursor encodes the tick index. A bounded retention window (for example the last 100 ticks) gives
truncated: truea real trigger. - The type exercises
maxEvents/hasMore,maxAgeMs,nextPollMsand a stableeventId(tick-<k>). - Its
inputSchemahas a filter (for exampleeveryNth) and a transform (for exampleincludeIso). ItspayloadSchemais minimal.
custom-event: an emit-only type, delivered by["push", "poll"].- The cursor is always
null(absent), andtruncatedis alwaysfalse. - A new tool,
trigger-event, emits it. It is verb-first, kebab-case and annotated, and takes a short message. - Events go through a process-wide bus with a small ring buffer, so a poll or a push stream served by a different instance still sees them. This is the same reasoning as the task store in
server/tasks.ts.
- The cursor is always
Methods
events/list: both descriptors, with thedelivery,inputSchemaandpayloadSchemafields, andnextCursorpagination support.events/poll: params validated with Zod. Anullcursor returns no events and a fresh cursor. The result carries{resultType: "complete", events, cursor, truncated, hasMore, nextPollMs}.events/stream: a long-lived request.- It first sends
notifications/events/activewith the grantedheartbeatMs: the client's suggestion, clamped, defaulting to 30 s. - It then sends
notifications/events/eventas events occur, andnotifications/events/heartbeatcarrying the current cursor whenever the interval passes without another message. - Every notification carries
_meta["io.modelcontextprotocol/subscriptionId"]= the request id. - A gap mid-stream is reported as a fresh
notifications/events/activewithtruncated: true. - On cancellation (
notifications/cancelledon stdio, or abort on HTTP) the server clears timers and listeners. It sends a finalStreamEventsResultonly when it closes the stream itself. - Optionally, a test-only argument produces one
notifications/events/error, so a client can see the recoverable-error path.
- It first sends
- Errors: these use the spec's codes, defined as constants next to the module.
NotFound(-32023,data.kind: "event"): unknown name.InvalidParams(-32602): arguments that do not match theinputSchema.Unsupported(-32026,data: {feature: "deliveryMode", value}): a mode the type does not offer.-32601:events/subscribeandevents/unsubscribe, since webhook is not offered.
Wiring
-
Add a new module
server/events.tswith a purpose header, modelled onserver/tasks.ts. It exportsEVENTS_EXTENSIONandregisterEventsExtension(server, context). -
In
server/index.ts, the extension is advertised inextensionsand registered only whenera === "modern", next to Tasks. -
trigger-eventis registered inregisterModernTools. -
Timers and bus listeners are released through
context.onCleanupand on stream cancellation. -
Verify on Streamable HTTP that the SDK:
- keeps an
events/streamresponse open as SSE; - does not apply a request timeout or a concurrent-request cap to it;
- checks
Mcp-Nameagainstparams.nameforevents/*, with-32020on a mismatch.
If any of these is missing, it is filed upstream and linked here, and not patched around in this server.
- keeps an
Tests
These are protocol-level tests in src/everything/__tests__/events.test.ts, driven through the in-process harness with raw custom requests, since the client SDK has no Events helpers yet.
events/listshape.- Poll bootstrap with a
nullcursor, replay,maxEvents/hasMore,maxAgeMsand retention-window truncation. eventIdstability.- The emit-only
nullcursor. - A push stream's active → event → heartbeat ordering and
subscriptionIdstamping. - Cancellation releasing timers.
- Every error code.
- A 2025-era client getting
-32601.
Fake timers keep the tests fast and free of retries. Every touched file must clear the per-file 90 % coverage gate.
Docs and release
- README: a new Events section listing the event types, delivery modes and the
trigger-eventtool. docs/features.md,docs/structure.mdanddocs/architecture.md.- A minor changeset, since this adds a capability and a tool.
- Client evidence: the Inspector CLI and an LLM client cannot drive
events/*today. The PR will record what was exercised and how: the conformance Events suite if it can be pointed at a local build, otherwise a scripted raw JSON-RPC session over stdio and over Streamable HTTP.
Follow-ups (not this issue)
- Migrate onto the SDK's
ext/eventsonce typescript-sdk#3209 ships, and switchlistChangedon after feat: add Universal Commerce Protocol (UCP) MCP server #3203. - Webhook delivery, gated on the everything server gaining an authenticated principal.
Open question
The alternative to building this now is to wait for typescript-sdk#3209 and write only the event types against its API. The recommendation is to build now: the conformance suite needs a target, the implementation is small and follows the precedent of server/tasks.ts, and the event types and tests carry over unchanged when we migrate.
Activity