Documentation Index
Fetch the complete documentation index at: https://gofastmcp.com/llms.txt
Use this file to discover all available pages before exploring further.
fastmcp.server.auth.handlers.authorize
Enhanced authorization handler with improved error responses.
This module provides an enhanced authorization handler that wraps the MCP SDK’s
AuthorizationHandler to provide better error messages when clients attempt to
authorize with unregistered client IDs.
The enhancement adds:
- Content negotiation: HTML for browsers, JSON for API clients
- Enhanced JSON responses with registration endpoint hints
- Styled HTML error pages with registration links/forms
- Link headers pointing to registration endpoints
Functions
create_unregistered_client_html
client_id: The unregistered client ID that was providedregistration_endpoint: URL of the registration endpointdiscovery_endpoint: URL of the OAuth metadata discovery endpointserver_name: Optional server name for brandingserver_icon_url: Optional server icon URLtitle: Page title
- HTML string for the error page
Classes
AuthorizationHandler
Authorization handler with enhanced error responses for unregistered clients.
This handler extends the MCP SDK’s AuthorizationHandler to provide better UX
when clients attempt to authorize without being registered. It implements
content negotiation to return:
- HTML error pages for browser requests
- Enhanced JSON with registration hints for API clients
- Link headers pointing to registration endpoints
handle
request: The authorization request
- Response (redirect on success, error response on failure)

