Expand description
Bearer-token authentication for the MCP endpoint.
Separate from the Admin API’s Basic Auth on purpose: an agent gets a
narrower credential (read or write) that is useless on /api/*, and
the Admin credentials are useless here. The token is resolved on every
request (never cached on the MCP session) so a client cannot keep a scope
it no longer presents.
Structs§
- McpAuth
State - Configured tokens, ready for constant-time lookup.
- McpPrincipal
- The identity behind an authenticated MCP request.
Enums§
- Auth
Failure - Why a request was refused. Deliberately coarse: callers must not leak whether a token was unknown, malformed, or absent.
Functions§
- authenticate
authenticate_forwith the authority taken from theHostheader.- authenticate_
for - Resolves the principal for a request from its headers, taking the request
authority (
Host, or the HTTP/2:authority) fromauthority. - bearer_
middleware - axum middleware for the MCP path: authenticates, then stores the
McpPrincipalin request extensions for the server handler to read. - origin_
authority 🔒 - Extracts
host[:port]from anOriginvalue such ashttps://a.b:9091.