Repository navigation
feat(mcp): follow the MCP Events beta for push delivery - #65271
Conversation
There was a problem hiding this comment.
The change looks sound. I ran the pull request's MCP test file against the base code: the new Streamable HTTP events test fails there because the server rejects the stream for the missing Mcp-Param-Job header, and it passes with this change. I also checked the installed patched SDK: the ESM shortened names (D/k) and the CJS require_src exports both resolve to buildMcpParamHeaders and scanXMcpHeaderDeclarations. With the pull request, test/mcp.test.ts and test/mcp-events.test.ts pass except one subprocess test ("terminates MCP descendants after the wrapper exits successfully") that also fails on the base. typecheck:tsc is clean.
The stream retry follows the same relist-and-retry-once pattern as callTool. Event types with invalid x-mcp-header annotations are dropped with a warning, as the spec requires.
Public API is unchanged: the only new exports come from the project's private SDK patch.
fa2dd51 to
24715dc
Compare
7514332 to
b6e2b16
Compare
117d7f9 to
8f635ad
Compare
…t heartbeat grant and check timestamp format only
…play to an hour and skip replayed duplicates
…nly store the position
8f635ad to
9f38e57
Compare
Issue for this PR
Closes #
Type of change
What does this PR do?
Brings the experimental MCP Events client (push delivery) up to the beta of SEP-3415. Poll and webhook are still out of scope.
events/streamsendsMcp-Param-*headers for subscription arguments marked withx-mcp-header, as tool calls do. OnHeaderMismatch(-32020) it relists and retries once. The SDK keeps its header scan and encoding private, so a small port lives inclient.ts; it matches the SDK's output on the schemas and values I compared.events/listskips event types that are malformed or whose schemas can't be checked.events.checkrefuses an unknown event type, one without push, or arguments that don't matchinputSchema;streamruns it first. Events whose data doesn't matchpayloadSchemaare dropped with a warning.listChanged, the client openssubscriptions/listenwitheventsListChangedand relists onnotifications/events/list_changed.maxAgeMs), and the last 100 event IDs are remembered per subscription so a replayed event isn't delivered twice.Mcp.follow: following an event type now lives in the MCP service: it reopens broken streams, waits for a disconnected server, dedupes, and yields each event with the position after it. Automation watches only store that position next to the run's result, andMcp.subscribeis built on it too. A watch now waits for its server to come back instead of pausing after three failed reopens.mcp_eventsflag: Events are always on. Nothing happens unless a server offers them and something subscribes, andautomations: falsestill turns event watches off. A leftoverexperimental.mcp_eventsis ignored like any unknown key.How did you verify your code works?
Moved the event fixtures to the 2026-07-28 handshake and extended the existing tests rather than adding new ones. MCP, MCP events, automation and tool suites pass, plus
bun run check.Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist