Skip to content

Commit bca8d54

Browse files
committed
feat(oauth): add OAuth authentication for MCP HTTP mode
- 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
1 parent ad54b9e commit bca8d54

3 files changed

Lines changed: 740 additions & 49 deletions

File tree

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,29 @@ This approach automatically uses the latest version without requiring global ins
182182
MCP_HTTP_MODE=true SOCKET_API_KEY=your-api-key npx @socketsecurity/mcp@latest --http
183183
```
184184

185+
HTTP mode supports these environment variables:
186+
187+
| Variable | Required | Default | Description |
188+
|---|---|---|---|
189+
| `SOCKET_API_KEY` | Required unless OAuth is enabled | None | Socket API key used for outbound API calls. |
190+
| `SOCKET_OAUTH_ISSUER` | Set together with the two introspection vars to enable OAuth | None | OAuth issuer URL used for metadata discovery and incoming bearer-token validation. |
191+
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_ID` | With OAuth | None | Client ID used for token introspection. |
192+
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_SECRET` | With OAuth | None | Client secret used for token introspection. |
193+
| `SOCKET_OAUTH_REQUIRED_SCOPES` | No | `packages:list` | Space-delimited scopes required on incoming access tokens. |
194+
| `SOCKET_API_URL` | No | Production Socket API URL, or localhost when `SOCKET_DEBUG=true` | Override the upstream Socket API endpoint. Useful for local development and testing. |
195+
| `SOCKET_DEBUG` | No | `false` | Switches the default upstream Socket API endpoint to localhost when `SOCKET_API_URL` is unset. |
196+
| `MCP_PORT` | No | `3000` | Port to bind the HTTP server to. |
197+
198+
To enable OAuth-backed auth for incoming MCP requests:
199+
200+
```bash
201+
MCP_HTTP_MODE=true \
202+
SOCKET_OAUTH_ISSUER=https://issuer.example.com \
203+
SOCKET_OAUTH_INTROSPECTION_CLIENT_ID=your-client-id \
204+
SOCKET_OAUTH_INTROSPECTION_CLIENT_SECRET=your-client-secret \
205+
npx @socketsecurity/mcp@latest --http
206+
```
207+
185208
2. Configure your MCP client to connect to the HTTP server:
186209
```json
187210
{

0 commit comments

Comments
 (0)