Repository navigation
feat: per-message webhook-id for SEP-3415 clients, eventId for legacy ones - #114
Merged
Merged
Conversation
… ones Each subscription now records which webhook-id its deliveries carry, chosen at subscribe time: - event: the eventId, as before. Clients that don't declare the events extension get it, as do declaring clients on a legacy list (TanStack AI, the Vercel AI SDK and OpenClaw by their default names), which reject a webhook-id that isn't the eventId. - message: msg_ plus 24 random characters, as SEP-3415 requires, for a client that declares io.modelcontextprotocol/events in the request's _meta. BRIDGE_WEBHOOK_ID (subscriptions.webhookId) sets auto (default), event or message. The mode is stored as wid in the connection description, where the transformation reads it; replays publish with the same rule. Event Gateway runs the transformation once per event, so retries keep a generated id (verified). Dedupe moves from headers.webhook-id to body.eventId, so a service's resend is still dropped when the id is random. Refs #113 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ll and changelog Refs #113 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, event-id and per-message BRIDGE_WEBHOOK_ID read as if it held an id. The setting picks what each delivery's webhook-id header holds, so it's now BRIDGE_WEBHOOK_ID_FORMAT (subscriptions.webhookIdFormat), with auto (the default), event-id and per-message. Refs #113 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The description size check counts wid only for a per-message subscription, so an event-id subscription keeps the room it had. - The subscribe log says when the legacy client list chose event-id, and names both places the format setting can come from. - BRIDGE_WEBHOOK_ID_FORMAT values are read in any case. - Tests: a refresh switching format, the size limit with wid, migration giving event-id, and the operator setting in the log. Refs #113 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #113.
SEP-3415 now requires each delivery's
webhook-idto be a per-message id, unique to one event on one subscription, kept across retries, and never derived fromeventId. The bridge has always sent theeventId, and TanStack AI, the Vercel AI SDK and OpenClaw reject anything else. This PR picks the format per subscription.What changes
event-id:webhook-idis the event'seventId, as today.per-message:msg_plus 24 random characters, the same on every retry of that delivery.auto(the default) chooses per subscription, at every subscribe and refresh:per-messagewhen the client declaresio.modelcontextprotocol/eventsin the request's_meta(io.modelcontextprotocol/clientCapabilities). The MCP SDK moves that envelope toctx.mcpReq.envelope, so the subscribe handler reads it from there.event-idfor any client that doesn't declare it, and for a legacy list of client names:tanstack-ai-mcp,ai-sdk-mcp-clientandopenclaw. TanStack AI declares the extension whenever events are on, and still rejects a per-message id, so the declaration alone isn't enough.BRIDGE_WEBHOOK_ID_FORMAT(subscriptions.webhookIdFormat):auto,event-idorper-message. A fixed value applies to every subscription, for exampleevent-idwhen one of those clients runs under a name of its own."wid":"msg"in the subscription's connection description, which the transformation reads. Replays publish with the same rule.headers.webhook-idtobody.eventId, on subscription and replay connections. A service resending an event runs the transformation again, which gives a new random id, so dedupe on the header would let the repeat through. It's the same as before forevent-idsubscriptions. Existing subscriptions take the new rule at their next refresh.per-message, rather than skipped.servelogs the choice after each subscribe:<subscription id>: webhook-id per message (client "<name>" declares io.modelcontextprotocol/events)or<subscription id>: webhook-id is the eventId (...).Verified
webhook-idwithcrypto.getRandomValues. The initial attempt, two automatic retries and a manual retry all carried the same id, each with a fresh timestamp and signature. The transformation runs once per event. Allspike-113resources are deleted.DUPLICATE, even though its randomwebhook-iddiffered.@tanstack/ai-mcp1.2.0), the AI SDK (@ai-sdk/mcp2.0.99) and OpenClaw (v2026.11.3). A bridge test with the MCP TypeScript SDK client confirms that a declared capability and the client name reach the subscribe handler.Details are in
docs/SPIKES.md, "Per-message webhook-id (#113)", anddocs/ARCHITECTURE.md, "Whichwebhook-id".Known limits
per-message, and its receiver answers400. The README troubleshooting table and the skill say to setBRIDGE_WEBHOOK_ID_FORMAT=event-id.eventId, because the SEP forbids deriving it fromeventId. So withper-message, an event's live delivery and its replay have different ids; receivers dedupe oneventIdfor that overlap.Tests
npm test: 461 pass, with new tests for both formats in the transformation, the store (including the description size limit), the config, the format choice, migration, and end to end through the SDK client (test/host/bridge.test.ts), including a refresh that switches format.An independent review found no correctness bugs; its three low-severity findings are fixed in the last commit: the size check counted
widfor every subscription, and the subscribe log didn't say when the legacy list or the operator setting chose the format.npm run typecheckandnpm run buildare clean.🤖 Generated with Claude Code