feat(oauth): add OAuth authentication for MCP HTTP mode#153
feat(oauth): add OAuth authentication for MCP HTTP mode#153
Conversation
jwerle
commented
Mar 9, 2026
- discover oauth server metadata, expose protected resource metadata, and introspect bearer tokens for incoming requests
- pass auth'd access tokens through to Socket API calls returning 401/403 when auth fails
There was a problem hiding this comment.
Pull request overview
This PR adds OAuth 2.0 authentication support for the MCP server when running in HTTP mode. It implements the full OAuth resource-server flow: discovery of the upstream authorization server's metadata, exposure of a protected resource metadata endpoint (RFC 9728), per-request Bearer token introspection, scope checking, and forwarding the validated token to Socket API calls. Non-OAuth HTTP mode and stdio mode continue to work with a static API key.
Changes:
- Added OAuth metadata discovery, token introspection (
verifyAccessToken), and request authentication (authenticateRequest) functions with all associated helpers - Exposed
/.well-known/oauth-authorization-serverand/.well-known/oauth-protected-resourceendpoints when OAuth is enabled - Threaded
extra.authInfo.tokenthrough to Socket API calls so authenticated tokens are forwarded, with explicit 401/403 error handling
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
703c9b3 to
520ed47
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
520ed47 to
bca8d54
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bca8d54 to
3ea63ac
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- discover oauth server metadata, expose protected resource metadata, and introspect bearer tokens for incoming requests - pass auth'd access tokens through to Socket API calls returning 401/403 when auth fails
3ea63ac to
35797fc
Compare