mcpField
M
Mcp Mongodb

Mcp Mongodb

Local
github.com/nan-qinDatabases0Updated 60w ago

About Mcp Mongodb

Mcp Mongodb is an MCP server project for working with MongoDB databases. Its examples distinguish tool-based operations from read-only resource access and include a multi-collection aggregation query.

Key features

  1. 01MongoDB resource reads
  2. 02Collection-list and insert operations
  3. 03Multi-collection aggregation query

Use cases

  1. 01Reading database resources
  2. 02Listing collections or inserting data
  3. 03Joining collections with an aggregation pipeline

MCP support

The MCP server exposes MongoDB operations as tools and read-only database content as resources. The README includes a resource URI example and a multi-collection query tool example.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MCP 配置文件

{
  "mcpServers": {
    "mongodb": {
      "command": "node",
      "args": [
        "E:\\project\\mongodb\\build\\index2.js"
      ],
      "env": {
        "MONGO_URI": "mongodb://localhost:27017/"
      },
      "disabled": false,
      "autoApprove": []
    },
  }
}

读取资源请求示例:

<use_mcp_tool> <server_name>mongodb</server_name> <tool_name>read_resource</tool_name>

{ "uri": "mongodb://localhost:27017/common" }

</use_mcp_tool>

CallToolRequestSchema、ReadResourceRequestSchema 的区别

CallToolRequestSchema: 用于执行特定操作 适合执行命令、处理数据等主动操作 示例:获取集合列表、插入数据等

ReadResourceRequestSchema: 用于读取资源内容 适合提供对资源的只读访问 示例:读取集合文档、获取数据库状态等

多表联查示例

<use_mcp_tool> <server_name>mongodb</server_name> <tool_name>multi_collection_query</tool_name>

{ "database": "common", "collection": "players", "pipeline": [ { "$lookup": { "from": "platform", "localField": "platform", "foreignField": "appKey", "as": "platformInfo" } }, { "$unwind": "$platformInfo" }, { "$project": { "_id": 1, "pid": 1, "__v": 1, "bank": 1, "ip": 1, "lobbyUrl": 1, "platform": "$platformInfo", "rtp": 1, "_collection": { "$literal": "players" } } }, { "$limit": 2 } ] }

</use_mcp_tool>

修改托送测试test

pull-request

漫长的过程

跑一下试试

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.