ai-mcp: conform to the final MCP Events spec (SEP-3415) #2219
TanStack AI version#
@tanstack/ai-mcp 1.3.1 (main at f25954a28)
Framework/Library version#
@modelcontextprotocol/client and @modelcontextprotocol/server 2.1.0. Neither ships Events support, so there is nothing to adopt from the SDK.
Describe the bug and the steps to reproduce it#
SEP-3415 (MCP Events) is now Final. It merged upstream on 2026-11-19: https://github.com/modelcontextprotocol/modelcontextprotocol/pull/3415
@tanstack/ai-mcp was built against draft revision 2ec39b9. An audit of packages/ai-mcp/src/events/ against the final text (seps/3415-events-extension.md) found the gaps below. Line numbers are lines of that file.
The webhook-id / eventId mismatch is not in this list. #2150 fixes it.
MUST-level
-
Mcp-Param-*headers are not sent. Line 787: "the client MUST set anMcp-Param-{Name}header for each annotated property that has a value inparams.arguments".src/transport.tssets onlyMcp-Nameforevents/*requests. When an event type annotates an argument withx-mcp-header, a conforming server answers subscribe, refresh and unsubscribe with 400HeaderMismatch. The tools path already sends these headers. - Event types with invalid
x-mcp-headerannotations are not excluded fromevents/list. Line 788: "A client MUST exclude an event type whose annotations violate them from the result ofevents/list". - A gap envelope without a cursor returns 400. Line 694: "An absent
cursorfield MUST be treated identically to an explicitcursor: null... a receiver MUST NOT fail because it is missing".src/events/wire.ts:217returnsgap requires cursor. The server retries, then stops, and the app never getsonGap. -
Mcp-Nameis not set for a customTransportinstance. Line 754. The header comes from a fetch wrapper that only the http and sse config paths use.
Edge cases
- The timestamp is turned into a number before verification. Line 641 signs
webhook-id + "." + webhook-timestamp + "."plus the body.src/events/webhook.ts:188doesNumber(webhookTimestamp), and the signed string is built from that number. A header value with a leading zero fails verification. Sign with the raw header string. -
_metaon an event occurrence is dropped. Line 234.parseEventOccurrenceandMCPEventOccurrencehave no field for it. - Error
-32020(HeaderMismatch) is not mapped.src/events/errors-map.tscovers-32023to-32027. Line 789 says the client SHOULD callevents/listagain and retry.
SHOULD-level, now left to the app
- Dedupe on
webhook-id(line 535). The docs tell the app to do it. Decide if the receiver gets an optional store hook. - Refresh before
refreshBefore(line 465).refresh()exists. There is no scheduler. -
notifications/events/list_changed(line 194). There is no handler.
Check the strict parsing
The final text has no formal schema. Confirm that these checks do not reject a conforming server:
-
truncatedis required on the subscribe result (wire.ts:128-130). -
inputSchemaandpayloadSchemaare required, and one bad descriptor or unknown delivery mode fails the whole list (wire.ts:29-32,62-65). -
deliveryStatusfields other thanlastErrorrejectnull(wire.ts:93-97).
Docs and examples
-
docs/tools/mcp-events.md:19andsrc/events/capability.ts:6still cite draft2ec39b9and say the wire format can change. Point them at the final text. -
examples/react/mcp-events/src/lib/desk.ts:147-150setswebhook-idto theeventId. Line 640 says the sender MUST NOT do that.docs/tutorials/mcp-events.md:69tells readers to copy this file. - The
onEventexamples atdocs/tools/mcp-events.md:157and:180forward onlyevent, so they dropmessageId, the dedupe key.
Scope, not a bug
We implement webhook delivery only. Poll (events/poll) and push (events/stream) are absent, and there is no server side. Line 179 says no mode is mandatory, so this conforms. An event type that lists only poll or push cannot be used. Track those modes in a separate issue if we want them.
Your Minimal, Reproducible Example#
No sandbox. Each item cites the spec line and the code line. For the first item: subscribe to an event type whose inputSchema has a property with x-mcp-header, and check that the request has no Mcp-Param-* header.
tombeckenham added labelsbug
tombeckenham assignedtombeckenham
tombeckenham linked this to #2221
AlemTuzlak closed this
Sign in to join this conversation.