
How to add MongoDB MCP Server to Windsurf
Official MongoDB server connecting Atlas, Community, or Enterprise deployments to AI tools. Paste the config into ~/.codeium/windsurf/mcp_config.json and restart Windsurf.
Last updated June 15, 2026 · 1.5k★ · stdio · apikey · official
Windsurf config for MongoDB MCP Server
npx -y mongodb-mcp-server@latest --readOnly{
"mcpServers": {
"mongodb-mcp-server": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server@latest",
"--readOnly"
],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://<user>:<password>@<cluster-host>/<db>"
}
}
}
}Setup steps
- 1Open Windsurf → Cascade → the hammer/MCP icon → Configure (or edit ~/.codeium/windsurf/mcp_config.json).
- 2Paste the MongoDB MCP Server config below.
- 3Fill in placeholder secrets, then save.
- 4Click Refresh in the MCP panel.
- 5MongoDB MCP Server's tools become available to Cascade.
Before you start
- Node.js v22.13.0 or later (Node 20.x support is deprecated)
- A MongoDB connection string for the deployment you want to access (Atlas, Community, or Enterprise), OR Atlas API Service Account credentials (Client ID + Secret) for Atlas control-plane tools
- For Atlas tools: an Atlas Service Account created in the Atlas UI under Access Manager, with the minimum required project/org roles
- Optionally Docker, if you prefer running the published container image instead of npx
What MongoDB MCP Server can do in Windsurf
findRun a query against a collection and return matching documents
aggregateExecute an aggregation pipeline on a collection
countCount documents matching a filter
insert-manyInsert one or more documents into a collection
update-manyUpdate documents matching a filter
delete-manyDelete documents matching a filter
list-databasesList databases in the connected deployment
list-collectionsList collections in a database
Security
The connection string carries full database credentials, so keep it in env vars (never args) and use a scoped user. Pass --readOnly when the agent should not mutate or drop collections.
MongoDB MCP Server + Windsurf FAQ
Where is the Windsurf config file?
Windsurf reads MCP servers from ~/.codeium/windsurf/mcp_config.json. Paste the MongoDB MCP Server config there under the "mcpServers" key and restart the client.
Is MongoDB MCP Server safe to use with Windsurf?
The connection string carries full database credentials, so keep it in env vars (never args) and use a scoped user. Pass --readOnly when the agent should not mutate or drop collections.
Does it work with self-hosted MongoDB or only Atlas?
Both. Database tools work against any MongoDB deployment via a connection string — Atlas, Community, or Enterprise. The atlas-* tools additionally require Atlas Service Account API credentials and only apply to Atlas.
How do I get Atlas API credentials?
Create a Service Account in the Atlas UI (Organization/Project Access Manager > Applications), copy the Client ID and Client Secret, and grant it the minimum roles needed for the operations you want to perform.
Can I stop an agent from modifying data?
Yes. Start the server with read-only mode enabled and it will only expose non-destructive tools. You can also require confirmation for specific tools and cap how many documents/bytes a query returns.