-
Notifications
You must be signed in to change notification settings - Fork 614
[BUG]: Token scoping #2192
Copy link
Copy link
Labels
MUSTP1: Non-negotiable, critical requirements without which the product is non-functional or unsafeP1: Non-negotiable, critical requirements without which the product is non-functional or unsafebugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)securityImproves securityImproves security
Milestone
Description
🐞 Bug Summary
Server-scoped tokens cannot access the /rpc endpoint because it's not included in the general_endpoints list in the token scoping middleware. This prevents SSE transport from working with server-scoped tokens.
🧩 Affected Component
-
mcpgateway- API -
mcpgateway- UI (admin panel) -
mcpgateway.wrapper- stdio wrapper - Federation or Transports
- CLI, Makefiles, or shell scripts
- Container setup (Docker/Podman/Compose)
- Other (explain below)
🔁 Steps to Reproduce
- Create a server-scoped API token
- Attempt to use SSE transport to connect to an MCP server
- SSE transport calls
/rpcendpoint - Observe: HTTP 403 Forbidden
🤔 Expected Behavior
Server-scoped tokens should be able to access /rpc since it's an internal RPC endpoint required for MCP protocol operations.
🔍 Root Cause Analysis
In mcpgateway/middleware/token_scoping.py, the _check_server_restriction function:
- Checks if
/rpcmatches any server path pattern → NO - Checks if
/rpcis ingeneral_endpoints→ NO (not listed) - Returns
False→ HTTP 403
Current code:
general_endpoints = ["/health", "/metrics", "/openapi.json", "/docs", "/redoc"]Missing: /rpc
🛠️ Proposed Fix
Add /rpc to the general_endpoints list:
general_endpoints = ["/health", "/metrics", "/openapi.json", "/docs", "/redoc", "/rpc"]File: mcpgateway/middleware/token_scoping.py
✅ Acceptance Criteria
-
/rpcadded togeneral_endpoints - Server-scoped tokens can access
/rpc - SSE transport works with server-scoped tokens
- Existing token scoping tests pass
- No security regression (verify
/rpcshould be accessible)
🔗 Related Issues
- Related: [BUG][SSE]: SSE transport incorrect endpoint and data parsing #1595 (SSE transport incorrect endpoint)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
MUSTP1: Non-negotiable, critical requirements without which the product is non-functional or unsafeP1: Non-negotiable, critical requirements without which the product is non-functional or unsafebugSomething isn't workingSomething isn't workingpythonPython / backend development (FastAPI)Python / backend development (FastAPI)securityImproves securityImproves security