Skip to content

feat(everything): serve the Events extension (poll and push) on 2026-07-28 - #5652

Open
cliffhall wants to merge 3 commits into
v2/mainfrom
v2/feat/5651-everything-events
Open

cliffhall wants to merge 3 commits into
v2/mainfrom
v2/feat/5651-everything-events

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #5651

Description

The everything server now serves the Events extension (io.modelcontextprotocol/events, SEP-3415, Beta) on protocol version 2026-07-28, with poll and push delivery. The SDK has no server-side Events support yet (modelcontextprotocol/typescript-sdk#3209 is a draft), so server/events.ts builds it on the SDK's custom request handlers, the same way server/tasks.ts serves Tasks.

  • Capability. extensions["io.modelcontextprotocol/events"]: {} in server/discover, on 2026-07-28 only. There is no listChanged, because the event types never change.
  • events/list. Two event types, each with delivery, inputSchema and payloadSchema:
    • clock-tick (poll, push) is replayable. Tick k happens at k × 5 s since the Unix epoch, so every occurrence is computed from the clock and nothing is stored. That matters because on HTTP every 2026-07-28 request gets a fresh server instance. The cursor is clock-tick:<k>, and the last 100 ticks can be replayed. Its arguments are everyNth, a filter, and label, a transform copied into the payload.
    • custom-event (push) is emit-only, and its cursor is always null. The new trigger-event tool raises it through a process-wide bus, so a stream opened through one connection or request sees an event raised through another. Its argument is minSeverity, a filter.
  • events/poll.
    • A null or absent cursor means "start from now".
    • A cursor replays the ticks after it: at most maxEvents at a time (default 50, at most 100), with hasMore and nextPollMs.
    • Replay starts no earlier than maxAgeMs or the retention window allows, and truncated: true says when either skipped events.
  • events/stream.
    • It opens with notifications/events/active, which carries the starting cursor, truncated and the granted heartbeatMs (the client's suggestion clamped to 1–60 s, 30 s by default).
    • The replayed backlog and each new occurrence follow as notifications/events/event.
    • notifications/events/heartbeat carries the checked-up-to cursor whenever the interval passes without another message.
    • Every notification is tagged with the request id in _meta["io.modelcontextprotocol/subscriptionId"].
    • Cancellation (notifications/cancelled on stdio, an aborted response on HTTP) releases the stream's timers and listener.
    • trigger-event can also send a recoverable notifications/events/error, or end the subscriptions with notifications/events/terminated (-32024), after which the request answers with an empty result.
    • The process holds at most 100 streams; past that, a new one gets -32025.
  • Errors.
    • -32023 NotFound (data.kind: "event") for an unknown type.
    • -32026 Unsupported (data: {feature: "deliveryMode", value}) for a delivery mode the type does not offer.
    • -32602 for arguments that do not match the inputSchema, or for a cursor the server never minted.
    • An invalid subscription gets its error before any stream opens.
  • Not served.
    • Webhook delivery: events/subscribe and events/unsubscribe answer -32601. The spec requires an authenticated principal for webhooks, and this server has none.
    • Every events/* method on 2025-era connections, which also answer -32601.

Server Details

  • Server: everything
  • Changes to:
    • The new server/events.ts.
    • The new 2026-07-28-only tool trigger-event (tools/trigger-event.ts).
    • The capabilities in server/index.ts.
    • The raw test harness, which now records notifications and can send notifications/cancelled.
    • The README, docs/features.md (a new Events section), how-it-works.md, structure.md, startup.md and instructions.md.

Motivation and Context

Events reached Beta. The everything server is the protocol showcase, so clients need a reference server to develop against. The Inspector is adding Events support (modelcontextprotocol/inspector#3026), and the conformance repo has an Events server suite in review (modelcontextprotocol/conformance#521). The plan and its scope decisions are on #5651.

How Has This Been Tested?

Automated.

  • src/everything/__tests__/events.test.ts has 29 protocol-level tests. They drive the server with raw 2026-07-28 JSON-RPC over the in-memory serveStdio harness on a faked clock, with no retries. They cover:
    • discovery, and -32601 for a 2025-era client and for the webhook methods;
    • poll bootstrap, replay, eventId stability, maxEvents/hasMore, everyNth/label, retention truncation and maxAgeMs;
    • every error code;
    • push ordering, heartbeats, the heartbeat cursor advancing over filtered ticks, clamping, cancellation sending no response, and invalid subscriptions opening no stream;
    • custom-event filtering, reaching streams on another connection, error and terminate, and cleanup on disconnect;
    • the 100-stream limit;
    • a failed send ending a stream.
  • events.ts is at 100 % branches and functions.
  • npm run local:gate passed (exit 0).

Inspector CLI 2.16.0 (stdio, node src/everything/dist/index.js stdio):

Era Request Result
modern tools/list (Events-related names) ["simulate-research-query","trigger-event"]
legacy tools/list (same filter) ["toggle-subscriber-updates"]: no trigger-event
modern tools/call trigger-event message=cli-smoke Sent custom-event (info) to 0 open custom-event streams, answered by mcp-servers/everything with 2026-07-28 serverInfo
legacy tools/call trigger-event tool_not_found (exit 5)
modern --method events/list Unsupported method: events/list: the CLI has no events/* methods yet

The Inspector's Events client (modelcontextprotocol/inspector#3028–#3030) ships this week. Until then, the Events methods were exercised with scripted raw JSON-RPC sessions against the built server.

stdio, raw 2026-07-28 JSON-RPC. Trimmed:

events/poll {name: clock-tick, cursor: null}
  → {events: [], cursor: "clock-tick:359099146", truncated: false, hasMore: false, nextPollMs: 1000, resultType: "complete"}
events/poll {cursor: "clock-tick:359099143", maxEvents: 2}
  → events tick-359099144, tick-359099145; cursor "clock-tick:359099145", hasMore: true, nextPollMs: 0
events/stream {name: clock-tick, cursor: "clock-tick:359099144", heartbeatMs: 2000, arguments: {label: "x"}}   (id 5)
  ← notifications/events/active {cursor: "clock-tick:359099144", truncated: false, heartbeatMs: 2000, _meta.subscriptionId: 5}
  ← notifications/events/event tick-359099145, tick-359099146 (replay), then tick-359099147 at :55.000, each with data.label "x"
  ← notifications/events/heartbeat {cursor: "clock-tick:359099147"} every 2 s while idle
events/stream {name: custom-event, heartbeatMs: 1000}   (id 6)
  ← notifications/events/active {cursor: null, truncated: false, heartbeatMs: 1000}
tools/call trigger-event {message: "hi"} → "Sent custom-event (info) to 1 open custom-event stream"
  ← notifications/events/event {eventId: "custom-f78896f4-…", data: {message: "hi", severity: "info"}, cursor: null, _meta.subscriptionId: 6}
notifications/cancelled {requestId: 5} → stream 5 falls silent; no response sent
tools/call trigger-event {kind: terminate, message: "bye"}
  ← notifications/events/terminated {error: {code: -32024, message: "Forbidden", data: {reason: "bye"}}, _meta.subscriptionId: 6}
  ← response to id 6: {_meta: {subscriptionId: 6, …}, resultType: "complete"}
events/poll {name: custom-event}   → -32026 {feature: "deliveryMode", value: "poll"}
events/subscribe                   → -32601 Method not found
events/poll {name: "nope"}         → -32023 {kind: "event"}
events/poll {arguments: {bogus: 1}} → -32602 Invalid arguments for event type clock-tick: Unrecognized key: "bogus"

Streamable HTTP, with curl against PORT=3917 node dist/index.js streamableHttp:

  • events/stream returned an SSE response: active, then heartbeat every 2 s, then event on the tick.
  • A custom-event stream opened in one HTTP request received terminated, followed by its final result frame, after trigger-event {kind: terminate} ran in a separate request.
  • Aborting a stream's HTTP request released it. trigger-event reported 1 open custom-event stream while the stream was open, and 0 after the abort.

LLM client: Claude Code 2.1.331, claude -p --mcp-config <local build> --strict-mcp-config. The prompt was: "Use the everything server's trigger-event tool to raise a custom event with the message 'llm-smoke' and severity 'warning'. Then reply with exactly the text the tool returned, and … whether the server's tool list includes simulate-research-query." It replied Sent custom-event (warning) to 0 open custom-event streams / yes. The yes means the client negotiated 2026-07-28, which Claude Code gives no way to change, so no 2025-era LLM run was possible. The tool does not exist on 2025-era connections, as the Inspector legacy run above shows. No LLM client can subscribe to events yet.

Breaking Changes

None. One capability and one tool are added on 2026-07-28. 2025-era connections are unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation: the Events overview and the Beta specification.
  • My changes follow MCP security best practices:
    • Payloads are minimal.
    • No outbound requests are made, because webhook is not offered.
    • Streams are capped at 100 per process, and maxEvents, heartbeatMs and replay are bounded.
    • Subscription arguments are validated strictly.
  • I have updated the server's README accordingly.
  • I have added a changeset (npm run changeset) if this changes what a TypeScript server publishes: a minor changeset, everything-events-extension.md.
  • I have tested this with an LLM client. This covers trigger-event only: no LLM client can subscribe to events yet.
  • My code follows the repository's style guidelines.
  • New and existing tests pass locally.
  • I have added appropriate error handling.
  • I have documented all environment variables and configuration options (not applicable: none were added).

Additional context

  • Mcp-Name is not checked for events/* over Streamable HTTP. The spec says a server refuses an events/poll or events/stream whose Mcp-Name header does not match params.name (400, -32020). The SDK validates Mcp-Name from a fixed table, which today covers only tools/call, prompts/get, resources/read and tasks/*, and the draft Events PR (typescript-sdk#3209) does not add the events/* rows. A mismatched header is therefore accepted. This is an SDK gap, not something to patch around in this server. docs/features.md says so.
  • List changes. listChanged stays off. The event types are fixed, and the SDK's subscriptions/listen filter drops the eventsListChanged field until typescript-sdk#3203 lands.
  • Follow-ups, deliberately not in this PR:
    • Move onto the SDK's ext/events once typescript-sdk#3209 ships.
    • Webhook delivery, if the server ever gains an authenticated principal.

🤖 Generated with Claude Code

cliffhall and others added 2 commits November 23, 2026 23:54
Serve io.modelcontextprotocol/events (SEP-3415) with poll and push
delivery: events/list, events/poll and events/stream. A replayable
clock-tick type (poll and push) is computed from the clock, and an
emit-only custom-event (push) is raised by the new trigger-event tool
through a process-wide bus. Webhook delivery is not offered: it needs
an authenticated principal this server does not have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d277263

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/server-everything Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cliffhall
cliffhall requested a balanced review from Copilot November 24, 2026 05:42
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

everything: MCP interface diff

Base: ec089ce10014 (Merge pull request #5638 from modelcontextprotocol/v2/fix/5634-memory-heartbeat-test-race)
Head: the build in this checkout, at 2ea42b58ea42 (Merge d277263 into ec089ce)

Diffed because it was named (--server).

⚠️ Interface changes detected in 3 part(s) of the interface. Review them below to confirm they are intended.

Tools Prompts Resources Resource templates
Base 22 4 8 5
Head 23 4 8 5

initialize

--- base/initialize.json
+++ target/initialize.json

+ capabilities.extensions.io.modelcontextprotocol/events: {}
- instructions: "# Everything Server – Server Instructions\n\nAudience: These instructions are written for an LLM or au..."
+ instructions: "# Everything Server – Server Instructions\n\nAudience: These instructions are written for an LLM or au..."

instructions

--- base/instructions
+++ target/instructions
- # Everything Server – Server Instructions

Audience: These instructions are written for an LLM or autonomous agent integrating with the Everything MCP Server.
Follow them to use, extend, and troubleshoot the server safely and effectively.

## Protocol Versions

The server serves two protocol eras. A client on protocol version 2026-07-28 connects with `server/discover` and sends its capabilities with each request; a 2025-era client connects with `initialize`. Some tools exist on one era only, so trust your `tools/list`:

- 2026-07-28 only: `simulate-research-query`, `trigger-sampling-request-async` and `trigger-elicitation-request-async`, which run as tasks on the `io.modelcontextprotocol/tasks` extension and need a client that declares it; `trigger-sampling-request-async` also needs `sampling`, and `trigger-elicitation-request-async` form-mode `elicitation`. A call without them fails with `-32021`
- 2025-era only (deprecated): `toggle-simulated-logging` and `toggle-subscriber-updates`

## Cross-Feature Relationships

- If `get-roots-list` is in your tool list, use it to see client workspace roots before file operations
- `gzip-file-as-resource` creates resources you can read later: for the current session on a 2025-era connection, or for ten minutes at the returned URI on 2026-07-28
- Use `trigger-log-messages` to see which log levels reach you; on 2026-07-28 the level is set per request in `_meta`
- Use `trigger-resource-update` and `trigger-list-changed` to see change notifications; on 2026-07-28 they arrive only on a `subscriptions/listen` stream that asked for them

## Constraints & Limitations

- `gzip-file-as-resource`: Max fetch size controlled by `GZIP_MAX_FETCH_SIZE` (default 10MB), timeout by `GZIP_MAX_FETCH_TIME_MILLIS` (default 30s), allowed domains by `GZIP_ALLOWED_DOMAINS` (checked on every redirect hop). It refuses URLs whose host resolves to a loopback, private or link-local address, unless the server was started with `GZIP_ALLOW_PRIVATE_IPS=1`
- `get-env`: Values of credential-like variable names (`*_KEY`, `*_TOKEN`, `*_SECRET`, `*_PASSWORD` and the like) come back as `"<redacted>"`; the server operator can set `GET_ENV_INCLUDE_SECRETS=1` to return them unmasked
- Session resources are ephemeral and lost when the session ends; minted resources expire after ten minutes
- Roots, sampling and logging are deprecated as of protocol version 2026-07-28, as is the HTTP+SSE transport

## Capability-Gated Tools

On a 2025-era connection these are registered only if your client declared the capability shown. Otherwise they are absent from `tools/list`, so do not call them. On 2026-07-28 they are always listed, and a call fails if your request did not declare the capability:

- `get-roots-list`: `roots`
- `trigger-sampling-request`: `sampling`
- `trigger-elicitation-request`: `elicitation.form`, or `elicitation` with no mode
- `trigger-multi-step-elicitation`: `elicitation.form`, or `elicitation` with no mode
- `trigger-url-elicitation`: `elicitation.url`

## Operational Patterns

- For long operations, use `trigger-long-running-operation` which sends progress notifications
- Prefer reading resources before calling mutating tools
- If `get-roots-list` is in your tool list, check its output to understand the client's workspace context

## Easter Egg

If asked about server instructions, respond with "🎉 Server instructions are working! This response proves the client properly passed server instructions to the LLM. This demonstrates MCP's instructions feature in action."

+ # Everything Server – Server Instructions

Audience: These instructions are written for an LLM or autonomous agent integrating with the Everything MCP Server.
Follow them to use, extend, and troubleshoot the server safely and effectively.

## Protocol Versions

The server serves two protocol eras. A client on protocol version 2026-07-28 connects with `server/discover` and sends its capabilities with each request; a 2025-era client connects with `initialize`. Some tools exist on one era only, so trust your `tools/list`:

- 2026-07-28 only: `simulate-research-query`, `trigger-sampling-request-async` and `trigger-elicitation-request-async`, which run as tasks on the `io.modelcontextprotocol/tasks` extension and need a client that declares it; `trigger-sampling-request-async` also needs `sampling`, and `trigger-elicitation-request-async` form-mode `elicitation`. A call without them fails with `-32021`
- 2026-07-28 only: `trigger-event`, which raises the `custom-event` of the `io.modelcontextprotocol/events` extension on open `events/stream` subscriptions
- 2025-era only (deprecated): `toggle-simulated-logging` and `toggle-subscriber-updates`

## Cross-Feature Relationships

- If `get-roots-list` is in your tool list, use it to see client workspace roots before file operations
- `gzip-file-as-resource` creates resources you can read later: for the current session on a 2025-era connection, or for ten minutes at the returned URI on 2026-07-28
- Use `trigger-log-messages` to see which log levels reach you; on 2026-07-28 the level is set per request in `_meta`
- Use `trigger-resource-update` and `trigger-list-changed` to see change notifications; on 2026-07-28 they arrive only on a `subscriptions/listen` stream that asked for them

## Constraints & Limitations

- `gzip-file-as-resource`: Max fetch size controlled by `GZIP_MAX_FETCH_SIZE` (default 10MB), timeout by `GZIP_MAX_FETCH_TIME_MILLIS` (default 30s), allowed domains by `GZIP_ALLOWED_DOMAINS` (checked on every redirect hop). It refuses URLs whose host resolves to a loopback, private or link-local address, unless the server was started with `GZIP_ALLOW_PRIVATE_IPS=1`
- `get-env`: Values of credential-like variable names (`*_KEY`, `*_TOKEN`, `*_SECRET`, `*_PASSWORD` and the like) come back as `"<redacted>"`; the server operator can set `GET_ENV_INCLUDE_SECRETS=1` to return them unmasked
- Session resources are ephemeral and lost when the session ends; minted resources expire after ten minutes
- Roots, sampling and logging are deprecated as of protocol version 2026-07-28, as is the HTTP+SSE transport

## Capability-Gated Tools

On a 2025-era connection these are registered only if your client declared the capability shown. Otherwise they are absent from `tools/list`, so do not call them. On 2026-07-28 they are always listed, and a call fails if your request did not declare the capability:

- `get-roots-list`: `roots`
- `trigger-sampling-request`: `sampling`
- `trigger-elicitation-request`: `elicitation.form`, or `elicitation` with no mode
- `trigger-multi-step-elicitation`: `elicitation.form`, or `elicitation` with no mode
- `trigger-url-elicitation`: `elicitation.url`

## Operational Patterns

- For long operations, use `trigger-long-running-operation` which sends progress notifications
- Prefer reading resources before calling mutating tools
- If `get-roots-list` is in your tool list, check its output to understand the client's workspace context

## Easter Egg

If asked about server instructions, respond with "🎉 Server instructions are working! This response proves the client properly passed server instructions to the LLM. This demonstrates MCP's instructions feature in action."

tools

--- base/tools.json
+++ target/tools.json

+ tools[trigger-event]: {"annotations":{"destructiveHint":false,"openWorldHint":false},"description":"Raises the Events extension's custom-event on every open events/stream subscribed to it. With kind error it sends a recove...

Updated by this run for d2772632794324761df27a7583e937ae6d77263e.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Event streaming assigns inconsistent occurrence identities across subscriptions, can send queued notifications after closure, and can exceed retention limits during timer catch-up.

3 open issues
What changed in this PR

Adds the Events extension to the everything reference server for 2026-07-28 clients, demonstrating poll and push delivery while leaving 2025-era behavior unchanged.

Changes:

  • Adds replayable clock-tick events and push-only custom-event subscriptions.
  • Introduces trigger-event, stream lifecycle handling, and protocol-level tests.
  • Documents the extension, its limitations, and a minor package release.
File Description
src/​everything/​tools/​trigger-event.ts Adds the tool for events, recoverable errors, and termination.
src/​everything/​tools/​index.ts Registers trigger-event for modern clients.
src/​everything/​server/​index.ts Advertises and registers the Events extension.
src/​everything/​server/​events.ts Implements discovery, polling, streaming, and the event bus.
src/​everything/​README.md Includes Events in the modern feature overview.
src/​everything/​docs/​structure.md Documents the new modules.
src/​everything/​docs/​startup.md Updates capability and registration descriptions.
src/​everything/​docs/​instructions.md Lists the modern-only event tool.
src/​everything/​docs/​how-it-works.md Explains event delivery and stream lifecycle.
src/​everything/​docs/​features.md Documents delivery modes, arguments, errors, and limitations.
src/​everything/​__tests__/​stdio.test.ts Updates expected discovery capabilities.
src/​everything/​__tests__/​registrations.test.ts Updates expected modern tool registrations.
src/​everything/​__tests__/​harness.ts Adds notification recording and cancellation support.
src/​everything/​__tests__/​events.test.ts Tests Events methods and stream behavior.
.changeset/​everything-events-extension.md Records the minor release addition.

Review effort: Balanced

Comment thread src/everything/server/events.ts Resolved
Comment thread src/everything/server/events.ts Resolved
Comment thread src/everything/server/events.ts Resolved
…ncel, bound catch-up replay

Copilot round 1 on #5652:
- Mint a custom-event's eventId and timestamp once on the bus, so every
  matching subscription receives the same occurrence identity.
- Drop notifications still queued when a stream ends abruptly
  (cancellation, a failed send, cleanup); a termination still drains.
- Re-apply the retention window when a late tick timer catches up, and
  report the gap with a fresh active carrying truncated: true.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1: three findings, all defects in what this PR adds, all fixed in d277263 with tests. The gate passed (exit 0) before the push.

  • Queued notifications after an abrupt end. Cancellation, a failed send or cleanup now drops what is still queued. A server-initiated termination still drains, so terminated precedes the final result.
  • Retention on catch-up. A late tick timer (process suspension, clock jump) now replays at most the 100 retained ticks, and announces the gap with a fresh active carrying truncated: true.
  • Shared occurrence identity. A custom-event gets its eventId and timestamp once on the bus, so every matching subscription receives the same identity.

Round 2 requested.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The Events extension change has no active review issues requiring resolution.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2: clean ("No open issues"), and the three round-1 findings are marked resolved. The review loop ends here on its first clean round.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants