Routes & well-known endpoints
RFC 8414 / RFC 9728 metadata endpoints and Dynamic Client Registration façade.
auth_routes
mcpauthkit.auth_routes — generic MCP OAuth metadata endpoints.
Provides the well-known OAuth protected-resource and authorization-server discovery documents required by the MCP OAuth spec, plus a Dynamic Client Registration (DCR) façade that returns a pre-registered public client ID.
Works with any standard OIDC provider (Keycloak, Okta, Entra ID, Duende, …).
Usage
from mcpauthkit.auth_routes import oauth_meta_router
app.include_router(oauth_meta_router(
server_base_url="http://localhost:8005",
issuer_url="http://localhost:8889/realms/mcp-quickstart",
client_id="mcp-quickstart-vscode",
))
Call include_router before app.mount("/", ...).
oauth_meta_router
oauth_meta_router(
*, server_base_url: str, issuer_url: str, client_id: str
) -> APIRouter
Return an APIRouter with well-known OAuth metadata routes and a DCR
façade. Mount it on the app with app.include_router(...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_base_url
|
str
|
Full URL of this MCP server, e.g. |
required |
issuer_url
|
str
|
Base URL of the OIDC issuer,
e.g. |
required |
client_id
|
str
|
Pre-registered public client ID returned by the DCR façade. |
required |
Source code in mcpauthkit/auth_routes.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |