Nick George — AI Agents & Automation
Open source · gatehouse-issuer

Give the agent a pass of its own. Not the user's.

gatehouse-issuer hands out tokens. A token is a pass: it says who someone is and what they're allowed to do, and it stops working after five minutes. Your apps and MCP servers check each pass themselves, without asking the issuer. They can check a pass, but none of them can make one.

pip install "gatehouse-issuer[server]"

Open sourceMITPython 3.10+JS checker on npmv0.1.0

How gatehouse-issuer works: alice signs in to your app, whose token is good only at your agent backend. The agent backend trades it at the issuer for a token of its own: good only at one MCP server, limited to what alice and the agent both may do, and gone in 5 minutes. The MCP server checks it offline. The steps below walk through it.
The agent trades alice's pass for one of its own: good only at one MCP server, for what alice and the agent may both do, and gone in five minutes. The MCP server checks it offline, with the issuer's public keys. Only the issuer holds the key that makes passes.
Nick George, Charlotte, NC

Why I built it

The easy way is to hand the agent the user's own pass.

An AI agent working for someone needs to call tools. The quickest way to let it is to give it that person's login. Then one bad instruction hidden in an email or a web page, a prompt injection, can make the agent do anything the person can do.

mcp-gatehouse, my other open-source library, decides each call inside an MCP server: is this order the caller's, and may it be cancelled? It reads who the caller is from their pass. It never said where that pass should come from, or what should be in it.

gatehouse-issuer is where it comes from. The agent gets a pass of its own that works at one MCP server and nowhere else, allows only what the user and the agent are both allowed to do, and stops working after five minutes. For the risky actions, like cancelling an order, the user has to say so themselves. The agent can't say it for them.

It also works with anything else that checks JWTs, the standard kind of signed token, so you don't need mcp-gatehouse to use it. And the code is public, so if you're thinking about letting me connect AI to your business, your technical people can read exactly how the passes are made before we talk.

Nick George · Charlotte, NC

How it works

Four steps, two passes.

The user's pass and the agent's pass are made for different places. Each one is turned away everywhere else.

  1. 01

    The user signs in to your app.

    With the sign-in you already use: Firebase, Auth0, Google, Keycloak, or any other OpenID Connect provider. Your app trades that sign-in at the issuer for a pass. The pass works only at your agent backend, and lasts five minutes. Your app also gets a refresh token for the next pass, and keeps it to itself.

  2. 02

    Your app hands the agent backend that pass.

    It goes along with the task the agent is doing for the user.

  3. 03

    The agent backend trades it for a pass of its own.

    It proves who it is by signing the request with its own private key. The issuer holds only the public half.

  4. 04

    The agent calls the MCP server with its own pass.

    The MCP server checks it with the issuer's public keys, without calling the issuer. The user's own pass is no use there: it's turned away, because it was made for the agent backend.

Everything on the wire is a published standard: JWT access tokens checked against a JWKS, OAuth token exchange for the agent's trade, and a resource indicator naming the server on every request. The full list is below.

Agents

A new pass for every task, never wider than the user's.

The agent backend gets the user's pass, made for the agent's own address, and trades it for a new one for each task. It signs the trade with its own private key.

from gatehouse_issuer.client import TokenClient, load_private_key

issuer = TokenClient("https://auth.example.com", client_id="support-bot",
                     private_key=load_private_key("support-bot.pem"))
token = issuer.exchange_for_agent(user_token, resource="https://mcp.example.com")

The agent's pass

  • works only at the MCP server it asked for (aud);
  • names the agent, in client_id and in act, so the logs say “for alice via support-bot”;
  • allows what the user may do, cut down to the agent's ceiling, and cut down again by any pin;
  • belongs to the user's sign-in session, so once you revoke the user, the agent's next trade is refused;
  • stops working when the user's pass does, or after five minutes, whichever comes first. It comes with no refresh token.

Before it trades, the issuer checks the agent's signature, that the user's pass is real and was made for this agent, that it doesn't already name an agent (so agents can't chain), that the user's session is still open, and that the MCP server asked for is on the agent's list.

Pins, and who sets them

A pin narrows a pass to named records and actions: cancel order 4418, and nothing else. An agent can pin its own pass, which limits the harm if it leaks. But when a model drives the agent, a pin the agent picks is whatever the model decided, and a tricked model picks the wrong record. So for the actions that matter, the user sets the pin, through your app:

# In your app, when the user picks "cancel order 4418":
front_end = TokenClient("https://auth.example.com", client_id="web")
picked = front_end.refresh(refresh_token, resource="https://agent.example.com",
                           authorization_details=[{"type": "order", "identifier": "4418", "actions": ["cancel"]}])
# Keep picked.refresh_token. Hand picked.access_token to the agent, with the task.

Only your app holds the refresh token, so the agent can't make the user's pin itself. In the agent's config, needs_user_pin lists what it may do only on a pass the user pinned. Without that pin, those actions are cut, whatever the agent pins itself:

agents:
  support-bot:
    ceiling: ["order.own.read", "order.own.note", "order.own.cancel"]
    needs_user_pin: ["order.*.cancel"]   # cut, unless the user pinned the token

See an agent do it

The repo's examples/order_desk_http puts an agent backend in front of mcp-gatehouse's demo order desk. alice's own pass is turned away with a 401. The first cancel uses a pass the agent pinned to order 4417 itself, as a tricked model might, and gets no cancel at all. The last three use the pass alice's app pinned to 4418: cancelling 4417 is refused, reading is refused (the pin allows only cancelling), and cancelling 4418 goes through. Both logs share the pass's ID, so you can match them up.

alice's own token, sent straight to the order desk: HTTP 401 (it was minted for the agent)

The order desk's audit log (mcp-gatehouse), one line per call:
  list_orders   ok      for 'alice' via 'support-bot'
  lookup_order  ok      for 'alice' via 'support-bot'
  add_note      ok      for 'alice' via 'support-bot'
  lookup_order  denied  for 'alice' via 'support-bot'  policy: has order.own.read; order 4420 belongs to someone else
  cancel_order  denied  for 'alice' via 'support-bot'  policy: no grant for order.own.cancel
  cancel_order  denied  for 'alice' via 'support-bot'  policy: token is pinned to order 4418; this is order 4417
  lookup_order  denied  for 'alice' via 'support-bot'  policy: no grant for order.own.read
  cancel_order  ok      for 'alice' via 'support-bot'

The issuer's audit log:
  token_issued    sub='alice' client='web'
  token_issued    sub='alice' client='web' pinned=[{"type": "order", "identifier": "4418", "actions": ["cancel"]}]
  token_exchanged sub='alice' client='support-bot' act='agent:support-bot' for client 'web' cut=["order.*.cancel"] (needs the user's pin)
  token_exchanged sub='alice' client='support-bot' act='agent:support-bot' for client 'web' pinned by agent=[{"type": "order", "identifier": "4417", "actions": ["cancel"]}] cut=["order.*.cancel"] (needs the user's pin)
  token_exchanged sub='alice' client='support-bot' act='agent:support-bot' for client 'web' pinned by user=[{"type": "order", "identifier": "4418", "actions": ["cancel"]}]

Five-minute quickstart

Run an issuer, sign in alice, check her pass.

Dev mode uses a pretend sign-in provider, so there's nothing to sign up for. init writes a config with one app, one MCP server and one user, alice, and never writes over a file that's already there.

pip install "gatehouse-issuer[server]"
gatehouse-issuer init          # writes issuer.yaml: one app, one MCP server, one user (alice)
gatehouse-issuer serve --dev   # a pretend sign-in provider; nothing to sign up for

# in a second terminal
export ACCESS_TOKEN=$(gatehouse-issuer dev token alice@dev --dev)

Any service can check the pass with only the issuer's address. It needs no secrets:

import os

from gatehouse_issuer import TokenValidator

validator = TokenValidator("http://localhost:8000", "http://localhost:9000/mcp", dev=True)
token = validator.verify(os.environ["ACCESS_TOKEN"])
print(token.subject, token.client_id, token.perms.allows("order.own.cancel"))   # alice web True

dev=True is there because a dev issuer marks every pass as a dev pass, and checkers turn those away unless they're in dev mode too. After five minutes, verify raises InvalidToken("expired"). The README's last step puts the issuer in front of a small MCP server behind mcp-gatehouse, where alice reads her own order without its cost and is refused someone else's.

The full quickstart on GitHub ↗

Two more ways in

MCP clients and services get passes too.

MCP clients sign the user in

Claude Code, Cursor and other MCP clients find the issuer through your MCP server's metadata and sign the user in with OAuth's authorization code flow and PKCE. The user sees a page that names the client, where it will send them back to, and what its passes could do. The client's pass holds only the scopes they agreed to, and names the client in act, so a policy can refuse it outright. Your own app, marked first_party, skips the consent page.

Services call services

A nightly job that isn't working for anyone gets a pass for itself. It proves who it is with its own key, the pass names the service as its sub, and there's no refresh token. gatehouse-issuer client-key makes the key pair and prints the public half for the config.

To check that your MCP server and the issuer agree, gatehouse-issuer check-resource https://mcp.example.com/mcp checks the resource, the issuer, the audience, PKCE, and that every scope has a ceiling.

Permissions

Small words for who may do what.

A permission is written resource.scope.action, with an optional field. order.own.read reads your own orders, -order.own.read.cost hides what they cost, and invoice.org.* does anything with your org's invoices. Members get them through groups and permission sets in the config, or from the admin portal.

Scopes say whose records

own is yours, org is your org's, any is anyone's, and each covers the ones inside it. A pass can't know who owns a record, so the check looks at the record your loader returned.

A denial always wins

A permission starting with - beats any grant, at its scope and every narrower one. Denied fields are left out of what redact returns.

Typos fail loudly

List your resources in a catalog, and a pattern naming a resource, action or field that isn't there is refused when the config loads, so -ordr.own.read.cost can't quietly deny nothing. One pattern that doesn't parse spoils the whole pass.

A spec, with test cases

The permission language and the pass format are written up in the repo's spec/, with the test cases a version in another language must pass. The JavaScript checker passes the token test cases, makes the same checks in the same order and gives the same reasons.

You don't have to write the catalog by hand: gatehouse-issuer policy schema reads your database's tables and prints them as resources.

Standards it uses

Any JWT library can check the passes.

Everything on the wire is a published standard. Passes are ES256 only: no none, no shared secret, so a checker can never forge one.

The standards gatehouse-issuer implements
StandardWhat it's for
RFC 9068JWT access tokens, checked with keys from a JWKS
RFC 8414OAuth authorization server metadata
OAuth 2.1 + RFC 7636authorization code flow with PKCE, for MCP clients
RFC 9207iss in the authorization response
RFC 8693token exchange, for agents
RFC 8707resource indicators: every request names its server
RFC 7523private_key_jwt, for agents and services
RFC 7009 + 7662revocation and introspection

Two optional features need more than a JWT library: permission sets by reference, and the revocation list for strict mode. Both are signed or hash-pinned JSON, described in the repo's spec/tokens.md.

Design choices

One place makes passes. Everything else only checks.

With a shared secret, every service that can check a token can also forge one. Here only the issuer holds the private key. Checkers fetch the public keys and hold no secret at all, so no service can make a pass, however compromised it is.

It fails closed. A checker with no audience refuses to start. A pass with the wrong algorithm, type, issuer, audience or lifetime is refused, and so is one with a single permission that doesn't parse. And it never puts a pass in a log.

The parts that keep a pass safe are about 3,000 of the package's 15,100 lines, and the README lists the eight files to read first if you're reviewing it for security.

What it isn't, or doesn't do yet

  • A sign-in provider. Your users still sign in with Firebase, Auth0, Google, Keycloak or any OpenID Connect provider. The issuer decides what they get once they've signed in.
  • Dynamic client registration. It isn't planned, because the MCP spec dropped it. MCP clients bring a Client ID Metadata Document, or you list them in the config.
  • AWS KMS or Vault Transit for keys. Keys live in a file or in Google Cloud KMS. Others would plug into the same interface, when someone needs them.
  • Instant revocation by default. Revoking a session stops its refreshes and trades at once, but passes already out work for up to five minutes. Strict mode closes that gap for the services that can't wait.

0.1.0 is the first release, and PyPI lists it as alpha. The JS checker needs Node 22.12 or newer, and is tested on Deno, Bun and Cloudflare's workerd too. If you find a security problem, email nick@nickgeorgeai.com instead of opening a public issue. You'll hear back within 72 hours.

gatehouse-issuer on PyPI ↗The JS checker on npm ↗SECURITY.md ↗

Common questions

Questions about gatehouse-issuer.

Is gatehouse-issuer free?

Yes. It's open source under the MIT license. The issuer installs with pip install "gatehouse-issuer[server]" and needs Python 3.10 or newer. The checker alone, for any Python service, is pip install gatehouse-issuer, and its only dependency is PyJWT. For JavaScript or TypeScript, the checker is on npm as gatehouse-issuer, with no dependencies.

Do I need mcp-gatehouse to use it?

No. It's built for mcp-gatehouse, which decides each call inside your MCP server and reads who the caller is from their pass. But the passes are standard JWT access tokens (RFC 9068), so anything that checks JWTs can check them. The gatehouse extra adds the adapter for mcp-gatehouse.

Does it replace Firebase, Auth0 or my sign-in provider?

No. Your sign-in provider still says who signed in: Firebase, Auth0, Google, Keycloak or any other OpenID Connect provider. The issuer decides what that person gets. Your app trades the sign-in at the issuer for a short pass, and signing in isn't enough on its own: the user has to be a member, or join as one under rules you set.

Why not just give the agent the user's own token?

Because then one bad instruction hidden in an email or a web page, a prompt injection, can make the agent do anything the user can do. gatehouse-issuer gives the agent a pass of its own instead. It works at one MCP server and nowhere else, allows only what the user and the agent are both allowed to do, and stops working after five minutes.

Can an agent give itself more access?

No. An agent's pass is the user's permissions cut down to the agent's ceiling, and it can only be cut down further. An agent may pin its own pass to narrow it, but never widen it. For the actions that matter, like cancelling an order, you can require the user's own pin, set through your app with a refresh token only your app holds. Without it, those actions are cut from the agent's pass.

Can Claude Code or Cursor sign in to it?

Yes. MCP clients find the issuer through the MCP server's metadata and sign the user in with OAuth's authorization code flow and PKCE. A client that isn't yours gets the user's permissions cut down to the scopes the user agreed to on a consent page, and its pass names it, so a policy can refuse it outright. Clients identify themselves with a Client ID Metadata Document or are listed in the config. Dynamic client registration isn't supported, because the MCP spec dropped it.

How does a service check a pass?

Offline, with only the issuer's address. It fetches the issuer's public keys from its JWKS and checks the signature, the issuer, the audience and the lifetime itself, with no call to the issuer and no secret to hold. Passes are ES256 only, so no service can make one, however compromised it is.

What happens when I revoke a user?

Revoking a sign-in session stops its refreshes and an agent's next trade at once. Passes already handed out stop working within five minutes. If you need them stopped sooner, strict mode has services check a signed revocation list as well.

Where do the signing keys live?

In a key file, or in Google Cloud KMS, where the private key never leaves KMS. Either way, keys rotate on a schedule: a new key is published before it signs anything. Sessions and members can live in Postgres, shared across replicas. AWS KMS and Vault Transit aren't supported yet; they would plug into the same key interface.

The gate the passes are made for: mcp-gatehouse, permissions and audit logs for MCP servers →

Testing an agent before it gets near real data? fieldtwin, my open-source Jobber and QuickBooks twins →

Want agents working for your users?

I build agents that carry their own pass.

If you want AI agents working in your CRM, your books or your order system on your people's behalf, and you want each one limited to what that person may do, that's the work I do.

MCP server development →

New to MCP? The plain-English guide →