mcp-remote-auth-example
Allows the MCP server to use Auth0 as an OAuth 2.1 authorization server for token validation and audience checking.
Allows the MCP server to use Keycloak as an OAuth 2.1 authorization server for token validation and audience checking.
Allows the MCP server to use Okta as an OAuth 2.1 authorization server for token validation and audience checking.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-remote-auth-example
A minimal remote (Streamable HTTP) MCP server that is an OAuth 2.1 resource server — the shape the MCP authorization spec requires for remote servers. It shows the only auth code you actually own on your server:
Publishes Protected Resource Metadata at
/.well-known/oauth-protected-resource(RFC 9728).Rejects unauthenticated requests with
401+ aWWW-Authenticateheader pointing at that metadata (the discovery entry point).Validates every access token: signature, issuer, expiry, and audience (RFC 8707) — the check most walkthroughs skip.
You do not run your own OAuth server. In production you delete the local dev issuer and point the metadata at your IdP (Auth0, Okta, Keycloak, WorkOS, Entra). The dev issuer here exists only so the whole flow runs on your machine in one command.
Pinned to @modelcontextprotocol/sdk@1.29.0, TypeScript 5.9, jose 6.
One-command run
npm install
npm run demonpm run demo boots the server and walks the four wire behaviors, printing the real request/response for each:
Unauthenticated
POST /mcp→401+WWW-Authenticatereferencing the PRM URL.GET /.well-known/oauth-protected-resource→ the RFC 9728 document.A correctly audience-bound token →
initialize+tools/list+tools/call whoamisucceed.A token minted for a different resource →
401 invalid_token(the RFC 8707 audience check doing its job).
Tests
npm testSix guard tests cover the same behaviors plus expired and malformed tokens.
What's yours vs. what's the dev stand-in
File | Role | Keep in production? |
| The resource-server guard: PRM doc + token validation + audience check. | Yes — this is the code you own. |
| Remote MCP server (Streamable HTTP) with the guard in front. | Yes. |
| A tiny local dev authorization server so the demo runs offline. | No — delete and use your IdP. |
|
| Yes — set from env. |
Going to production
Delete
src/issuer.tsand the/jwksroute.Set
OAUTH_ISSUERto your IdP's issuer URL andMCP_RESOURCEto your server's public canonical URI.Your IdP already serves its own JWKS from its metadata;
src/auth.tsverifies against it unchanged.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Minimal streamable HTTP MCP server used for owned-account registry connectivity tests.
Demo banking MCP server: accounts, transactions and payments. OAuth 2.1 with DPoP.
Experimental MCP server for current empirical verification of explicit public HTTPS endpoint claims.
An authenticated remote MCP server for user-owned devices and one-shot capability invocation.