Skip to content

everything: serve the Events extension (io.modelcontextprotocol/events) on 2026-07-28: poll and push delivery #5651

Done

Description

@cliffhall

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

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.

  1. 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: true a real trigger.
    • The type exercises maxEvents / hasMore, maxAgeMs, nextPollMs and a stable eventId (tick-<k>).
    • Its inputSchema has a filter (for example everyNth) and a transform (for example includeIso). Its payloadSchema is minimal.
  2. custom-event: an emit-only type, delivered by ["push", "poll"].
    • The cursor is always null (absent), and truncated is always false.
    • 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.

Methods

  • events/list: both descriptors, with the delivery, inputSchema and payloadSchema fields, and nextCursor pagination support.
  • events/poll: params validated with Zod. A null cursor 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/active with the granted heartbeatMs: the client's suggestion, clamped, defaulting to 30 s.
    • It then sends notifications/events/event as events occur, and notifications/events/heartbeat carrying 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/active with truncated: true.
    • On cancellation (notifications/cancelled on stdio, or abort on HTTP) the server clears timers and listeners. It sends a final StreamEventsResult only 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.
  • 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 the inputSchema.
    • Unsupported (-32026, data: {feature: "deliveryMode", value}): a mode the type does not offer.
    • -32601: events/subscribe and events/unsubscribe, since webhook is not offered.

Wiring

  • Add a new module server/events.ts with a purpose header, modelled on server/tasks.ts. It exports EVENTS_EXTENSION and registerEventsExtension(server, context).

  • In server/index.ts, the extension is advertised in extensions and registered only when era === "modern", next to Tasks.

  • trigger-event is registered in registerModernTools.

  • Timers and bus listeners are released through context.onCleanup and on stream cancellation.

  • Verify on Streamable HTTP that the SDK:

    • keeps an events/stream response open as SSE;
    • does not apply a request timeout or a concurrent-request cap to it;
    • checks Mcp-Name against params.name for events/*, with -32020 on a mismatch.

    If any of these is missing, it is filed upstream and linked here, and not patched around in this server.

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/list shape.
  • Poll bootstrap with a null cursor, replay, maxEvents / hasMore, maxAgeMs and retention-window truncation.
  • eventId stability.
  • The emit-only null cursor.
  • A push stream's active → event → heartbeat ordering and subscriptionId stamping.
  • 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-event tool.
  • docs/features.md, docs/structure.md and docs/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)

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

  1. added this to the v2.7.0 milestone on Nov 24, 2026
  2. added
    enhancement
    server-everything
    on Nov 24, 2026
  3. modified the milestones: v2.7.0, v2.6.0 on Nov 24, 2026
  4. self-assigned this
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementserver-everythingv2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions