-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Version
App
- Cursor
- Windsurf
- VSCode
- VSCode Insiders
- Claude Desktop
- Other
Affected Models (if applicable)
- Claude 3.5 Sonnet
- Claude 3.7 Sonnet
- GPT-4a
- o4-mini
- Other
Bug Description
MongoDB MCP Server - Atlas API Permission Issue
Bug Summary
The MongoDB MCP server fails to connect to Atlas clusters and read data when using Atlas API with "read-only" permissions, requiring full "Project Owner" permissions to function properly. This contradicts the expected behavior for read-only operations.
Environment
- MCP Server:
mongodb-mcp-server
(latest via npx) - MongoDB Atlas: Cluster on Atlas (M50 tier)
- MCP Configuration: Using Atlas API credentials with
--readOnly
flag - Connection Method: Atlas API (not direct connection string)
Expected Behavior
The MCP server should be able to:
- Connect to Atlas clusters
- List databases
- List collections
- Read data from collections
When configured with minimal read permissions such as:
Project Read Only
Project Data Access Read Only
Actual Behavior
The MCP server fails with authentication errors when using read-only permissions and only works with full Project Owner
permissions.
Detailed Test Results
Working Configuration (Project Owner)
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y", "mongodb-mcp-server",
"--apiClientId", "mdb_sa_id_xxx",
"--apiClientSecret", "mdb_sa_sk_xxx",
"--readOnly"
]
}
}
}
Permissions: Project Owner
Result: All operations work (connect, list databases, list collections)
❌ Failing Configurations
Configuration 1: Minimal Read Permissions
Permissions:
- Project Read Only
- Project Data Access Read Only
Result:
- ✅
atlas-list-clusters
works - ❌
atlas-connect-cluster
fails with401 Unauthorized
Configuration 2: Extended Read Permissions
Permissions:
- Project Read Only
- Project Data Access Read Only
- Project Observability Viewer
- Project Cluster Manager
Result: Same as Configuration 1
Configuration 3: Admin Permissions (Without Owner)
Permissions:
- Project Data Access Admin
- Project Cluster Manager
- Project Database Access Admin
- Project Data Access Read Only
- Project Observability Viewer
- Project Read Only
Result:
- ✅
atlas-connect-cluster
works - ❌
list-databases
fails with "Authentication failed" - ✅
list-collections
works for specific databases
Error Messages
Connection Error (Insufficient Permissions)
Unable to authenticate with MongoDB Atlas, API error: [401 Unauthorized]
error calling Atlas API: Unauthorized; Current user is not authorized to perform this action.
Database Listing Error (Even with Data Access Admin)
Error running list-databases: Authentication failed.
Analysis
- Atlas API metadata operations (list-clusters, list-users, etc.) work with basic read permissions
- Atlas cluster connection requires
Project Data Access Admin
(not just Read Only) - Database listing fails even with
Project Data Access Admin
- Collection listing works when database name is specified
- Only Project Owner enables full functionality
Impact
- Users cannot use least-privilege access principles
- Requires unnecessarily broad permissions for read-only operations
- Security concern for production environments
- Contradicts MongoDB Atlas best practices for API access
Reproduction Steps
- Create Atlas API key with
Project Read Only
+Project Data Access Read Only
permissions - Configure MCP server with
--readOnly
flag - Attempt to connect and list data
- Observe authentication failures
- Upgrade to
Project Owner
permissions - Observe that everything works
Additional Context
This issue was discovered during systematic permission testing where we incrementally tested different Atlas API permission combinations to find the minimum required access level.