---
title: MCP events
description: "Subscribe to app events from an MCP client over webhook delivery using events/list, events/subscribe, and events/unsubscribe."
---

Executor implements the draft `2026-07-28` MCP Events extension (`events/list`, `events/subscribe`, and `events/unsubscribe`) so an MCP client can receive push notifications when an app emits a declared event. Clients subscribe with a webhook callback URL and a Standard Webhooks signing secret (`whsec_...`), answer a verification challenge, and receive signed HTTP POST deliveries for matching events.

- **Available on:** Local, Self-host, and Cloud (shipped in `2.0.0-beta.79`).
- **Prerequisites:**
  - Support for the draft **`2026-07-28`** MCP protocol revision (ordinary `2025-11-25` initialize responses do not advertise events). Send `MCP-Protocol-Version: 2026-07-28`, `MCP-Method: <method>`, `Accept: application/json, text/event-stream`, `Content-Type: application/json`, and the protocol `_meta` block on every `events/*` request.
  - An authorized MCP connection (OAuth grant, personal access token, or local server API key) with access to an app that declares events.
  - A webhook receiver endpoint reachable over HTTPS, or over loopback `http://` on a server whose egress policy explicitly permits loopback HTTP (`EXECUTOR_URL_ALLOW_LOOPBACK_HTTP=true`, enabled by default on Local and configurable on Self-host).
- **Main JSON-RPC method:** `events/subscribe` against `/mcp`.

You'll know it worked when your webhook receiver verifies and echoes the `verification` challenge with HTTP `2xx`, `events/subscribe` returns a subscription `id` and `refreshBefore`, and emitting an app event delivers a signed JSON payload to your callback URL.

## How subscriptions work

Calling `events/list` on `/mcp` returns one shared event definition named `executor.app_event` (title `"Executor app events"`, delivery `["webhook"]`). You can subscribe in two ways:

1. **Broad or filtered via `executor.app_event`:** Pass `name: "executor.app_event"` with optional `arguments`:
   - `{}` subscribes to all events from every app your connection can access.
   - `{ app: "<app-slug>" }` subscribes to all events declared by that app.
   - `{ app: "<app-slug>", event: "<event-name>", ...filters }` subscribes to one event with its declared filter fields.
   - Delivered payloads wrap the event as `{ app, event, data }` inside the envelope's `data`.
2. **Direct app event name:** Pass `name: "<app-slug>.<event-name>"` with optional declared filter fields in `arguments` (for example `{ repo: "acme/widgets" }`). Delivered payloads place the event's fields directly in `data`.

If you use a [scoped connection](/docs/mcp/scoped-connections), enable either **All events** or the specific event names under that app on the **Connections** page. An exact event subscription returns `-32012` for a disallowed event, or `-32011` if the app cannot be resolved in your visible app list. Broad subscriptions are accepted and omit unauthorized occurrences at delivery.

## Subscribing and verifying a webhook

### Cloud and Self-host

1. Generate a Standard Webhooks signing secret: `whsec_` followed by base64-encoded random bytes (24 to 64 raw bytes).
2. Expose an HTTPS callback URL (no userinfo or URL fragment; redirects are not followed; Self-host may also accept callbacks on its own loopback address when `EXECUTOR_URL_ALLOW_LOOPBACK_HTTP=true`). Verify signatures and timestamp freshness before echoing `{"challenge":"<token>"}` with HTTP `200` for `{"type":"verification","challenge":"<token>"}`.
3. POST `events/subscribe` to `https://mcp.executor.sh/mcp` (Cloud) or `<your origin>/mcp` (Self-host) with the `2026-07-28` headers, `_meta`, `delivery: { mode: "webhook", url, secret }`, and an optional positive integer `ttlMs` (clamped to 60 seconds through 7 days; omit for 24 hours or send `null` for 7 days).
4. Renew before the returned `refreshBefore` (rather than computing expiry from your requested `ttlMs`) by calling `events/subscribe` again with the same credential, selector, arguments, and URL, or stop deliveries with `events/unsubscribe`.

You'll know it worked when `events/subscribe` returns `{ id, refreshBefore, ... }` and your receiver records a verified `msg_verification_<uuid>` request followed by event deliveries.

### Local

The same JSON-RPC flow runs against `http://127.0.0.1:4312/mcp` (or your server's reported port) using either a local OAuth bearer token or the local server API key, and your receiver may listen on loopback `http://127.0.0.1:<port>/...` while loopback HTTP is enabled.

You'll know it worked when triggering the emitting app tool delivers a signed POST to your local receiver with `x-mcp-subscription-id` matching the subscription ID.

## Verifying signatures, rotation, and authorization

Every verification request and event delivery includes four headers:

- `webhook-id`: Unique message ID (`msg_verification_<uuid>` for verification; the event ID across retries for event deliveries—the same event ID can also be delivered to more than one subscription).
- `webhook-timestamp`: Unix timestamp in seconds.
- `webhook-signature`: Space-separated Standard Webhooks signatures in format `v1,<base64 HMAC-SHA256(secretBytes, "${webhookId}.${webhookTimestamp}.${rawBody}")>`.
- `x-mcp-subscription-id`: The subscription ID returned by `events/subscribe`.

Verify Standard Webhooks signatures against the raw request bytes with a constant-time verifier (`crypto.timingSafeEqual`) and a timestamp tolerance (for example, 5 minutes). Reject invalid or stale requests before echoing a challenge or processing an event. Acknowledge retries for already processed `webhook-id` values without applying the same event twice.

- **Verification reuse:** Executor can reuse a verification less than 24 hours old from an active subscription under the same credential and callback URL (so a successful subscribe response does not always send a new challenge).
- **Secret rotation:** To rotate a subscription secret, resubscribe with the same credential, selector, arguments, and URL and a new secret. Rotation sends a new verification challenge, and Executor signs both the challenge and deliveries with the current and immediately previous secret for 5 minutes. Accept both outgoing and incoming secrets during that overlap.
- **Per-delivery authorization:** For each delivery attempt, Executor checks that the subscription is active and applies the target's current authorization. Hosted checks the grant or token, organization and app access, event permission, and access to recorded accounts (scoped policies can further restrict which account IDs qualify). Local OAuth checks the grant and its scope. Local API-key subscriptions use the installation's administrative access.

## Example

Run a complete Local walkthrough using `executor@2.0.0-beta.79` with no hosted target selected or remembered.

### 1. Create and deploy a synthetic emitter app

```bash
mkdir -p ./tracker
FRAMEWORK_VERSION=$(executor apps framework | node -e 'const d = JSON.parse(require("node:fs").readFileSync(0, "utf8")); console.log(d.version);')

cat <<EOF > ./tracker/package.json
{
  "name": "tracker",
  "private": true,
  "dependencies": {
    "apps": "${FRAMEWORK_VERSION}"
  }
}
EOF

cat <<'EOF' > ./tracker/index.ts
import { defineApp, event, mutation, number, object, router, string, type MutationContext } from "apps";

const issueOpened = event({
  description: "An issue was opened in a repository.",
  filters: { repo: string({ minLength: 3 }) },
  payload: object({ title: string(), number: number() }),
});

const requirements = { events: { "issue.opened": issueOpened } };

const open = mutation(
  { input: object({ repo: string(), title: string(), number: number() }) },
  async (ctx: MutationContext<typeof requirements>, input) => {
    ctx.events.emit(
      "issue.opened",
      { title: input.title, number: input.number },
      { filters: { repo: input.repo } },
    );
    return { emitted: true };
  },
);

export default defineApp(requirements, { tools: router({ open }) });
EOF

APP_ID=$(executor apps create --name "tracker" --files ./tracker | node -e 'const d = JSON.parse(require("node:fs").readFileSync(0, "utf8")); console.log(d.id);')
executor apps deploy --app "$APP_ID" --files ./tracker --message "Initial tracker emitter"
```

### 2. Start a verifying webhook receiver

Save `receiver.mjs`, which verifies signatures with `timingSafeEqual`, checks a 5-minute timestamp window, rejects invalid or stale requests before parsing or echoing, supports comma-separated secrets during rotation, and deduplicates retried `webhook-id` values:

```js
// receiver.mjs
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";

const secrets = (process.env.WEBHOOK_SECRETS ?? "").split(",").filter(Boolean);
const toleranceSec = 300;
const processed = new Set();

function verifySignature(headers, rawBody) {
  const id = headers["webhook-id"];
  const ts = headers["webhook-timestamp"];
  const sigHeader = headers["webhook-signature"];
  if (typeof id !== "string" || typeof ts !== "string" || typeof sigHeader !== "string") return false;
  const tsNum = Number(ts);
  if (!Number.isInteger(tsNum) || Math.abs(Math.floor(Date.now() / 1000) - tsNum) > toleranceSec) {
    return false;
  }
  const presented = sigHeader.split(" ").filter((s) => s.startsWith("v1,"));
  for (const secret of secrets) {
    if (!secret.startsWith("whsec_")) continue;
    const key = Buffer.from(secret.slice("whsec_".length), "base64");
    const expected = Buffer.from(
      "v1," + createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest("base64"),
    );
    for (const candidate of presented) {
      const buf = Buffer.from(candidate);
      if (buf.length === expected.length && timingSafeEqual(buf, expected)) return true;
    }
  }
  return false;
}

const server = createServer((req, res) => {
  if (req.method !== "POST" || req.url !== "/hook") {
    res.writeHead(404).end();
    return;
  }
  const chunks = [];
  req.on("data", (chunk) => chunks.push(chunk));
  req.on("end", () => {
    const rawBody = Buffer.concat(chunks).toString("utf8");
    if (!verifySignature(req.headers, rawBody)) {
      res.writeHead(401).end();
      return;
    }
    const message = JSON.parse(rawBody);
    if (message.type === "verification") {
      console.log(JSON.stringify({ kind: "verification", id: req.headers["webhook-id"] }));
      res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify({ challenge: message.challenge }));
      return;
    }
    const webhookId = req.headers["webhook-id"];
    if (!processed.has(webhookId)) {
      processed.add(webhookId);
      console.log(JSON.stringify({ kind: "event", id: webhookId, subscription: req.headers["x-mcp-subscription-id"], body: message }));
    }
    res.writeHead(200).end();
  });
});

server.listen(Number(process.env.HOOK_PORT ?? 45123), "127.0.0.1", () => {
  console.log(`listening on http://127.0.0.1:${server.address().port}/hook`);
});
```

Start the receiver with a generated secret (keep the secret in an environment variable rather than printing it):

```bash
WEBHOOK_SECRET="whsec_$(node -e 'process.stdout.write(require("node:crypto").randomBytes(32).toString("base64"))')"
HOOK_URL="http://127.0.0.1:45123/hook"
WEBHOOK_SECRETS="$WEBHOOK_SECRET" HOOK_PORT=45123 node receiver.mjs > receiver.log 2>&1 &
RECEIVER_PID=$!
```

### 3. Subscribe over streamable HTTP (`2026-07-28`)

Set `MCP_URL` (default `http://127.0.0.1:4312/mcp` on Local) and `MCP_TOKEN` (your OAuth bearer token, hosted PAT, or local server API key), then subscribe:

```bash
MCP_URL="${MCP_URL:-http://127.0.0.1:4312/mcp}"

curl -sS -X POST "$MCP_URL" \
  -H "Authorization: Bearer ${MCP_TOKEN}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "MCP-Protocol-Version: 2026-07-28" \
  -H "MCP-Method: events/subscribe" \
  -d "{
    \"jsonrpc\": \"2.0\",
    \"id\": 1,
    \"method\": \"events/subscribe\",
    \"params\": {
      \"name\": \"tracker.issue.opened\",
      \"arguments\": { \"repo\": \"acme/widgets\" },
      \"delivery\": {
        \"mode\": \"webhook\",
        \"url\": \"${HOOK_URL}\",
        \"secret\": \"${WEBHOOK_SECRET}\"
      },
      \"_meta\": {
        \"io.modelcontextprotocol/protocolVersion\": \"2026-07-28\",
        \"io.modelcontextprotocol/clientCapabilities\": {}
      }
    }
  }"
```

### 4. Emit an event and check receipt

```bash
executor call tools.tracker.open --input '{"repo":"acme/widgets","title":"Issue 1","number":1}'
cat receiver.log
```

Confirm that `receiver.log` shows both a verified `verification` entry and an `event` entry whose body matches:

```json
{
  "eventId": "019...",
  "name": "tracker.issue.opened",
  "timestamp": "2026-11-26T12:00:00.000Z",
  "data": { "title": "Issue 1", "number": 1 },
  "cursor": null
}
```

### 5. Unsubscribe

Send `events/unsubscribe` with the `2026-07-28` headers, matching `_meta`, and the same `name`, `arguments`, and `delivery` (`mode` and `url`):

```bash
curl -sS -X POST "$MCP_URL" \
  -H "Authorization: Bearer ${MCP_TOKEN}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "MCP-Protocol-Version: 2026-07-28" \
  -H "MCP-Method: events/unsubscribe" \
  -d "{
    \"jsonrpc\": \"2.0\",
    \"id\": 2,
    \"method\": \"events/unsubscribe\",
    \"params\": {
      \"name\": \"tracker.issue.opened\",
      \"arguments\": { \"repo\": \"acme/widgets\" },
      \"delivery\": { \"mode\": \"webhook\", \"url\": \"${HOOK_URL}\" },
      \"_meta\": {
        \"io.modelcontextprotocol/protocolVersion\": \"2026-07-28\",
        \"io.modelcontextprotocol/clientCapabilities\": {}
      }
    }
  }"

kill "$RECEIVER_PID"
```

## Limits

| Limit | Value |
| --- | --- |
| Delivery mode | `webhook` only (no cursor replay; requesting another mode or non-null cursor returns `-32014`) |
| Signing secret | `whsec_` prefix + base64 of 24–64 raw bytes |
| Subscription TTL | Positive integer clamped to 60 seconds–7 days; omit for 24 hours; `ttlMs: null` requests 7 days |
| Delivery retries | Up to 14 attempts (5 s exponential backoff capped at 1 hour, ~4 h 25 min scheduled delays) |
| Per-attempt timeout | 10 seconds |
| Event retention | 3 days |
| Payload size | 250 KiB max emitted JSON data; 256 KiB max delivery body; 100 emits per invocation |
| Permanent stop codes | HTTP `410` or `413` from the receiver stops retries for that delivery |

Error codes returned by `events/*`:

- `-32602`: Invalid parameters (nonpositive TTL, invalid TTL type, missing `_meta`, bad secret format, invalid URL, or invalid filters).
- `-32011`: App or event not found (or app not visible to this connection).
- `-32012`: Connection is not authorized for that event.
- `-32014`: Unsupported delivery mode, cursor replay requested, or existing subscription filters no longer match the event schema on renewal.
- `-32015`: Callback verification failed (`data.reason` describes why).

## Related

- [The MCP endpoint](/docs/mcp)
- [Scoped connections](/docs/mcp/scoped-connections)
- [Apps](/docs/apps)
- [Author an app](/docs/author-an-app)
