Test mode: paid plans aren't on sale yet, so nothing is charged. Every plan's limits apply.

← Docs

MCP servers and AI assistants

An MCP server (the Model Context Protocol, how assistants such as ChatGPT and Claude call tools) protects its tools with OAuth: the assistant signs the person in at an authorization server and calls the tools with the access token. Nod is that authorization server. Everything MCP's authorization spec asks of one is built: metadata where clients look, registration by the client itself, sign-in with PKCE, consent for an app the realm doesn't run, and tokens for the MCP server only.

Setting it up

# Assistants may register themselves; each is a third-party app, so people are asked first.
nod realm set acme --open-registration on
# The MCP server, as an API: its address is the resource tokens are for; its scopes are its permissions.
nod api register acme https://mcp.acme.example/mcp --scope orders:read --scope orders:refund --name "Acme MCP"
# Who may do what there: roles grant the scopes.
nod role create acme support
nod role grant acme support https://mcp.acme.example/mcp --scope orders:read
nod user role acme ana support

The MCP server answers a request without a token with 401 and WWW-Authenticate: Bearer resource_metadata="…", pointing at its protected resource metadata (RFC 9728), which names https://auth.acme.example/acme as its authorization server. It checks each token's signature against the realm's JWKS, its issuer, and that its audience is the MCP server's address. SocketLLM's MCP door does all of this (its docs).

An MCP server in front of an API you already have

When the MCP server's tools call an API that already has its own identifier (urn:orders:api) and grants, don't register the MCP server as a second API. Give the API an alias at the MCP server's address instead:

nod api alias acme urn:orders:api --add https://mcp.acme.example/mcp

A token asked for resource=https://mcp.acme.example/mcp is then the API's (its grants, scopes, permissions and lifetime) with the MCP server's address alone as aud. The MCP server's metadata names that address as its resource, and the server accepts that audience only for calls made through it, so the token is no good at the API directly. Aliases are exact https URLs, at most 10 per API, unique in the realm; --remove URL takes one away, and the command with neither flag lists them. kit-mcp servers do this when their metadata's resource is their own URL (kit docs/mcp.md).

What the assistant does

  1. Reads the MCP server's metadata, then Nod's: /.well-known/oauth-authorization-server/acme (RFC 8414, the issuer's path inserted), which lists registration_endpoint, the endpoints and code_challenge_methods_supported (S256).
  2. Registers itself at POST <issuer>/register (RFC 7591), usually as a public client with a loopback or https redirect. It's always a third-party app, can only sign people in, and can't name a URL Nod would fetch (Apps that register themselves).
  3. Signs the person in with the authorization code flow, PKCE (S256) and resource=https://mcp.acme.example/mcp (RFC 8707). Nod shows its consent page: the assistant's name and what it asks for, as text. Allow or Deny; prompt=consent asks again.
  4. Gets a token for the MCP server only: its audience is the resource, and its scopes are what the person's roles allow there, whatever the assistant asked for. A token for the MCP server can't be used at another API.
  5. Calls the tools. The MCP server never passes the token on to the app behind it (MCP forbids token passthrough).

People see each assistant under Apps with access on their account page, and Remove access takes its tokens and the consent back at once. Administrators see every registered app in the management API ("registered": true) and can delete one.

Proof

SocketLLM's tests/with_harpora.rs runs this whole path against a real Nod: the assistant starts with only the MCP server's address, finds Nod, registers, signs a person in through the consent page with PKCE and the resource, gets a token carrying only what her role allows, and calls a tool as her.

Nod's own MCP server

Each realm also serves its management API as MCP tools at <issuer>/mcp: free tools that read, limits tools that change things within the API's rules, nod tools that need a person's approval, and two views (view_realm, view_nod) for MCP Apps hosts. See Management API: for agents and Nod.

With serve --nod, three limits tools can need a nod too, when their route asks for one: waitlist_admit past the day's 25 admissions, user_block past the hour's 5 blocks (both per caller), and client_update_redirects when the list adds an origin the client doesn't use yet. Each takes an optional approval argument, sent to the API as the Nod-Approval header, as the nod tools do. Called without one when it's needed, the tool fails with the challenge as JSON on the error's last line ({"nod": <issuer>, "authorization_details": [...]}); ask for exactly that (CIBA bc-authorize at that issuer), and once a person approves, call the tool again with the same arguments and the token as approval. An approval is good for that action, once. Within limits the argument isn't needed.

Its protected resource metadata names the MCP server itself as the resource: <issuer>/mcp, the URL the metadata's address comes from (RFC 9728 §3.3), so clients that check it accept it. Ask for a token with resource=<issuer>/mcp: Nod treats that address as an alias of the realm's management API (<issuer>/api), so the token carries the management scopes the client was granted there (or, on a person's behalf, what the person holds), with the MCP URL as its audience. Such a token works only through the MCP tools; the management API over HTTP refuses it. A token for the management API itself keeps working at MCP, as before. The tools call the API as the caller, so it's the same power either way, and nothing outside Nod sees the token. The alias covers machine tokens (client_credentials) and on-behalf-of tokens (token exchange), the two kinds the management API accepts.

It covers a person's sign-in too, the way assistants such as Claude connect: the authorization code flow with PKCE and resource=<issuer>/mcp at /authorize (or resource at device_authorization, for the device flow). The token's audience is the MCP URL alone when the token request names it, or beside the issuer when it doesn't, as for any API; its scopes are the management scopes asked for that the person's roles allow, and its permissions theirs there. A refresh keeps the MCP audience (the grant is for the MCP URL; asking a refresh for <issuer>/api is invalid_target). Any other resource that isn't one of the realm's APIs, another realm's MCP URL included, is still invalid_target.

A person's token never does more at MCP than their token for the API would. A person's own token (no act) manages no realm, for either audience: the tools refuse it with 401 ("a person's own token can't manage the realm"), whatever roles they hold. The one person's token that works is an org member's console token (from the accounts realm, for its accounts API) at a realm their org owns, as far as their org role goes (a member reads, an admin changes all but the realm's own settings, an owner everything), at the API and through MCP alike. An org member's sign-in for an MCP URL is an ordinary person's token of that realm, so it manages nothing either. An assistant acting for a person in a realm uses token exchange: its on-behalf-of token for the MCP URL carries what the person holds and its own grant allows.