MCP Hub
Back to servers

mongodb-mcp-legacy

MCP server for legacy MongoDB (3.2+) — connect old MongoDB to Claude Code, Codex, Cursor, and other AI tools via Model Context Protocol

npm105/wk
Updated
Mar 7, 2026

Quick Install

npx -y mongodb-mcp-legacy

mongodb-mcp-legacy

npm version License: MIT Node.js

A Model Context Protocol (MCP) server for old MongoDB versions (3.2+) that the official MongoDB MCP Server does not support. Works with Claude Code, Codex, Cursor, and any MCP-compatible client.

Why This Project?

The official mongodb-mcp-server uses a modern MongoDB Node.js driver that does not work with MongoDB 3.x or 4.x. If you're running a legacy MongoDB instance (3.2 -- 4.x) and want to connect it to AI tools like Claude Code or Cursor via MCP, you're stuck.

mongodb-mcp-legacy solves this by using the mongodb@3.7.4 driver, which supports MongoDB 3.2 and above.

mongodb-mcp-legacyOfficial mongodb-mcp-server
MongoDB version3.2+6.0+ (modern driver)
Node.js version>= 16>= 20.19
OperationsRead-onlyRead / Write / Atlas API
Setup complexityZero configMultiple config options

Features

  • Legacy MongoDB support -- works with MongoDB 3.2, 3.4, 3.6, 4.0, 4.2, 4.4, and above
  • Read-only operations -- safe by design, no write/update/delete tools
  • MCP compatible -- works with any MCP client (Claude Code, Codex, Cursor, Windsurf, VS Code, etc.)
  • Zero config -- just provide a MONGODB_URI and go
  • Lightweight -- single file, minimal dependencies

Quick Start

Prerequisites

  • Node.js >= 16.0.0
  • A MongoDB instance (version 3.2 or above)

Installation

Run directly with npx (no install needed):

npx mongodb-mcp-legacy

Or install globally:

npm install -g mongodb-mcp-legacy

Configuration

The server reads the MONGODB_URI environment variable to connect. If not set, it defaults to mongodb://localhost:27017.

Claude Code

Add to your Claude Code config (~/.claude.json):

{
  "mcpServers": {
    "mongodb-legacy": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mongodb-mcp-legacy"],
      "env": {
        "MONGODB_URI": "mongodb://username:password@host:port/database"
      }
    }
  }
}

Codex

Add to your Codex MCP config:

{
  "mcpServers": {
    "mongodb-legacy": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mongodb-mcp-legacy"],
      "env": {
        "MONGODB_URI": "mongodb://username:password@host:port/database"
      }
    }
  }
}

Cursor

Add to your Cursor MCP settings:

{
  "mcpServers": {
    "mongodb-legacy": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mongodb-mcp-legacy"],
      "env": {
        "MONGODB_URI": "mongodb://username:password@host:port/database"
      }
    }
  }
}

Other MCP Clients

Any MCP client that supports stdio transport will work. Set the command to npx -y mongodb-mcp-legacy and pass MONGODB_URI as an environment variable.

Local Development

MONGODB_URI="mongodb://localhost:27017/mydb" node index.js

Available Tools

ToolDescriptionParameters
list_databasesList databases (falls back to current database without admin perms)(none)
list_collectionsList all collections in a databasedatabase (optional)
execute_queryExecute a read-only find querydatabase (optional), collection (required), query (optional JSON string), limit (optional, default 10)
count_documentsCount documents matching a filterdatabase (optional), collection (required), query (optional JSON string)

Examples

list_databases()

list_collections({ database: "mydb" })

execute_query({ collection: "users", query: '{"status": "active"}', limit: 5 })

count_documents({ collection: "orders", query: '{"total": {"$gt": 100}}' })

Development

git clone https://github.com/maximuszeng/mongodb-mcp-legacy.git
cd mongodb-mcp-legacy
pnpm install

Note: Running the server only requires Node.js >= 16, but development and testing require Node.js >= 18 (due to pnpm and vitest).

Run the server locally:

MONGODB_URI="mongodb://localhost:27017/mydb" pnpm start

Lint and format:

pnpm run lint
pnpm run format

Run tests:

pnpm test

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT

Reviews

No reviews yet

Sign in to write a review