Skip to content

fix: whitelist /rpc endpoint for server-scoped tokens#2646

Merged
crivetimihai merged 1 commit intomainfrom
fix/2192-rpc-endpoint-server-scoped-token
Feb 7, 2026
Merged

fix: whitelist /rpc endpoint for server-scoped tokens#2646
crivetimihai merged 1 commit intomainfrom
fix/2192-rpc-endpoint-server-scoped-token

Conversation

@shoummu1
Copy link
Copy Markdown
Collaborator

@shoummu1 shoummu1 commented Feb 2, 2026

🐛 Bug-fix PR

📌 Summary

Server-scoped tokens cannot access the /rpc endpoint, preventing SSE transport and WebSocket relay from functioning. This PR adds /rpc to the general endpoints whitelist to allow server-scoped tokens to make MCP protocol requests.

🔗 Related Issue

Closes #2192

🐞 Root Cause

In mcpgateway/middleware/token_scoping.py, the _check_server_restriction function:

  1. Checks if /rpc matches any server path pattern → NO
  2. Checks if /rpc is in general_endpoints → NO (not listed)
  3. Returns False → HTTP 403

The /rpc endpoint is a core JSON-RPC endpoint used for:

  • Direct POST requests for MCP operations
  • WebSocket relay (proxies requests to /rpc)
  • Internal RPC handling

Without /rpc in the whitelist, server-scoped tokens are denied access despite needing it for MCP protocol operations.

💡 Fix Description

Added /rpc to the general_endpoints list in mcpgateway/middleware/token_scoping.py (line 328):

general_endpoints = ["/health", "/metrics", "/openapi.json", "/docs", "/redoc", "/rpc"]

@shoummu1 shoummu1 marked this pull request as ready for review February 2, 2026 10:52
@crivetimihai crivetimihai added this to the Release 1.0.0-RC1 milestone Feb 3, 2026
@crivetimihai
Copy link
Copy Markdown
Member

Clean one-liner fix with a test. Server-scoped tokens need /rpc access for MCP protocol operations. CI is all green.

LGTM — ready to merge.

@crivetimihai crivetimihai self-assigned this Feb 4, 2026
@shoummu1 shoummu1 force-pushed the fix/2192-rpc-endpoint-server-scoped-token branch 3 times, most recently from 2eaca5e to d852e04 Compare February 6, 2026 09:47
Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
@crivetimihai crivetimihai merged commit 86c7ed8 into main Feb 7, 2026
51 checks passed
@crivetimihai crivetimihai deleted the fix/2192-rpc-endpoint-server-scoped-token branch February 7, 2026 10:55
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
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.

[BUG]: Token scoping

2 participants