-
Notifications
You must be signed in to change notification settings - Fork 613
[SECURITY]: MCP authentication controls and team membership validation #2125
Copy link
Copy link
Closed
Copy link
Labels
enhancementNew feature or requestNew feature or requestrbacRole-based Access ControlRole-based Access ControlsecurityImproves securityImproves security
Milestone
Description
Summary
Implement configurable authentication requirements and consistent authorization controls across all MCP protocol endpoints and entity types, bringing them to full parity with REST API security features.
Motivation
MCP endpoints serve as the primary interface for AI agents and MCP clients to interact with tools, resources, prompts, and A2A agents. As deployments scale to multi-tenant environments, operators need:
- Configurable authentication - Choose between open public access or strict authentication requirements
- Consistent authorization - Same visibility and team-scoping rules across all entity types
- Real-time membership validation - Users removed from teams should lose access immediately, not at token expiry
Implementation Status
| Component | Status |
|---|---|
MCP_REQUIRE_AUTH config |
✅ Complete |
| MCP team membership validation | ✅ Complete |
| Template resource read access | ✅ Complete |
| A2A listing access control | ✅ Complete |
| A2A get/invoke access control | ✅ Complete |
| Resource templates listing | ✅ Complete |
| Visibility parameter precedence | ✅ Complete |
| Nginx cache isolation | ✅ Complete |
Features
1. Configurable MCP Authentication (MCP_REQUIRE_AUTH)
| Setting | Default | Behavior |
|---|---|---|
MCP_REQUIRE_AUTH=false |
✓ | Unauthenticated requests allowed with public-only access |
MCP_REQUIRE_AUTH=true |
All requests must include valid Bearer token |
2. Team Membership Validation
- Cache-first lookup (60s TTL) for performance
- Database validation on cache miss
- Immediate access revocation when users are removed from teams
- 403 Forbidden response for invalid team membership
3. Visibility-Based Access Control
Access control rules based on token_teams JWT claim:
token_teams=None: Admin unrestricted access (sees all entities)token_teams=[]: Public-only access (no owner access to private entities)token_teams=[...]: Team-scoped access with owner access to private entities
Security Fixes
- A2A Listing Unscoped - Added
_apply_visibility_filter()to enforce team/visibility scoping - A2A Direct Access Bypass - Added
_check_agent_access()for get/invoke operations - Resource Templates Unfiltered - Added visibility filtering to
list_resource_templates() - Visibility Parameter Precedence - Fixed schema default overriding endpoint parameter
- Nginx Cache Data Leakage - Added
$http_authorizationto cache key
Configuration
# Require authentication for /mcp endpoints (default: false)
MCP_REQUIRE_AUTH=false
# Enable JWT authentication for MCP (default: true)
MCP_CLIENT_AUTH_ENABLED=trueFiles Changed
mcpgateway/config.py- Addedmcp_require_authconfigurationmcpgateway/main.py- Updated A2A endpoints with access contextmcpgateway/services/a2a_service.py- Added visibility filtering and access checksmcpgateway/services/resource_service.py- Added visibility filteringmcpgateway/transports/streamablehttp_transport.py- Team membership validationinfra/nginx/nginx.conf- Per-user cache key isolation
Migration
No migration required. Default behavior (MCP_REQUIRE_AUTH=false) maintains backward compatibility.
For multi-tenant deployments, enable strict authentication:
MCP_REQUIRE_AUTH=true
MCP_CLIENT_AUTH_ENABLED=trueReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestrbacRole-based Access ControlRole-based Access ControlsecurityImproves securityImproves security