Skip to content

Conversation

@fahreddinozcan
Copy link
Contributor

@fahreddinozcan fahreddinozcan commented Dec 5, 2025

This PR adds OAuth 2.0 authentication support to the MCP server, enabling secure access control for MCP clients.

Changes

New OAuth-protected endpoint (/mcp/oauth) - Requires authentication via JWT tokens
JWT validation - Validates tokens against the authorization server's JWKS endpoint with caching (1 hour TTL)
OAuth Protected Resource Metadata - Implements RFC 9728 discovery endpoint at /.well-known/oauth-protected-resource
WWW-Authenticate header - Returns resource metadata URL to help clients discover the authorization server
Backward compatibility - The existing /mcp endpoint remains available for anonymous access

New Files

packages/mcp/src/lib/jwt.ts - JWT validation utilities using jose library

Configuration

AUTH_SERVER_URL - Authorization server URL (default: https://context7.com)
RESOURCE_URL - Resource server URL for metadata

@linear
Copy link

linear bot commented Dec 5, 2025

CTX7-884 oauth for mcp

@fahreddinozcan fahreddinozcan changed the title Ctx7 884 CTX7-884: OAuth Support for MCP Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants