Token导航 LogoToken导航TokenDH.com
MCP Mongo Server logo
开发工具stdio官方级别未说明来源级核验

MCP Mongo Server

MCP Server

mcp-mongo-server

A Model Context Protocol Server for MongoDB

工具数

0

提示词数

0

GitHub Stars

276

资源数

0
数据库操作TypeScriptClaudeClaudeCursorWindsurfClineClaude Desktop

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

kiliczsh

提供方

kiliczsh

最后核验

2026/5/18 02:17

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database

详细介绍

MCP MongoDB服务器

______________________________________________________________________

](https://smithery.ai/server/mcp-mongo-server) ![Verified on MseeP](https://mseep.ai/app/e274a3dd-7fe6-4440-8c43-043bae668251)

一个模型上下文协议服务器,使LLM能够与MongoDB数据库交互。该服务器提供通过标准化接口检查收集模式和执行MongoDB操作的功能。

演示

![MCP MongoDB Server Demo | Claude Desktop](https://www.youtube.com/watch?v=FI-oE_voCpA)

主要特点

智能对象ID处理

  • 字符串ID和MongoDB ObjectId之间的智能转换
  • 可配置 objectIdMode 参数:

- "auto":根据字段名称转换(默认) - "none":无转换 - "force":强制所有字符串ID字段为ObjectId

灵活的配置

  • 环境变量:

- MCP_MONGODB_URI:MongoDB连接URI - MCP_MONGODB_READONLY:设置为“true”时启用只读模式

  • 命令行选项:

- --read-only-r:以只读模式连接

只读模式

  • 防止写入操作(更新、插入、创建索引)
  • 使用MongoDB的二次读取首选项以获得最佳性能
  • 非常适合安全连接到生产数据库

MongoDB操作

  • 读取操作:

- 查询具有可选执行计划分析的文档 - 执行聚合管道 - 统计符合条件的文档 - 获取集合架构信息

  • 写入操作 (非只读模式时):

- 更新文档 - 插入新文档 - 创建索引

LLM集成

  • 收集完成以增强LLM交互
  • 用于改进上下文理解的模式推理
  • 数据洞察的收集分析

安装

全球安装

npm install -g mcp-mongo-server

为了发展

# Clone repository
git clone https://github.com/kiliczsh/mcp-mongo-server.git
cd mcp-mongo-server

# Install dependencies
npm install

# Build
npm run build

# Development with auto-rebuild
npm run watch

用法

基本用法

# Start server with MongoDB URI
npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database

# Connect in read-only mode
npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database --read-only

环境变量

您可以使用环境变量配置服务器,这对于CI/CD管道、Docker容器或当您不想在命令参数中公开连接详细信息时特别有用:

# Set MongoDB connection URI
export MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database"

# Enable read-only mode
export MCP_MONGODB_READONLY="true"

# Run server (will use environment variables if no URI is provided)
npx -y mcp-mongo-server

在Claude Desktop配置中使用环境变量:

{
  "mcpServers": {
    "mongodb-env": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server"
      ],
      "env": {
        "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database",
        "MCP_MONGODB_READONLY": "true"
      }
    }
  }
}

在Docker中使用环境变量:

# Build
docker build -t mcp-mongo-server .

# Run
docker run -it -d -e MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database" -e MCP_MONGODB_READONLY="true" mcp-mongo-server

# or edit docker-compose.yml and run
docker-compose up -d

与Claude Desktop集成

手动配置

将服务器配置添加到Claude Desktop的配置文件中:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%/Claude/claude_desktop_config.json

命令行参数方法:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server",
        "mongodb://muhammed:kilic@localhost:27017/database"
      ]
    },
    "mongodb-readonly": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server",
        "mongodb://muhammed:kilic@localhost:27017/database",
        "--read-only"
      ]
    }
  }
}

环境变量方法:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server"
      ],
      "env": {
        "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database"
      }
    },
    "mongodb-readonly": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server"
      ],
      "env": {
        "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database",
        "MCP_MONGODB_READONLY": "true"
      }
    }
  }
}

GitHub包用法:

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "github:kiliczsh/mcp-mongo-server",
        "mongodb://muhammed:kilic@localhost:27017/database"
      ]
    },
    "mongodb-readonly": {
      "command": "npx",
      "args": [
        "-y",
        "github:kiliczsh/mcp-mongo-server",
        "mongodb://muhammed:kilic@localhost:27017/database",
        "--read-only"
      ]
    }
  }
}

与Windsurf和Cursor集成

MCP MongoDB服务器可以与Windsurf和Cursor以类似于Claude Desktop的方式一起使用。

风帆配置

将服务器添加到Windsurf配置中:

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

光标配置

对于Cursor,将服务器配置添加到您的设置中:

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

您还可以将环境变量方法用于Windsurf和Cursor,遵循Claude Desktop配置中显示的相同模式。

自动化安装

使用Smithery:

npx -y @smithery/cli install mcp-mongo-server --client claude

使用mcp get:

npx @michaellatman/mcp-get@latest install mcp-mongo-server

可用工具

查询操作

  • 怎么翻译:执行MongoDB查询
  {
    collection: "users",
    filter: { age: { $gt: 30 } },
    projection: { name: 1, email: 1 },
    limit: 20,
    explain: "executionStats"  // Optional
  }
  • 合计:运行聚合管道
  {
    collection: "orders",
    pipeline: [
      { $match: { status: "completed" } },
      { $group: { _id: "$customerId", total: { $sum: "$amount" } } }
    ],
    explain: "queryPlanner"  // Optional
  }
  • 计数:统计匹配的文档
  {
    collection: "products",
    query: { category: "electronics" }
  }

写入操作

  • 更新:修改文档
  {
    collection: "posts",
    filter: { _id: "60d21b4667d0d8992e610c85" },
    update: { $set: { title: "Updated Title" } },
    upsert: false,
    multi: false
  }
  • 插入:添加新文档
  {
    collection: "comments",
    documents: [
      { author: "user123", text: "Great post!" },
      { author: "user456", text: "Thanks for sharing" }
    ]
  }
  • 创建指数:创建集合索引
  {
    collection: "users",
    indexes: [
      {
        key: { email: 1 },
        unique: true,
        name: "email_unique_idx"
      }
    ]
  }

系统操作

  • 服务器信息:获取MongoDB服务器详细信息
  {
    includeDebugInfo: true  // Optional
  }

调试

由于MCP服务器通过stdio进行通信,调试可能具有挑战性。使用MCP检查器以获得更好的可见性:

npm run inspector

这将提供一个URL,用于访问浏览器中的调试工具。

运行评估

evals包加载一个mcp客户端,然后运行index.ts文件,因此不需要在测试之间重建。您可以通过在npx命令前加前缀来加载环境变量。可以找到完整的文档 这里.

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts src/schemas/tools.ts

许可证

此MCP服务器根据MIT许可证获得许可。这意味着您可以根据MIT许可证的条款和条件自由使用、修改和分发软件。有关更多详细信息,请参阅项目存储库中的LICENSE文件。

目录标签

目录标签

数据库操作TypeScriptClaudedeveloper-toolsmongomongodbmcpcursorclinewindsurfMongoDB接口本地部署LLM集成智能ID处理只读模式

支持客户端

ClaudeCursorWindsurfClineClaude Desktop

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

mcp-mongo-server

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP