# mcp-mongo-server — MongoDB MCP with Read-Only Mode > mcp-mongo-server is an MCP server you can run via `npx` to let assistants query MongoDB, with a read-only mode for safer database access. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use ```bash # start the MCP server (example connection string from README) npx -y mcp-mongo-server mongodb://localhost:27017/database # read-only mode npx -y mcp-mongo-server mongodb://localhost:27017/database --read-only ``` ## Intro mcp-mongo-server is an MCP server you can run via `npx` to let assistants query MongoDB, with a read-only mode for safer database access. - **Best for:** Giving agents structured MongoDB access while keeping a safety dial (read-only) - **Works with:** MongoDB connection URI; MCP clients like Claude Desktop/Cursor/Windsurf (integration guide linked in README) - **Setup time:** 2–10 minutes ## Practical Notes - GitHub: 278 stars · 54 forks; pushed 2026-02-06 (verified via GitHub API). - README shows `npx -y mcp-mongo-server ` and `--read-only` as the primary usage pattern. - README documents env vars like `MCP_MONGODB_URI` and `MCP_MONGODB_READONLY` for configuration. ## Main Safer database access patterns for assistants: 1. Start in **read-only** until you’ve validated tool behavior and logging. 2. Prefer a dedicated MongoDB user with minimal privileges, even when read-only is enabled. 3. Use the MCP client’s system prompt to declare what “allowed queries” mean (collections, time range, limits). 4. Treat DB writes as a separate workflow with explicit approvals. The key is turning “ask the DB” into a controllable tool boundary, not an unrestricted superpower. ### FAQ **Q: Is `npx` required?** A: That’s the documented default in the README (`npx -y mcp-mongo-server …`). **Q: How do I enable read-only?** A: Pass `--read-only` or set `MCP_MONGODB_READONLY` (README). **Q: What clients can use it?** A: README links an integration guide for Claude Desktop, Windsurf, Cursor, and Docker setups. ## Source & Thanks > Source: https://github.com/kiliczsh/mcp-mongo-server > License: MIT > GitHub stars: 278 · forks: 54 --- ## 快速使用 ```bash # 启动 MCP server(README 示例连接串) npx -y mcp-mongo-server mongodb://localhost:27017/database # 只读模式 npx -y mcp-mongo-server mongodb://localhost:27017/database --read-only ``` ## 简介 mcp-mongo-server 是可用 `npx` 启动的 MongoDB MCP server,支持 `--read-only` 只读模式与环境变量配置,适合把数据库查询能力安全地交给助手使用。 - **适合谁:** 想把 MongoDB 查询能力给 agent,但仍保留安全旋钮(只读) - **可搭配:** MongoDB 连接 URI;MCP 客户端(README 链接到 Claude Desktop/Cursor/Windsurf 集成指南) - **准备时间:** 2–10 分钟 ## 实战建议 - GitHub:278 stars · 54 forks;最近更新 2026-02-06(GitHub API 验证)。 - README 的主用法是 `npx -y mcp-mongo-server `,并支持 `--read-only`。 - README 记录了 `MCP_MONGODB_URI` 与 `MCP_MONGODB_READONLY` 等环境变量配置方式。 ## 主要内容 把 MongoDB 给助手用,先把边界立好: 1. 先用 **只读模式** 起步,确认行为与日志可追溯再放开。 2. 即便只读,也建议用最小权限的专用账号连接数据库。 3. 在 MCP 客户端的系统提示里明确“允许的查询范围”(集合/时间范围/limit)。 4. 写操作建议单独拆成流程,并且要求人工确认。 核心是把“问数据库”变成可控工具边界,而不是无边界超能力。 ### FAQ **必须用 `npx` 吗?** 答:README 的默认示例就是 `npx -y mcp-mongo-server …`。 **怎么开启只读?** 答:使用 `--read-only` 或设置 `MCP_MONGODB_READONLY`(见 README)。 **哪些客户端能用?** 答:README 链接的集成指南覆盖 Claude Desktop、Windsurf、Cursor、Docker 等。 ## 来源与感谢 > Source: https://github.com/kiliczsh/mcp-mongo-server > License: MIT > GitHub stars: 278 · forks: 54 --- Source: https://tokrepo.com/en/workflows/mcp-mongo-server-mongodb-mcp-with-read-only-mode Author: MCP Hub