pub fn mcp() -> AuthLayerExpand description
Middleware that protects an MCP route, for any tower stack: axum, tonic or hyper.
AI clients sign users in through Stackure and send the credential it issues
as Authorization: Bearer. The layer checks that credential against
Stackure on every request, with the same app secret as auth; cookies
are ignored. On success the user is inserted into the request extensions,
exactly as auth does. Every other answer is JSON, never a redirect and
never a cookie: 401 with the WWW-Authenticate challenge from Stackure
when not signed in, 503 when the check itself fails.
The MCP endpoint must be served from the same site as the app’s registered URL unless an MCP URL is set for the app in Stackure.
§Example
let app = app.layer(stackure::mcp());