Skip to content
Source
Sign inSign up
TanStack/ai

ai-mcp: conform to the final MCP Events spec (SEP-3415) #2219

Closedtombeckenham opened this issue 0 comments
tombeckenhamcommented

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 an Mcp-Param-{Name} header for each annotated property that has a value in params.arguments". src/transport.ts sets only Mcp-Name for events/* requests. When an event type annotates an argument with x-mcp-header, a conforming server answers subscribe, refresh and unsubscribe with 400 HeaderMismatch. The tools path already sends these headers.
  • Event types with invalid x-mcp-header annotations are not excluded from events/list. Line 788: "A client MUST exclude an event type whose annotations violate them from the result of events/list".
  • A gap envelope without a cursor returns 400. Line 694: "An absent cursor field MUST be treated identically to an explicit cursor: null ... a receiver MUST NOT fail because it is missing". src/events/wire.ts:217 returns gap requires cursor. The server retries, then stops, and the app never gets onGap.
  • Mcp-Name is not set for a custom Transport instance. 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:188 does Number(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.
  • _meta on an event occurrence is dropped. Line 234. parseEventOccurrence and MCPEventOccurrence have no field for it.
  • Error -32020 (HeaderMismatch) is not mapped. src/events/errors-map.ts covers -32023 to -32027. Line 789 says the client SHOULD call events/list again 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:

  • truncated is required on the subscribe result (wire.ts:128-130).
  • inputSchema and payloadSchema are required, and one bad descriptor or unknown delivery mode fails the whole list (wire.ts:29-32, 62-65).
  • deliveryStatus fields other than lastError reject null (wire.ts:93-97).

Docs and examples

  • docs/tools/mcp-events.md:19 and src/events/capability.ts:6 still cite draft 2ec39b9 and say the wire format can change. Point them at the final text.
  • examples/react/mcp-events/src/lib/desk.ts:147-150 sets webhook-id to the eventId. Line 640 says the sender MUST NOT do that. docs/tutorials/mcp-events.md:69 tells readers to copy this file.
  • The onEvent examples at docs/tools/mcp-events.md:157 and :180 forward only event, so they drop messageId, 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.

  1. tombeckenham added labelsbug

  2. tombeckenham assignedtombeckenham

  3. tombeckenham linked this to #2221

  4. AlemTuzlak closed this

Sign in to join this conversation.