A few weeks ago I set out to give every AI agent its own cryptographic identity. Then I asked the people who run MCP servers what they actually needed. Most of my first idea didn't survive. This is what did.
The problem
A user connects Claude, ChatGPT, Cursor and a couple of their own agents to the same account on your MCP server. One of them starts misbehaving: looping, over-reading, doing something the user didn't intend. Today, cutting off that one agent usually means signing the user out everywhere, or rotating a key every agent shares.
What I got wrong first
- "Servers want keyless agent identity." They don't. A free, self-made ID costs an abuser nothing, so it can't protect a free tier. One operator watched accounts get farmed at 70+ an hour; a stable ID wouldn't have helped.
- "Revocation is painful for everyone." It isn't. Many operators already tie keys to users and revoke the user.
- "Builders will pay for a hosted agent wallet." Three said no outright. They keep secrets in keychains or Vaultwarden and don't want to hand credentials to a startup.
What operators actually said
- Anything costly stays on their own accounts. Paid tools, writes and anything that spends money need their own sign-in, credits or billing.
- Identity they didn't issue is worth little, unless there's a contract. One security engineer said outside credentials would look like an attack in their SIEM. Federated partners are accepted only under an agreement. It's a business question first.
- Reads are where outside identity can help. Two operators said a signed, per-agent token could earn a looser limit on cheap read tools. One runs a hosted notes server and wants per-agent revocation on its search and read tools without re-authing the whole account.
- Revocation has to be fast. If revoking takes a day, you've outsourced vetting to someone slower than your own account system. A minute of caching is fine for reads. Writes need a live check.
- Scope the dangerous tools. Anything that can send, delete or spend gets its own scope. Reads can stay per server.
The design now
It's deliberately boring: a standard JWT from an issuer you verify against a public key.
{
"iss": "https://issuer.example",
"sub": "user_123",
"agent_id": "cursor-laptop",
"aud": "https://your-server.example/mcp",
"scope": "search_notes read_document",
"iat": 1762700000,
"exp": 1762700900,
"jti": "6f1c..."
}
- Verification: signature against the issuer's JWKS, then issuer, audience and expiry. Any JWT library does this.
- Revocation: a list of revoked agent IDs. Reads cache it for up to 60 seconds; writes check it live.
- Scopes: reads per server to start; send, delete and spend get their own scopes.
- Rollout: observe-only first. Tokens are checked and logged, nothing is blocked, and existing auth is untouched.
What's still open
- Writes. Operators want per-agent control most on dangerous tools, but they only trust identity they issue. For writes, the server probably has to be the issuer.
- Whether anyone pays for this. Nobody has named a price yet.
- Whether it beats what OAuth already gives you. One client registration per agent gets you part of the way.
Looking for testers
If you run an MCP server that holds people's notes, memory, documents or meeting data, I'm looking for one or two more operators to test this on read tools.
- About 30 minutes, with me helping: a small snippet and two settings.
- Observe-only. Nothing is blocked; remove the setting and it's gone.
- You get per-agent visibility in your logs, a one-agent kill switch on reads, and a short write-up of the results, including what didn't work.
Comment or reach out if you're interested. If you'd never use this, a sentence on why helps just as much.
Disclosure: I'm building an open-source library in this area, so I'm biased. Drafted with help from Claude, edited by me.
Top comments (20)
When the server is the issuer, most of the revocation problem shrinks to token lifetime. In one MCP server I run on Kubernetes, an agent's only credential is a projected ServiceAccount token with the server's audience and a ten-minute life, and the server asks TokenReview about it before it answers. A stolen token is worth ten minutes. The API server refuses it outright.
The piece I'd borrow for your scopes is how an ungranted tool answers. It's missing from
tools/list, and a call to it gets the same error as a tool that doesn't exist, so a looping agent can't probe what it might be allowed. The destructivedelete_recordexists on the server and is granted to nobody; a static check fails the build if it ever is.On Kevin's spend limit, one caveat from the same setup: the rate limit lives in the process. Several replicas would each allow their own ten calls.
This is great, thank you. Three things I'm taking: ungranted tools disappear from tools/list and return the same error as a tool that doesn't exist, so a loop can't probe; destructive tools are granted to nobody by default, with a build check; and Kevin's cap has to be a shared counter, since an in-process limit multiplies with replicas. Your setup covers agents inside the cluster really cleanly. Do agents from outside it ever call that server? That's the case I'd most like to test, observe-only, if you're up for it.
No. Its only callers are agent pods in the same cluster, and it accepts nothing but a projected token issued for its own audience; anything else gets a 401. An observe-only test from outside would see that 401 and little more.
That is also why it skips the spec's OAuth flow. Inside one cluster the kubelet mints a token bound to the pod and the audience, and TokenReview checks it, so the authorization server's job is already done. A desktop agent or another cluster's workload has no kubelet behind it.
Opening the door to them means the server becomes an OAuth 2.1 resource server and publishes Protected Resource Metadata (RFC 9728). That's where your issuer question comes back, with a real issuer to answer it.
Kevin's point about the spend limit is the one I'd underline too, and it ties back to your revocation caching. A max-per-run carried in the token only helps if the server meters against it live: if the spend check happens at token issue and then the token is good for 15 minutes, a looping agent can still burn the whole budget inside that window. The claim has to be paired with a server-side rolling counter keyed on agent_id + sub, checked before each spend-bearing call, not just at verification time.
Same logic applies to the 60-second revocation cache for reads: fine when the cost of being wrong is one more cheap read, but for anything metered the cache window is exactly the window a runaway loop exploits. I'd treat spend-bearing tools like writes here — live check, no cache — even if the scope is read-only in name.
One question on the design: with the token's 15-minute expiry, does the agent re-mint on expiry mid-run, and does the per-run cap reset with the new token? If the cap is per-token rather than per-run, a long job that refreshes tokens gets a fresh budget each time, which quietly defeats the limit.
This is a real flaw, thank you. A cap carried in the token resets every time the agent re-mints, so a long run gets a fresh budget every 15 minutes. The fix I'm taking: the token only identifies the agent (agent_id plus sub, optionally a run_id), and the budget lives on the server as a rolling counter keyed on those, checked before every spend-bearing call. And agreed: anything that costs money gets a live check, whatever its scope says.
To answer directly: yes, the agent re-mints on expiry mid-run, which is exactly why the budget can't live in the token. If you run a metered server, I'd value you testing exactly this: observe-only, and it would show where a cap would have stopped a loop on your traffic.
The read vs write split reflects how document repositories handle delegation. For read tools, an agent querying notes or PDFs often runs in an aggressive retrieval loop. Having
agent_idin the JWT lets you throttle a looping scraper without disrupting the user's interactive session.For writes, issuing the token from the MCP server itself avoids the federated trust problem. If the server signs the token with a deterministic fingerprint of the client harness, it can enforce least-privilege mutations without maintaining external key agreements.
That's a better way to put the read case than mine: throttle the looping scraper by agent_id and leave the user's interactive session alone. And agreed on writes, the server issuing the token keeps trust where operators want it. Does KolmoPDF run an MCP server for PDFs? If so, I'd love to have you test this on your read tools: observe-only, about 30 minutes with me helping.
Most of the first idea not surviving contact with operators is the best outcome a post like this can have. Keyless identity that costs an abuser nothing, a hosted wallet nobody wants, and revocation that was never actually painful would all have been expensive things to build.
The spend cap thread is the sharpest part. A cap carried in the token resets every time the agent re-mints, and an in-process counter multiplies with replicas. A shared rolling counter keyed on agent and run, checked before every call that costs money, is the version that holds.
At Ascendra Ventures we write these as acceptance cases before building anything for agents: revoke one agent in under a minute without signing the user out, and stop a looping agent at a number the customer chose. If the design cannot pass those two, it is not done.
Did any operator give you a target for how fast a write-tool revocation has to take effect?
No operator gave me a number for writes, but two said the same thing a different way: reads can cache revocation for about a minute, and writes need a live check on every call. So the target for writes isn't a window. The first write after a revoke fails. I'll take your two acceptance cases as the bar for the test: revoke one agent without signing the user out, and stop a looping agent at a number the customer chose. Do you build agents for clients that call outside MCP servers? That's the side I still need testers for.
honestly I would reach for a spend limit per agent before the kill switch. on metered tools the thing that hurts is one loop going through the balance and by the time someone revokes it the money is gone, so a max per run carried in the token is what would get me to try this
That makes sense, and it changes what I'd lead with for metered tools: cap each agent's spend before worrying about the kill switch. Two corrections from this thread: the cap has to live on your server as a counter per agent, not just in the token, or a refresh resets it (agentwares). And the counter has to be shared across replicas, or each one hands out its own budget (Vladimir).
In an observe-only test I could show exactly where a per-agent cap would have stopped a loop on your real traffic, without blocking anything. Would you want to try that on a metered endpoint?
We ended up close to this with plain project keys: each agent can get its own key, so cutting one off doesn't sign you out of everything else.
That's the simplest version that works. Is there anything you wish those per-agent keys did that they don't, like expiring on their own, capping spend per agent, or showing which agent did what? If any of that matters, I'd be glad to have you try this observe-only alongside your keys and see if it adds anything.
Thanks! Spend is already capped per team and per member on our side, so not much is missing for now.
Good write-up, and I appreciate that the design changed after talking to operators. Two strengths that are easy to overlook:
1) The observe-only rollout is a very practical adoption path — it gives operators per-agent visibility without breaking existing auth, which is usually the hardest part of shipping auth changes.
2) The “boring” JWT/JWKS choice is a feature, not a weakness: standard verification, no vendor lock-in, and a clear separation between identity issuance and server-side policy. That should make it easier to test and adopt.
I’d be glad to compare notes, and I can introduce a couple of colleagues who run MCP servers or security teams if that helps broaden the tester pool.
One limitation I don’t think can be argued away: the design is strongest for reads and still unresolved for writes. For send/delete/spend tools, operators want identity they issue, so an external per-agent JWT alone cannot deliver the control that matters most; without consistent server-side validation and live checks at every enforcement point, it can create a false sense of security.
A realistic next step would be to publish a small operator checklist and reference tests covering issuer/audience/expiry validation, scope mapping, live revocation for writes and metered calls, shared rolling spend counters keyed on agent_id + sub (and run_id if used), and audit records that stamp the verified agent_id at write time. That would make the design easier to evaluate and safer to adopt.
Does a per-agent token help when two agents sit behind one client, like two Claude Code sessions? That's the case one client registration per agent can't separate.
Good question, and that's exactly the case client registration can't separate. A per-agent token can, but only if each session gets its own agent_id, which means something on the client side has to mint one per session: a small wrapper or local proxy around Claude Code, since it won't do that by itself. Is that your setup, several sessions running at once against the same server?
This lines up almost exactly with where I landed building the same thing, which is either reassuring or suspicious.
Three notes from running it in production rather than designing it:
Revocation. I went with a live check on everything rather than a 60s read cache. Your tradeoff is probably right at volume, but one cost worth knowing: the demo that makes people actually understand the product is revoke, then call again, denied, in the same breath. With a cache window that demo has an asterisk in it.
The thing I’d add to your list. Your operators told you revocation must be fast and dangerous tools need their own scopes. Both of those are about stopping an agent. Nothing in the design answers what it did before you stopped it. I hash-chain every verify decision into an append-only log, and the honest reason was compliance theater. Then I had an outage where the absence of one expected log entry located the crash immediately, and it’s turned out to be the most useful thing I built.
On “does this beat OAuth.” Per-client registration gets you most of the way for a handful of agents. It falls over when agents are spawned programmatically, because you’re doing client registration at runtime for ephemeral things. That’s where the line is for me.
One thing I’d be curious whether you probed: your three no’s were on hosted issuance, which makes sense to me, that’s a thing people can build themselves and know it. Did anyone react differently to the audit side? My read is that a log you self-host doesn’t prove much, since you control the database, and third-party custody is the only part of this genuinely worth paying someone else for. But I’ve been wrong about what people want before.
Happy to compare notes on the write-path issuer question, I haven’t solved that one either. I’ve got a working implementation of most of the rest if it’s useful to have something to poke at while you build.
The boring JWT design is the part I would keep. A short-lived token with sub, agent_id, aud, scope, exp, and jti gives you revocation of one agent without rotating every client the user has. Two checks from the MCP authorization work are worth making explicit. Bind the audience to the MCP server that should accept the token, and reject a token minted for a different resource. The official security best practices spend a lot of time on confused deputy and token misuse when a proxy sits between clients and a third-party API, and a missing audience check is how that starts. I would also keep writes on a live revocation check, as you already suggest, and I would not let the model request a scope upgrade on its own. A prompt injection that can talk the agent into calling a tool can often also talk it into asking for a broader scope. Scope changes should be a user or operator action, recorded with the agent_id that will receive them.