MCP MongoDB 服务器
模型上下文协议 (MLM) 服务器,使 LLM 能够与 MongoDB 数据库交互。该服务器提供通过标准化接口检查集合架构和执行 MongoDB 操作的功能。
演示
主要特点
智能 ObjectId 处理
- 字符串ID与MongoDB ObjectId之间的智能转换
- 可使用
objectIdMode
参数配置:"auto"
:根据字段名称转换(默认)"none"
:无转换"force"
:强制所有字符串 ID 字段为 ObjectId
灵活配置
- 环境变量:
MCP_MONGODB_URI
:MongoDB 连接 URIMCP_MONGODB_READONLY
:设置为“true”时启用只读模式
- 命令行选项:
--read-only
或-r
:以只读模式连接
只读模式
- 防止写入操作(更新、插入、创建索引)
- 使用 MongoDB 的辅助读取偏好来获得最佳性能
- 非常适合安全连接到生产数据库
MongoDB 操作
- 读取操作:
- 查询文档并进行可选的执行计划分析
- 执行聚合管道
- 统计符合条件的文档数量
- 获取集合架构信息
- 写入操作(不处于只读模式时):
- 更新文档
- 插入新文档
- 创建索引
LLM 整合
- 收集完成以增强 LLM 交互
- 模式推理可改善上下文理解
- 收集分析以获取数据洞察
安装
全局安装
为了发展
用法
基本用法
环境变量
您可以使用环境变量配置服务器,这对于 CI/CD 管道、Docker 容器或当您不想在命令参数中公开连接详细信息时特别有用:
在 Claude Desktop 配置中使用环境变量:
在 Docker 中使用环境变量:
与 Claude Desktop 集成
手动配置
将服务器配置添加到 Claude Desktop 的配置文件中:
MacOS : ~/Library/Application Support/Claude/claude_desktop_config.json
Windows : %APPDATA%/Claude/claude_desktop_config.json
命令行参数方法:
环境变量方法:
GitHub 包使用情况:
与 Windsurf 和 Cursor 集成
MCP MongoDB 服务器可以与 Windsurf 和 Cursor 一起使用,方式与 Claude Desktop 类似。
风帆冲浪配置
将服务器添加到您的 Windsurf 配置:
游标配置
对于 Cursor,将服务器配置添加到您的设置中:
您还可以将环境变量方法与 Windsurf 和 Cursor 一起使用,遵循 Claude Desktop 配置中显示的相同模式。
自动安装
使用 Smithery :
使用 mcp-get :
可用工具
查询操作
- 查询:执行 MongoDB 查询
- 聚合:运行聚合管道
- count :统计匹配的文档数量
写入操作
- 更新:修改文档
- 插入:添加新文档
- createIndex :创建集合索引
系统操作
- serverInfo :获取 MongoDB 服务器详细信息
调试
由于 MCP 服务器通过 stdio 进行通信,调试起来可能比较困难。使用 MCP 检查器可以更好地了解情况:
这将提供一个 URL 来访问浏览器中的调试工具。
执照
此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
模型上下文协议 (MLM) 服务器,使 LLM 能够与 MongoDB 数据库交互。该服务器提供通过标准化接口检查集合架构和执行 MongoDB 操作的功能。
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.Last updated -34075TypeScriptMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that provides read-only access to MongoDB databases, enabling AI assistants to directly query and analyze MongoDB data while maintaining data safety.Last updated -1492JavaScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -340TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.Last updated -340MIT License