← Back to directory
M

MongoDB MCP Server

Community
Let AI assistants work with your MongoDB databases safely.
GitHub source repository ↗
★ 284 Stars Category · Database Very popular Source revision 55310c0d09ed
42FMRS · D
Reliability
5/20
Security and permissions
7/20
Maintenance
6/20
Documentation
13/20
Setup experience
11/20

mcp-mongo-server is a feature-rich MongoDB MCP server with read-only mode, schema inference, query and aggregation support. It is easy to use via npx and prioritizes safety by restricting cross-db and server-side JS by default. Suitable for developers to safely explore and manipulate MongoDB through AI tools.

Read the FMRS scoring method →

mcp-mongo-server is a Model Context Protocol (MCP) server that enables AI assistants to interact with MongoDB databases. It automatically exposes collections, infers schemas, and runs queries, aggregations, and writes through a standard interface. Supports read-only mode, smart ObjectId handling, schema inference, aggregation pipelines, time conversion, and progress/cancellation. Works over stdio or HTTP transport, compatible with Claude Desktop, Cursor, and Windsurf.

Tools

query
Query documents in a collection with filters, projections, etc.
aggregate
Run aggregation pipelines, optionally with explain plans.
update
Update documents in a collection (when not read-only).
insert
Insert new documents into a collection (when not read-only).
createIndex
Create an index on a collection (when not read-only).
convertTime
Convert Unix timestamps or date strings to UTC/GMT/ISO formats.
listCollections
List collections in the database.
inferSchema
Infer schema of a collection from document samples.

Setup

No install needed; run via npx: npx -y mcp-mongo-server mongodb://localhost:27017/mydatabase

Fit and risk

Best for

  • Users of AI coding assistants (Claude Desktop, Cursor, Windsurf) that need to interact with MongoDB
  • Developers who want to query databases using plain language
  • Teams sharing MongoDB data access with AI tools

Not for

  • High-security production environments unless properly configured with authentication and permissions
  • Performance-critical scenarios where AI may run suboptimal queries
  • Users needing full database administration (e.g., user management, backups)

Required permissions

  • MongoDB connection string, possibly including username and password
  • Read/write access to the target database (unless read-only mode is enabled)
  • HTTP mode may require an authentication token

Risks and side effects

  • If read-only mode is not enabled, AI may inadvertently perform write operations (updates, inserts, index creation)
  • Cross-database operations are blocked by default, but enabling --allow-cross-db may expose other databases
  • Server-side JavaScript operators ($function, $where) are disabled by default, but enabling can introduce code execution risks
  • HTTP mode defaults to localhost only, but misconfiguration could expose the database
  • May execute resource-intensive aggregations or queries, leading to performance issues

Troubleshooting

  1. Check the MongoDB URI correctness and reachability
  2. Ensure Node.js version is 20 or newer
  3. If write operations fail, check if read-only mode is enabled
  4. In HTTP mode, if receiving 403, check allowed origins
  5. See docs/integration.md for client-specific configuration examples

Use cases

Ask AI assistants to query MongoDB in natural language
Automatically discover database structure and understand collections
Let AI safely explore data in read-only mode without modifications
Provide remote access over HTTP for multi-client or team use

Supported clients

Claude DesktopFull support
CursorFull support
WindsurfFull support