DEV Community

Dimitris Kyrkos
Dimitris Kyrkos

Posted on

MCP didn't give your agent permission. It gave it a phone book.

Wiring a tool into an AI app used to mean custom glue code. With the Model Context Protocol (MCP), a client can discover what a server offers, read the schemas, and start calling things. It's a real improvement.

It also makes one mistake very easy: treating "the agent can call it" as "the agent is allowed to call it."

Interoperability is not authorization.

The demo vs. the second user

In the demo there's one user, one tenant, and one API key with access to everything. Every call that works is a call that should have worked.

Then a second user shows up, and questions that had no meaning in the demo start to matter. Who is this call for? Which tenant does that record belong to? Does this action need someone's approval?

A tool schema answers none of them:

{
  "name": "delete_invoice",
  "description": "Deletes an invoice by ID. Admins only.",
  "inputSchema": {
    "type": "object",
    "properties": { "invoice_id": { "type": "string" } },
    "required": ["invoice_id"]
  }
}
Enter fullscreen mode Exit fullscreen mode

"Admins only" is a sentence. Nothing in that schema enforces it. The scenarios below are illustrative, but each one starts with a schema that looks about like this.

1. The server knows the agent, not the user

The server connects to the database with a service account. Dana, a read-only analyst, asks the assistant to clean up old invoices. The server sees a valid call from a trusted service account and deletes them.

Nobody bypassed a check. The server had no idea Dana existed.

2. The model picks the tenant

@tool
def get_invoices(tenant_id: str):
    return db.invoices.find(tenant_id=tenant_id)
Enter fullscreen mode Exit fullscreen mode

If tenant_id is a tool argument, the model fills it in. It might take it from the conversation, from a document it just read, or from a prompt injection hidden in that document. Tenant scope should come from the authenticated session, where the model can't edit it.

3. One credential for every tool

The integration token was created with full scope because that was quicker. Now the "search invoices" tool carries a credential that can also delete them, and a bug in the harmless tool has the reach of the dangerous one.

4. The confirmation is a chat message

The agent asks "Should I go ahead?" and the model decides whether the reply counts as a yes. That's a conversation, not an approval. A real one is recorded outside the model and tied to the exact action and arguments.

What the spec says

The MCP specification is fairly direct about this:

  • Authorization is optional for MCP implementations.
  • Servers that implement it must validate that access tokens were issued for them.
  • Servers must validate tool inputs and implement proper access controls, according to the tools page.
  • Clients must treat tool annotations as untrusted unless they come from a trusted server.

Even a valid token only gets you so far. It can tell you who is calling and with what scope. Whether that caller may delete this invoice is still your application's rule.

What enforcement looks like

def delete_invoice(invoice_id: str, *, ctx):
    # ctx comes from the verified session, never from model arguments
    if "invoices:delete" not in ctx.scopes:
        raise PermissionDenied("missing scope")

    invoice = db.invoices.get(id=invoice_id, tenant_id=ctx.tenant_id)
    if invoice is None:
        raise NotFound()

    if not policy.allows(ctx.user, "delete", invoice):
        raise PermissionDenied("not allowed for this user")

    if not approvals.consume(ctx.user, "delete_invoice", invoice_id):
        return approvals.request(ctx.user, "delete_invoice", invoice_id)

    return db.invoices.delete(invoice.id, tenant_id=ctx.tenant_id)
Enter fullscreen mode Exit fullscreen mode

Four habits are doing the work here:

  • Identity and scope travel with the request. The server knows which user it's acting for.
  • Permissions are checked on the server. Hiding a tool from the model is good UX, but it isn't a control.
  • Credentials are narrow. The search tool can't delete.
  • High-impact actions need confirmation that the model can't grant itself.

Then test it without the model. Call the tool directly as the wrong user, in the wrong tenant, with no approval. If any of those calls succeed, no prompt will save you.

The reframe

A tool call is an HTTP request with a very unpredictable client. We already know how to handle those: authenticate the caller, authorize the action, and trust nothing in the body.

If you took the model out and sent your tool servers raw requests, which of your permission checks would still be standing?

Top comments (3)

Collapse
 
forexnewsradar profile image
ForexNewsRadar •

The phone book framing is exactly right. In automated trading, one MCP server exposing 50 read/write tools inflates the context window and gives the agent a blast radius that is hard to reason about.

In production we keep a tiny read-only 5-tool risk gate in front of execution and expose zero write tools on that server. It returns deterministic fail-closed booleans like allowed_to_open_trade: false whenever inputs are malformed or upstream state goes stale, so the agent cannot talk itself past the gate.

Collapse
 
speedrunjaen profile image
Jaen Carrodine •

the directories push the read/write split too. anthropic's connector review rejects one tool that takes both safe and unsafe methods, and openai wants readOnlyHint and destructiveHint set explicitly on every tool. we had a sql tool doing reads and writes in one call, and that's the tool we expect a reviewer to flag first

Collapse
 
smtahosin profile image
S M Tahosin •

Hey Dimitris! second user thing lol. I demoed an MCP server on one token, teammate asked 'can it delete'... yea it could. Testing as the wrong user, stealing that :)