Accepting tokens
Configure your identity provider inbijection/auth.config.ts as usual, for
example as a custom JWT provider. Then tell the
endpoint which resource it is and which authorization servers issue its tokens:
bijection/mcp.ts
resourceidentifies this endpoint. Use your deployment’s.bijection.siteURL. Browser requests whoseOrigindiffers from the resource’s origin are refused with403 origin_refused.authorization_serverslists the issuers your clients get tokens from. At least one is required.
https:// URLs without credentials, a query string or a fragment.
Plain http:// is accepted only for localhost, 127.0.0.1 and [::1], so you
can develop locally.
Clients send the token in the Authorization header:
401 authentication_required with a
WWW-Authenticate header that points to the endpoint’s OAuth protected-resource
metadata:
metadata HTTP action you mounted at that path returns:
Grants
A valid token isn’t enough on its own. Yourauthorize query returns the grant
for the calling identity, and the endpoint accepts the request only when:
- the caller is authenticated,
- the grant’s
principalequals the caller’stokenIdentifier, - the grant’s
audienceequals the endpoint’sresource, - the grant has a non-empty
id, and - the grant’s
expires_at(milliseconds since the epoch) is in the future.
403 access_refused. The grant’s tools list is an
allowlist: tools/list shows only the published tools named in it, and calls to
any other tool fail with tool_unavailable. Publishing a new tool grants
nothing until you add it to a grant.
The full grant shape is the McpGrant type:
id, principal, audience, expires_at and
tools. organization, application and customer are yours to define and
use, for example in your admission limits or access rules.
Storing grants
Keep grants in a table your app owns:bijection/schema.ts
bijection/mcp.ts
Issuing grants
Issue one principal for each agent interaction you want to authorize, write its grant, and give the agent’s host three things: the endpoint URL, a way to obtain that principal’s token, and the grantid. Clients that call operation tools
must send the grant id with each call; a call made under a different grant
fails with request_scope_mismatch.
To revoke access, delete the grant, shorten its expires_at or remove tools from
its allowlist. A token refresh doesn’t change the grant, since the principal
stays the same.
When grants are checked
The grant is checked when the request arrives, again inside the transaction that runs each tool call, and once more before the response is released. If a grant is revoked or expires while a request is running, the response is withheld and the client receives403 request_refused.
Revocation fences future work only. An operation that was already accepted stays
accepted, and an external call it already made is not undone.