The quickest way to connect an agent to internal systems is one service account with access to everything. It's also how a single prompt injection turns into a breach. The agent can do whatever the account can do, and the audit log can't tell you who asked.
The rule I build MCP servers to: an agent can only do what the person asking could do. For Hive Mind, the MCP server I'm building at Barclays, that means OAuth 2.1 with PKCE against the company's SSO, and short-lived per-user tokens carried end to end.
Try both
Pick a user and call the tools. Then switch to the shared service account and call them again. Watch what the intern can reach, and what the audit log says.
get_price
Latest price for a ticker. Needs prices:read.
Runs
It runs with Trader's own permissions.
get_positions
The desk's open positions. Needs positions:read.
Runs
It runs with Trader's own permissions.
search_research
Search internal research notes. Needs research:read.
Denied
Trader has no research:read scope, so the server refuses the call.
place_order
Send an order to the market. Needs orders:write.
Waits for approval
It changes state, so it waits for a person to approve it.
Audit log
Call a tool to write the first entry.
How the client gets a per-user token (OAuth 2.1 with PKCE)
- The client makes a random code_verifier and sends only its SHA-256 hash (the code_challenge).
- The user signs in with the company's SSO and agrees to the scopes the client asked for.
- The identity provider redirects back with a one-time authorization code.
- The client swaps the code plus the original code_verifier for an access token. A stolen code is useless without the verifier.
- The token names the user, carries only their scopes and expires in 15 minutes. The MCP server checks it on every tool call.
What the per-user token buys you
- The caller's own entitlements. The token carries the user's scopes, so the server refuses a call the user couldn't make themselves. No tool has to re-implement permissions.
- Least privilege per tool. Each tool declares the one scope it needs. A read tool never needs write access.
- Short lives. A token that expires in minutes limits the damage if it leaks. A service account secret that never expires doesn't.
- An audit trail with names in it. Every call records who asked, which tool ran, the arguments and the result.
Why PKCE
An agent client often can't keep a secret, because it runs on a laptop or in a browser. PKCE lets it prove that the client which started the sign-in is the same one swapping the code for a token, without a stored secret. A stolen authorization code is useless on its own.
State-changing calls still wait
A valid token isn't permission to act. Read-only tools run freely, and anything that changes state still stops at a human approval gate. The tool gate playground shows that half of the design.
I used the same pattern for the public side of Social Line: OAuth 2.0 and scoped API keys, so customers' own agents drive the product through the same service layer as the dashboard. You can also try this demo on its own in the lab.