Appearance
Events extension
A customer's MCP client can subscribe to events about that customer: a message Frege sent them on Telegram, a change to their record, their connected account lapsing. Frege serves MCP's Events extension (SEP-3415) on a customer's own connection, as JSON-RPC methods beside the tools.
This page is for you if you write an MCP client, or a backend that receives events for one.
Capability
The server advertises capabilities.extensions["io.modelcontextprotocol/events"] in its initialize answer. Staff sessions, agents and the documentation server do not get it.
Events
| Name | Payload | When |
|---|---|---|
telegram.customer_message.sent | {RequestID, RunID} | Frege sent the customer a message on Telegram (an agent's reply it started on its own). |
telegram.customer_message.failed | {Reason, RequestID, RunID} | A message meant for them did not go, and is not tried again. Reason is no_bot, no_chat, blocked, refused or error. |
upstream.customer_fields.changed | {ChangedAt, Changes: [{Key, Redacted}]} | Fields of their customer record changed. Only the keys are sent, never the values. |
upstream.credential.lapsed | {Expiry: {Reason}} | The account they connected stopped working and could not be renewed: connect it again. |
events/list returns these with each one's description, delivery modes (webhook, poll), inputSchema and payloadSchema. Nothing else is listed.
Methods
Every result carries "resultType": "complete".
| Method | Params | Result |
|---|---|---|
events/list | events | |
events/subscribe | name, arguments, delivery: {mode, url, secret}, cursor, maxAgeMs, ttlMs | id, refreshBefore, cursor, truncated, deliveryStatus |
events/unsubscribe | name, arguments, delivery: {url} | {}, also when the subscription was already gone |
events/poll | name, arguments, cursor, maxAgeMs, maxEvents | events, cursor, truncated, hasMore, nextPollMs |
There is no push over the connection: events/stream is not served, and a delivery.mode other than webhook is refused.
Poll
json
{"jsonrpc": "2.0", "id": 7, "method": "events/poll",
"params": {"name": "upstream.credential.lapsed", "cursor": "c1.…", "maxEvents": 50}}maxEvents is 50 by default and at most 100. Keep the cursor of each answer for the next poll, and wait nextPollMs (30 seconds) between polls. Events are kept for 7 days.
Subscribe a webhook
json
{"jsonrpc": "2.0", "id": 8, "method": "events/subscribe",
"params": {"name": "telegram.customer_message.failed",
"delivery": {"mode": "webhook", "url": "https://hooks.example.com/frege",
"secret": "whsec_<base64 of 32 random bytes>"}}}urlmust behttpsand resolve to a public address; a private one is refused (-32602,data.reason: "private_address").secretis yours:whsec_and the standard base64 of 24 to 64 random bytes.ttlMsis how long the subscription lives: one day when left out, seven days whennull, from one minute to seven days otherwise. Subscribe again beforerefreshBeforeto keep it.- A subscription is one customer, URL and event. Subscribing to the same again renews it; with a new secret it rotates the secret, and for an hour deliveries are signed with both.
- These events take no
arguments. - A customer has at most 25 subscriptions, an environment 1000 (
-32025).
Verification
The first subscription of a URL for a customer sends a challenge, which covers that pair for 24 hours:
json
{"type": "verification", "challenge": "<nonce>"}Answer 2xx with {"challenge": "<nonce>"}. Anything else fails the subscription with -32027.
Deliveries
Each event is a signed POST with this body:
json
{"eventId": "evt_…", "name": "telegram.customer_message.failed", "timestamp": "2026-11-30T09:00:00.123Z",
"data": {"Reason": "blocked", "RequestID": "…", "RunID": 42}, "cursor": "c1.…"}| Header | Value |
|---|---|
Webhook-Id | msg_…, the same on every attempt of one delivery |
Webhook-Timestamp | Unix seconds, new on every attempt |
Webhook-Signature | v1,<signature>, two of them separated by a space while a secret rotates |
X-Mcp-Subscription-Id | The subscription |
User-Agent | Frege-MCP-Events/1 |
The signature is Standard Webhooks: HMAC-SHA256 of <id>.<timestamp>.<body>, keyed with the base64-decoded bytes after whsec_. Verification code is in Webhooks and signatures.
A 2xx answer is a delivery. Others are retried after 30 seconds, then 1, 2 and 4 minutes: five attempts in all. A 410 or 413 stops at once. Frege reads at most 4 KB of your answer, waits 10 seconds, and follows no redirects.
When the customer's access is revoked, the URL gets one last message and the subscription is deleted:
json
{"type": "terminated", "error": {"code": -32024, "message": "Forbidden", "data": {"reason": "access revoked"}}}Errors
| Code | Meaning |
|---|---|
-32602 | Invalid params; data.reason: "private_address" for a private callback URL. |
-32023 | No such event (data.kind: "event"). |
-32024 | Forbidden: access revoked. |
-32025 | Too many subscriptions; data.limit is subscriptions or stage_subscriptions. |
-32026 | Unsupported delivery mode. |
-32027 | The callback failed verification; data.reason is challenge_failed, timeout, connection_refused or tls_error. |
-32603 | The events could not be served just now; try again. |