Allow AuthCheck to inspect invocation details for resource-level authorization
Author: dgenioCreated Aug 24, 2026Updated Sep 16, 2026
Labelsenhancementauthtoo-long
Enhancement
AuthCheck can decide whether a caller may use a tool, but it cannot authorize the specific resource referenced by a tool invocation.
For example:
from fastmcp import FastMCP
from fastmcp.server.auth import AuthContext
mcp = FastMCP("demo")
def authorize_invoice(ctx: AuthContext) -> bool:
account_id = ctx.token.claims["account_id"]
# Need the invoice_id from this invocation here
# to check whether it belongs to account_id.
return ???
@mcp.tool(auth=authorize_invoice)
def get_invoice(invoice_id: str) -> str:
return invoice_idAuthContext exposes the token and component, but not the arguments of the current invocation.
Expected: the auth check can authorize the requested invoice_id before the tool runs.
Actual: resource-level authorization has to be implemented inside the tool or separately in middleware.
Source: PrefectHQ/fastmcp