feat: add external auth server example (RFC 8707)#1693
feat: add external auth server example (RFC 8707)#1693travisbreaks wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
Adds a new example demonstrating MCP authentication with an external OAuth2 authorization server, as requested in modelcontextprotocol#658. The example consists of three components: - External auth server: standalone OAuth2 AS that issues JWT tokens with JWKS endpoint for signature verification - MCP resource server: validates JWT tokens via JWKS, serves protected resource metadata pointing to the external AS - Client: discovers AS via resource metadata, authenticates, connects Implements RFC 8707 (resource indicators), RFC 9728 (protected resource metadata), RFC 9068 (JWT access tokens), RFC 7591 (dynamic client registration), and RFC 7636 (PKCE). Closes modelcontextprotocol#658
9efa772 to
ca06ce9
Compare
|
Thanks for this. We already have a better-auth example at |
Summary
Closes #658.
Adds a complete external authentication server example demonstrating RFC 8707 resource indicators with the MCP SDK. The example shows how to separate the authorization server from the MCP resource server, which is the recommended pattern for production deployments.
What's included:
authServer.ts): standalone OAuth2 AS with RSA key pair generation, JWKS endpoint, dynamic client registration, PKCE validation, and JWT access tokens with audience-bound claimsresourceServer.ts): MCP server that serves protected resource metadata, validates JWT Bearer tokens via remote JWKS, and exposes authenticated tools (greet,whoami)externalAuthServerClient.ts): demonstrates the full OAuth flow (401 challenge, resource/AS metadata discovery, dynamic registration, authorization, token exchange)--oauthexampleTest plan