MCP Directory

How to add MCP MongoDB Server to Windsurf

Let LLMs query, aggregate, and write to MongoDB with schema inference and read-only protection. Paste the config into ~/.codeium/windsurf/mcp_config.json and restart Windsurf.

Last updated June 14, 2026 · 279 · stdio · no auth

Windsurf config for MCP MongoDB Server

npx -y mcp-mongo-server mongodb://localhost:27017/database
{
  "mcpServers": {
    "mcp-mongodb-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server",
        "mongodb://username:password@localhost:27017/database"
      ]
    }
  }
}

Setup steps

  1. 1Open Windsurf → Cascade → the hammer/MCP icon → Configure (or edit ~/.codeium/windsurf/mcp_config.json).
  2. 2Paste the MCP MongoDB Server config below.
  3. 3Fill in placeholder secrets, then save.
  4. 4Click Refresh in the MCP panel.
  5. 5MCP MongoDB Server's tools become available to Cascade.

Before you start

  • Node.js with npx (to run the package), or Docker
  • A reachable MongoDB instance and a connection URI

What MCP MongoDB Server can do in Windsurf

query

Execute MongoDB queries with filter, projection, and limit options, plus an optional explain plan (e.g. executionStats).

aggregate

Run MongoDB aggregation pipelines, with an optional explain plan (e.g. queryPlanner).

count

Count documents in a collection that match a query.

update

Modify documents matching a filter, with upsert and multi options (disabled in read-only mode).

insert

Insert one or more new documents into a collection (disabled in read-only mode).

createIndex

Create one or more indexes on a collection, including unique and named indexes (disabled in read-only mode).

serverInfo

Get MongoDB server details, with optional debug information.

Security

Credentials are passed through the MongoDB connection URI (in args or the MCP_MONGODB_URI env var), so they will be stored in plaintext in your MCP client config. Use the --read-only flag (or MCP_MONGODB_READONLY="true") to block write operations and route reads to a secondary; read-only mode also disables the update, insert, and createIndex tools.

MCP MongoDB Server + Windsurf FAQ

Where is the Windsurf config file?

Windsurf reads MCP servers from ~/.codeium/windsurf/mcp_config.json. Paste the MCP MongoDB Server config there under the "mcpServers" key and restart the client.

Is MCP MongoDB Server safe to use with Windsurf?

Credentials are passed through the MongoDB connection URI (in args or the MCP_MONGODB_URI env var), so they will be stored in plaintext in your MCP client config. Use the --read-only flag (or MCP_MONGODB_READONLY="true") to block write operations and route reads to a secondary; read-only mode also disables the update, insert, and createIndex tools.

How do I run it in read-only mode?

Append the --read-only flag to the command args, or set the MCP_MONGODB_READONLY environment variable to "true". Read-only mode blocks write operations and uses a secondary read preference.

How do I provide the MongoDB connection string?

Pass the URI as a positional argument (e.g. npx -y mcp-mongo-server mongodb://user:pass@host:27017/db), or set the MCP_MONGODB_URI environment variable instead of an argument.

Can I use it without npm?

Yes. You can run it directly from GitHub (npx -y github:kiliczsh/mcp-mongo-server ...) or build and run the provided Docker image. Smithery and mcp-get automated installers are also documented.

View repo Full MCP MongoDB Server page