receiver
Receive SEP-3415 webhook deliveries: an ASGI app that verifies, decodes, and hands them over.
async def handle(delivery: EventOccurrence | WebhookGap | WebhookTerminated) -> None:
...
receiver = WebhookReceiver(secret, handle)
app = Starlette(routes=[Mount("/hooks/events", receiver)])
WebhookGap
dataclass
Events were skipped; resume from cursor, and reconcile if the gap matters.
Source code in src/mcp/experimental/events/receiver.py
33 34 35 36 37 38 | |
WebhookTerminated
dataclass
The server ended the subscription, e.g. after access was revoked; resubscribing may fail the same way.
Source code in src/mcp/experimental/events/receiver.py
41 42 43 44 45 46 | |
WebhookReceiver
ASGI app for the callback URL of webhook subscriptions made with one secret.
Requests that are unsigned, signed with another secret, or older than tolerance
get a 401 and never reach handler. Events are deduplicated on their subscription and
event_id across the last dedupe_window events, since servers retry deliveries.
Source code in src/mcp/experimental/events/receiver.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |