OAuth 2.1/OIDC resource-server reference for secure MCP authorization
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
A production-oriented OAuth 2.1 resource-server reference for remote MCP: Microsoft Entra ID and generic OIDC, exact token/resource validation, fail-closed authorization, progressive scope challenges, stateless MCP
2026-07-28, and metadata-only OpenTelemetry evidence.
Use this repository when the hard part is not "how do I expose an MCP tool?" but how do I expose
it without weakening identity, authorization, transport, and observability boundaries. The server
pairs with mcp-client-auth-template for
an executable end-to-end reference using synthetic identities and no production credentials.
The paired executable path validates real resource-server behavior rather than configuration claims:
403 insufficient_scope is returned before dispatch for progressive authorization4012026-07-28 stays stateless and does not mint Mcp-Session-IdFor a requirement-by-requirement view of the paired OAuth/MCP behavior, including explicit evidence gaps and discussion topics for the MCP Authorization Interest Group / Tool Scopes Working Group, see the Authorization Implementer Report.
The authorization server owns login, consent, client registration and token issuance. This repository owns the protected resource: transport admission, metadata publication, access-token verification, request-scoped principal construction, tool authorization and dispatch.
For layer boundaries and the detailed authorization sequence, see Architecture.
The companion client owns the executable cross-repository reference flow. With both repositories cloned as siblings, verify this server directly from source:
The flow starts the real server from this checkout plus a deterministic local OIDC provider and
proves CIMD-first Authorization Code + PKCE, authenticated whoami, bounded scope step-up,
wrong-audience rejection and stateless MCP behavior.
For the observable published-image proof:
The observable flow verifies one distributed trace across client and server, positive Collector receipt, Tempo retrieval, Grafana provisioning and telemetry privacy assertions.
See Verification guide for the exact evidence boundary.
The terminal proof below is captured from the source-level paired reference flow:

The trace screenshots are captured from a successful observable run and focus on
mcp-server-auth-template spans:


| Profile | Intended use | Key behavior |
|---|---|---|
| Entra delegated | Interactive enterprise users | Validates scp, tenant/application identifiers, issuer, audience and subject |
| Entra application | Provider-specific app-only deployments | Requires explicit idtyp=app; keeps roles separate from delegated scopes |
| Generic OIDC delegated | Standards-based interactive clients | Validates issuer/audience/signature/expiry and OAuth scopes |
| Generic OIDC client credentials | Unattended services in the deterministic pair profile | Accepts pre-registered machine tokens and progressive OAuth scopes |
Set MCP_SERVER_AUTH_PROVIDER=entra or generic to switch adapters. The example whoami tool
returns the verified caller identity; health requires the additional mcp:tools:health scope and
demonstrates a pre-dispatch 403 insufficient_scope challenge.
Prerequisites: Python 3.13 or 3.14 and
uv.
Configure either the Entra or generic-OIDC block in .env, then point an MCP client at
http://localhost:8000/mcp.
| Endpoint | Purpose | Authentication |
|---|---|---|
/mcp | MCP Streamable HTTP | Bearer token |
/.well-known/oauth-protected-resource | Authorization-server discovery metadata | Public |
/livez | Process liveness | Public, minimal response |
/readyz | MCP lifespan readiness | Public, minimal response |
For production-style execution:
See Production operations before exposing the service outside loopback.
P2.1 prepares this repository for the Official MCP Registry namespace
io.github.brunovicco/mcp-server-auth-template. server.json describes the public GHCR image as
an OCI package using the real streamable-http transport; it does not claim a hosted remotes
endpoint. Version 0.6.1 is reserved as the first immutable image version carrying the required
io.modelcontextprotocol.server.name ownership label.
Registry publication is deliberately separate from this readiness change and happens only after the secure release pipeline validates the final OCI index. See Official MCP Registry.
The implementation is deliberately fail closed:
This is a transparent reference implementation, not a security certification. Read
Privacy and data handling and the architecture decisions under
docs/adr/ before adapting the boundary.
2026-07-28The paired templates exercise the modern stateless profile as executable behavior:
server/discover and per-request _meta carry protocol version, client identity and capabilities
without the legacy initialize / initialized handshake;MCP-Protocol-Version, Mcp-Method and Mcp-Name;Mcp-Session-Id;resource binds the access token audience exactly;403 insufficient_scope preserves prior grants and permits only one bounded replay of
the undispatched operation;io.modelcontextprotocol/oauth-client-credentials.See Compatibility and the companion client's cross-repository E2E evidence.
a2a-otel-kit continues W3C trace context at the MCP ASGI boundary. Export remains network-silent
unless A2A_OTEL_ENABLED=true and a complete OTLP traces endpoint are configured. Spans are
metadata-only and sit inside hardened HTTP admission but outside authentication and tool dispatch.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/mcp-server-auth-template)<a href="https://allmcps.com/mcp/mcp-server-auth-template"><img src="https://allmcps.com/api/badge/mcp-server-auth-template?style=directory" alt="MCP Server Auth Template on AllMCPs" /></a>