fastmcp.server.middleware.authorization
Authorization middleware for FastMCP.
This module provides middleware-based authorization using callable auth checks.
AuthMiddleware applies auth checks globally to all components on the server.
Example:
Classes
AuthMiddleware
Global authorization middleware using callable checks.
This middleware applies auth checks to all components (tools, resources,
prompts) on the server. It uses the same callable API as component-level
auth checks.
The middleware:
- Filters tools/resources/prompts from list responses based on auth checks
- Checks auth before tool execution, resource read, and prompt render
- Skips all auth checks for STDIO transport (no OAuth concept)
auth: A single auth check function or list of check functions. All checks must pass for authorization to succeed (AND logic).

