Wait for Agent Events
ledger_wait_eventsLong-poll an agent's event feed — how an agent with no public URL receives alerts.
Webhooks (POST /v1/webhooks) push events to a URL you own; an agent on
stdio MCP cannot host one, so it waits here instead. Call this in a loop:
the call holds open up to timeout seconds (max 30) and returns when
events arrive or the wait lapses.
consumer_id names this consumer durably — pick a stable one
(e.g. "claude-code-main") and reuse it. Each call returns a cursor;
pass it back on your next call once you have processed that batch — that
is the ack. To get restart redelivery, also pass client_instance (your
process id or any per-boot token) and client_started (when your
process booted): when the pair changes, events that were served but
never acked come back with redelivered: true, so nothing is lost to a
crash between serve and process. (The stdio MCP server supplies its own
pid/started automatically — hosted callers must opt in because the
gateway cannot see the client's process.)
Each event is an envelope: id (deterministic — dedupe on it), kind (alert.raised | budget.warning | budget.exceeded | anomaly.detected), summary, context (agent_id, alert_type, timestamp), alerts_since_last_write (how many alerts are stacked up since the agent's last spend write — use it to throttle escalation), redelivered.
Requires a credential: either the agent's own agent_secret or its workspace's workspace_key (same rule as GET /v1/agents/{agent_id}/events/wait).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | optional label for this consumer instance | mcp |
| cursor | No | line offset you have processed through (omit to continue) | |
| timeout | No | seconds to hold the call open (default 5, max 30) | |
| agent_id | Yes | unique agent identifier | |
| consumer_id | Yes | durable name for this consumer (1-64 chars, [A-Za-z0-9._-]) | |
| agent_secret | No | the agent's own secret (either this or workspace_key) | |
| workspace_key | No | the owning workspace's key (either this or agent_secret) | |
| client_started | No | when your process booted — paired with client_instance | |
| client_instance | No | your process identity (e.g. pid or per-boot token) — enables restart redelivery |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||