Skip to content

MCP Events and Temporal for agents that react to events

Preetham ReddyUpdated 7 min readVoices

We built the agents in AutoFabric, our auto refinance platform, and they act the moment something changes in a loan file. Nobody has to prompt them, and we hand each action they take to a Temporal workflow that survives a server restart once it has started. An agent that only answers when it's asked can't do that. It calls a tool, gets data back and goes quiet, so a payoff quote that lands in the evening sits until somebody notices it the next morning.

For a business, that gap is the difference between an agent that saves a processor's evening and one that waits for the processor to come back. An agent that reaches a company's systems over MCP waits for a plain reason. MCP was request and response.

A draft extension called MCP Events is meant to close that gap. In it, your server notifies the client when something changes in a connected app. The client subscribes with events/subscribe, and your server stores that subscription and delivers matching events to a webhook until it expires or is ended, as WorkOS sets out in its walkthrough of the draft. For a company that owns the platform other people's agents connect to, that turns those agents from things a person queries into things that act the minute a payoff quote lands.

The other half of this is durable execution, which is ground we've covered. For Location Services we rebuilt assignment closure as a durable workflow on Temporal, so a close that fails retries on its own and alerts operations when the retries run out. The first thing to settle before any of it is what a subscription leaves behind on your side.

What a subscription leaves in your database

The client calls events/subscribe with an event name, filter arguments and a delivery destination. Here is the shape, as an illustration of what a lending platform would receive:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "events/subscribe",
  "params": {
    "name": "payoff_quote.returned",
    "arguments": { "deal_id": "deal_4471" },
    "delivery": {
      "mode": "webhook",
      "url": "https://agent.example.com/hooks/mcp",
      "secret": "whsec_..."
    },
    "cursor": null
  }
}

After that call you hold a durable row naming a user, a destination on the public internet and a signing secret, created under an access token that will be dead long before the row is.

That asymmetry is the thing to design around. A subscription is keyed on the principal, the callback URL, the event name and the arguments, a tuple that carries no token, no scopes and no expiry of its own, and it keeps delivering for whatever TTL you granted.

It does mean the defaults are yours to pick.

Agent calls events subscribe

Access token checked each request

Subscription row stored on your server

Token expires and fails

Deliveries continue for the granted TTL

Scheduled reverification ends it early

No signal reaches the subscription

The access token behind a subscribe call is rechecked on every request and soon expires, while the subscription it created keeps delivering until its TTL lapses or a scheduled reverification ends it.

Subscription TTLs and reverification

My position, before anyone writes the handler. Refuse ttlMs: null and grant short, finite TTLs, because the TTL you grant is the window in which a revoked subscription is still live and nobody can see it. Then reverify access on a schedule you can say out loud.

Grant no expiry and there's no refresh, so there's no error either.

The failure that costs money runs the other way. If your server only authorized at subscribe time, which is all the draft strictly requires, every matching change keeps being posted to a callback that still answers until the subscription lapses, and your audit log shows a successful webhook delivery and nothing else.

Two indexes earn their keep on that table. One on the user, so offboarding ends every subscription that user created instead of assuming it died with their account, and one on the time of last reverification, so a sweep turns periodically into a number you can state. Wire the per-user delete into whatever already handles deprovisioning. On the client side the same discipline applies in reverse, where the agent's own identity decides what it may subscribe to and a shared service account doesn't. Build it with one token for everybody and you'll build it twice.

Handling a delivery in a durable workflow

This is where an implementation can fall over. Teams handle the notification inside the agent loop. Receive event, read the record, call the model, call your APIs, write something back. That works in a demo. It breaks when a model call times out mid-sequence, when the worker is redeployed between one API call and the next, or when the same event arrives twice because a delivery was retried. The agent loop keeps its progress in memory, and a restart loses it.

So we keep the agent's webhook narrow. In AutoFabric the agents' Worker checks a timestamped HMAC signature on every delivery and refuses one more than five minutes old. It then looks up the event's id, and a delivery it has already handled is dropped. Our platform gives a delivery ten seconds before it retries on a schedule that starts at one minute and runs for about three days. One model round trip on Databricks plus an email send can take longer than ten seconds, so without that lookup a borrower would get the same email twice. The marker for each event id is kept for seven days, longer than the whole retry schedule.

Everything the agent then does goes back through the platform's actions, the same ones our MCP server for AutoFabric exposes, and every action runs as a Temporal workflow. A step that waits on a person runs as an approval workflow that rechecks its approval every ten minutes until a deadline, so a redeploy in the middle of the wait loses nothing. Our voice calls lean on the same machinery for calls that never report back. That's the same split that made failed steps retry on their own in the Athlinks pipeline instead of taking the run down with them.

MCP Events would map cleanly onto the same shape. Derive the workflow ID from the case the event is about, signal that workflow as the case changes, and carry your own idempotency key in the signal payload so a redelivered event is harmless. The AI SDK's MCP Events documentation is explicit that deliveries may be duplicated or reordered, so dedupe on the subscription ID and the event ID rather than trusting arrival order. Keep the payload itself thin, a summary plus an identifier, and let the workflow fetch the full record through a governed read. Our signals already work that way: when a borrower's reply has been saved, the signal that wakes the loan's workflow carries no extracted fields, and the workflow re-reads what was stored. Event receipt isn't authorisation to act, so the action the agent takes goes through the same checks any tool call would.

What this buys is a record you can show an auditor. In AutoFabric every action an agent takes is an ActionInvocation row with the agent as the actor, and every retry and approval wait sits in a workflow history, all tied to one loan application. Autonomy without that record is an unlogged robot.

Where Databricks comes in

Most events worth reacting to need a judgement, and a judgement needs data the triggering system doesn't hold. A payoff figure means nothing until you compare it with what the deal was structured on. A late shipment means nothing until you know what else is in the yard and which orders it blocks.

So we'd make the workflow's first real step a read against the lakehouse, through Unity Catalog, under an identity that belongs to the agent rather than to whoever happened to set the subscription up. That's the same governance question we'd ask of any agent reading client data, and it gets harder, not easier, when nobody is sitting there watching the agent work.

The reconciliation layer matters as much as the stream. The AI SDK documentation notes that deliveries may be duplicated or reordered and that some events cannot be replayed. So we'd write a Delta table of everything the platform emitted, from the same place the notifications come from, and let a scheduled workflow ask what it should have seen and didn't. That table is also what you calibrate against later. Which events led to an action, which actions a human reversed, and where the agent was wrong.

Change inside your platform

Signed webhook delivery

Verify and deduplicate the event

Handling it in the agent loop

Temporal workflow per case

Governed reads in Unity Catalog

Delta tables for the judgement

Delta event log for reconciliation

A thin signed notification is verified and deduplicated, starts or signals one durable workflow per case, and the judgement happens through governed reads on the lakehouse.

Start with the event that costs the most when it's late

Pick the one event in your platform where a slow reaction costs real money, and build that path only. Run it for a few weeks before you expose a second event type. You'll learn more from it, including how often deliveries repeat and whether your reverification sweep catches a revoked user, than from a design document covering every event you can imagine.

Most of the build goes into what happens after the delivery, the verification, the workflow and the governed reads, rather than the subscription itself. Our Unity Catalog write-up covers how we think about agent identity on the data side, and the reads this workflow depends on. And for the request-and-response side that MCP Events extends, the two servers we run ourselves are on our MCP servers page.

Frequently asked questions

Do MCP Events replace webhooks?

No. In the draft the server still delivers each event to a webhook the client named when it subscribed. What MCP Events adds is a standard way for an agent to ask for those deliveries, with an event name, filter arguments and a TTL, through the same protocol it already uses for tools, so the subscription becomes a row your server stores and has to govern.

Does an MCP event subscription expire with the access token that created it?

No. The subscription is keyed on the principal, the callback URL, the event name and the arguments, a tuple that includes no token, no scopes and no token expiry, and ttlMs: null requests a subscription with no expiry. The TTL you grant is the window in which a revoked user's subscription is still live, which is why short finite TTLs and a scheduled reverification sweep are the safer default.

How does securing an event webhook differ from securing a tool call?

A tool call arrives at your server with the caller's access token, so you check it on every request. A webhook arrives at the agent's side, so the agent has to prove the sender instead. In AutoFabric the agents' Worker checks an HMAC over the delivery's timestamp and body and refuses anything older than five minutes, which stops a captured delivery being replayed later.

Does AutoFabric use MCP Events today?

No. AutoFabric's agents get platform events as signed webhooks, which they verify and de-duplicate by event id before acting. MCP Events would let an outside agent subscribe to the same kind of event through the protocol it already uses for tools, and the handling behind it would stay the same: verify the delivery, de-duplicate it and hand each action to a Temporal workflow.

Where we do this work