Repository navigation
Track client-declared MCP Events extension capability - #285
Conversation
SEP-3415 (io.modelcontextprotocol/events) is Final and in beta. Add it to the extension allow-list so $mcp_initialize events record $mcp_client_supports_events, matching the existing tasks/apps/oauth extension wiring. Both declaration paths are covered: initialize capabilities.extensions and per-request _meta client capabilities, which eventProperties already routes through clientCapabilityAnalytics.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Picked masnwilliams to review: recent commits in |
masnwilliams
left a comment
There was a problem hiding this comment.
LGTM. This follows the existing extension pattern exactly, and the real change is the new map entry.
Two optional suggestions. Neither blocks this PR, and both apply equally to the existing extensions:
-
Derive the per-extension wiring from
CLIENT_EXTENSION_PROPERTIES. Adding an extension currently takes four hand-synced edits: the map, theMcpClientCapabilityAnalyticstype,SENT_PROPERTIES, and thefalsedefault.tsccatches a missing type field or default. A missing map entry orSENT_PROPERTIESentry fails silently. Deriving the type (Record<ClientExtensionProperty, boolean>), spreadingObject.values(CLIENT_EXTENSION_PROPERTIES)intoSENT_PROPERTIES, and building the booleans withObject.fromEntrieswould make the next extension a one-line change. Tasks keeps its extra|| isRecord(capabilities.tasks). I prototyped it locally:tscis clean, all tests pass, and it's net −10 lines. -
Assert that the property is actually sent. Removing
MCP_CLIENT_SUPPORTS_EVENTS_PROPERTYfromSENT_PROPERTIESstill passes the suite, because the new assertions only check whatclientCapabilityAnalyticsreturns. Adding the events property to the_metaend-to-end test'stoMatchObject(next to the apps property) would cover the path throughbeforeSend.
The analytics type, the false defaults, and SENT_PROPERTIES now come from CLIENT_EXTENSION_PROPERTIES, so adding an extension is a one-entry change and a missing allow-list entry can no longer drop a property silently. The legacy core tasks capability still counts as Tasks support. The SDK integration test now declares the Events extension in request _meta and asserts the property survives the SENT_PROPERTIES filter.
Summary
SEP-3415 (
io.modelcontextprotocol/events) is now Final and the Events extension is in beta. This adds it to the explicit client-extension allow-list so$mcp_initializeevents record a bounded$mcp_client_supports_eventsboolean, mirroring the existing Tasks/Apps/OAuth-client-credentials/enterprise-auth wiring.MCP_EVENTS_EXTENSIONconstant inclient-capabilities.ts$mcp_client_supports_eventsproperty:falseunless the client declares the extension as an objectfalsedefaults, and the extension entries inSENT_PROPERTIESnow derive fromCLIENT_EXTENSION_PROPERTIES, so a future extension is a one-entry change and a missing allow-list entry can no longer drop a property silently. The legacy corecapabilities.tasksdeclaration still counts as Tasks supportinitializecapabilities.extensions, and per-request_metaclient capabilities, whicheventPropertiesalready routes throughclientCapabilityAnalyticsOnly the boolean is captured; extension settings and unknown extension identifiers still never reach analytics.
Testing
bun test src/lib/mcp/analytics.test.ts— 58 pass (existing shape tests extended for declared, malformed, and absent Events declarations)_metaand asserts the property survives theSENT_PROPERTIESfilter (verified it fails if Events is dropped from the allow-list)bun test: 1355 passbunx tsc --noEmitcleanprettier --checkclean on changed files