Data as of
MongoDB MCP Server for VS Code: Setup & Config
VS Code: MongoDB MCP Server connects AI clients to MongoDB databases and Atlas.
What you can do with MongoDB in VS Code
A broad MongoDB toolset with read-only onboarding and integrated MongoDB knowledge search.
- Inspect collection schemas and indexes before writing queries.
- Review query plans, database statistics, and recent MongoDB logs.
Before you start: MongoDB in VS Code
- Node.js 22.13.0 or later
- A MongoDB connection string or Atlas service-account credentials
- An MCP-compatible client
This is the README's read-only connection-string setup. Atlas operations instead need MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET. Docker and HTTP alternatives are documented; HTTP needs deployment-level authentication and protection.
MongoDB VS Code configuration
Choose VS Code configuration scope
For MongoDB MCP Server, open Workspace: .vscode/mcp.json. Merge into servers; preserve existing inputs.
Add MongoDB MCP Server to VS Code
Use the mongodb-mcp-server entry below in servers. Keep MongoDB MCP Server's documented stdio connection fields and your other VS Code entries.
Check MongoDB MCP Server in VS Code
MongoDB MCP Server: Start in VS Code’s MCP controls; inspect output and trust prompts.
Config file · Workspace: .vscode/mcp.json
{
"servers": {
"mongodb-mcp-server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "<MongoDB connection string with appropriate credentials>"
}
}
}
}MongoDB tools available to VS Code
MongoDB's stored tool list documents 27 tools; compare it with VS Code's connected tool list, because the stored list is not a live check.
- aggregate-db
Look for aggregate-db among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- aggregate
Look for aggregate among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Execute an aggregation pipeline on a collection.
- collection-indexes
Look for collection-indexes among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Inspect indexes attached to a collection.
- collection-schema
Look for collection-schema among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Inspect a collection's document structure.
- collection-storage-size
Look for collection-storage-size among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Report storage size for a collection.
- connect
Look for connect among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Open an independent MongoDB connection and return its identifier.
- count
Look for count among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Count collection documents, optionally constrained by a query.
- create-collection
Look for create-collection among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Add a collection, creating its database if necessary.
- create-index
Look for create-index among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- db-stats
Look for db-stats among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- delete-many
Look for delete-many among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- disconnect
Look for disconnect among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- drop-collection
Look for drop-collection among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- drop-database
Look for drop-database among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- drop-index
Look for drop-index among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Remove a specified collection index.
- explain
Look for explain among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Inspect execution statistics for the optimizer's selected query plan.
- export
Look for export among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Save query or aggregation output in the requested EJSON format.
- find
Look for find among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Search documents within a collection.
- insert-many
Look for insert-many among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Insert a document array, splitting large payloads into batches when needed.
- list-collections
Look for list-collections among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Enumerate collections belonging to a database.
- list-connections
Look for list-connections among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Show active connection identifiers, including any preconfigured connection.
- list-databases
Look for list-databases among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- mongodb-logs
Look for mongodb-logs among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- rename-collection
Look for rename-collection among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- update-many
Look for update-many among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- list-knowledge-sources
Look for list-knowledge-sources among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
- search-knowledge
Look for search-knowledge among VS Code's agent-mode tools after starting MongoDB through the MCP controls.
Troubleshooting MongoDB in VS Code
- Make npx mongodb-mcp-server@latest (Node.js/npm) available in the workspace, container, or remote environment hosting MongoDB MCP Server. Start through VS Code's MCP controls; inspect output and trust prompts.
- For MongoDB MCP Server, keep MDB_MCP_CONNECTION_STRING out of version control; VS Code documents input variables and secret handling.
- MongoDB MCP Server uses stdio here: VS Code must keep the configured process running; protocol output belongs on stdout and diagnostics on stderr.
- Known limitation: Atlas tools require separate service-account credentials.
- Known limitation: HTTP deployments need additional security controls.
- Known limitation: Write-enabled tools can delete data and database objects.
- General VS Code troubleshooting lives in the /clients/vscode guide.
MongoDB MCP Server — details. VS Code guide