Token导航 LogoToken导航

MCP Server · AI代理

Mongo Server Main

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

stdio官方级别未说明来源级核验工具 7mcp-mongo-server
数据库操作TypeScriptClaudeClaude DesktopCursorWindsurf

快速开始

作者 / 组织
Vynr1504
提供方
Vynr1504
运行时
Node.js

工具数量

7

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

Mongo Server Main 属于AI代理类 MCP Server,公开资料标注 7 个工具,通过stdio 本地进程接入,适配 Claude Desktop、Claude、Cursor,有可以直接复制的安装命令;接入前先确认权限范围。

分类

AI代理

传输方式

stdio

认证方式

无需认证

部署方式

公开资料未说明

安装与配置

安装命令

npx -y mcp-mongo-server mongodb://vynr:1504@localhost:27017/database

客户端配置示例

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

按公开安装命令拼出来的示例,字段名和参数以仓库 README 为准;带 YOUR_API_KEY 这类占位符的位置记得换成自己的值。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 7 个工具,随便调一个只读工具确认能返回结果。

接入前确认

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

详细介绍

MCP MongoDB Server


A Model Context Protocol server that enables LLMs to interact with MongoDB databases. This server provides capabilities for inspecting collection schemas and executing MongoDB operations through a standardized interface.

Demo

Key Features

Smart ObjectId Handling

  • Intelligent conversion between string IDs and MongoDB ObjectId
  • Configurable with objectIdMode parameter:

- "auto": Convert based on field names (default) - "none": No conversion - "force": Force all string ID fields to ObjectId

Flexible Configuration

  • Environment Variables:

- MCP_MONGODB_URI: MongoDB connection URI - MCP_MONGODB_READONLY: Enable read-only mode when set to "true"

  • Command-line Options:

- --read-only or -r: Connect in read-only mode

Read-Only Mode

  • Protection against write operations (update, insert, createIndex)
  • Uses MongoDB's secondary read preference for optimal performance
  • Ideal for safely connecting to production databases

MongoDB Operations

  • Read Operations:

- Query documents with optional execution plan analysis - Execute aggregation pipelines - Count documents matching criteria - Get collection schema information

  • Write Operations (when not in read-only mode):

- Update documents - Insert new documents - Create indexes

LLM Integration

  • Collection completions for enhanced LLM interaction
  • Schema inference for improved context understanding
  • Collection analysis for data insights

Installation

Global Installation

npm install -g mcp-mongo-server
# Clone repository
git clone https://github.com/Vynr1504/mcp-mongo-server-main.git
cd mcp-mongo-server

# Install dependencies
npm install

# Build
npm run build

# Development with auto-rebuild
npm run watch

Usage

Basic Usage

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

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

Environment Variables

You can configure the server using environment variables, which is particularly useful for CI/CD pipelines, Docker containers, or when you don't want to expose connection details in command arguments:

# Set MongoDB connection URI
export MCP_MONGODB_URI="mongodb://vynr:1504@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

Using environment variables in Claude Desktop configuration:

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

Using environment variables with Docker:

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

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

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

Integration with Claude Desktop

Manual Configuration

Add the server configuration to Claude Desktop's config file:

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

Command-line Arguments Approach:
{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server",
        "mongodb://vynr:1504@localhost:27017/database"
      ]
    },
    "mongodb-readonly": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server",
        "mongodb://vynr:1504@localhost:27017/database",
        "--read-only"
      ]
    }
  }
}
Environment Variables Approach:
{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server"
      ],
      "env": {
        "MCP_MONGODB_URI": "mongodb://vynr:1504@localhost:27017/database"
      }
    },
    "mongodb-readonly": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-mongo-server"
      ],
      "env": {
        "MCP_MONGODB_URI": "mongodb://vynr:1504@localhost:27017/database",
        "MCP_MONGODB_READONLY": "true"
      }
    }
  }
}

GitHub Package Usage:

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

Integration with Windsurf and Cursor

The MCP MongoDB Server can be used with Windsurf and Cursor in a similar way to Claude Desktop.

Windsurf Configuration

Add the server to your Windsurf configuration:

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

Cursor Configuration

For Cursor, add the server configuration to your settings:

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

You can also use the environment variables approach with both Windsurf and Cursor, following the same pattern shown in the Claude Desktop configuration.

Automated Installation

Using Smithery:

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

Available Tools

Query Operations

  • query: Execute MongoDB queries
  {
    collection: "users",
    filter: { age: { $gt: 30 } },
    projection: { name: 1, email: 1 },
    limit: 20,
    explain: "executionStats"  // Optional
  }
  • aggregate: Run aggregation pipelines
  {
    collection: "orders",
    pipeline: [
      { $match: { status: "completed" } },
      { $group: { _id: "$customerId", total: { $sum: "$amount" } } }
    ],
    explain: "queryPlanner"  // Optional
  }
  • count: Count matching documents
  {
    collection: "products",
    query: { category: "electronics" }
  }

Write Operations

  • update: Modify documents
  {
    collection: "posts",
    filter: { _id: "60d21b4667d0d8992e610c85" },
    update: { $set: { title: "Updated Title" } },
    upsert: false,
    multi: false
  }
  • insert: Add new documents
  {
    collection: "comments",
    documents: [
      { author: "user123", text: "Great post!" },
      { author: "user456", text: "Thanks for sharing" }
    ]
  }
  • createIndex: Create collection indexes
  {
    collection: "users",
    indexes: [
      {
        key: { email: 1 },
        unique: true,
        name: "email_unique_idx"
      }
    ]
  }

System Operations

  • serverInfo: Get MongoDB server details
  {
    includeDebugInfo: true  // Optional
  }

Debugging

Since MCP servers communicate over stdio, debugging can be challenging. Use the MCP Inspector for better visibility:

npm run inspector

This will provide a URL to access the debugging tools in your browser.

Running evals

The evals package loads an mcp client that then runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command. Full documentation can be found here.

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

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

工具与能力

工具数量

7

资源数量

0

提示词数量

0

能力标签

MongoDB接口TypeScript本地部署LLM集成数据库操作协议服务器智能ID处理

支持客户端

Claude DesktopClaudeCursorWindsurf

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

多步任务编排

把拆解、检索、执行串成一条链,模型按步骤调用工具。

长期上下文

把会话、笔记和知识放到外部存储,换个会话还能接着做。

接自有流程

把内部系统和模型连起来,让助手调用已有的工作流。

选择建议

值得选的地方

  • 只提供 7 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已经适配 Claude Desktop、Claude、Cursor,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好 Node.js,换机器要重新装一遍。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Mongo Server Main

MCP World · 本页

7stdio有1 个2026-05-17
Everything Claude Code

MCP World

0stdio有1 个2026-05-17
Filesystem 560c4363

MCP World

13未说明未标注2 个2026-05-17
Time 7365cb6d

MCP.so

2SSE有2 个2026-05-17
Server Everything (everything)

MCP World

11stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Mongo Server Main 怎么安装?

公开资料给出的安装命令是 npx -y mcp-mongo-server mongodb://vynr:1504@localhost:27017/database,运行环境为 Node.js。装完后按客户端要求写进 MCP 配置,重启客户端生效。

Mongo Server Main 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Node.js;保存后完全退出客户端再打开,配置才会生效。

Mongo Server Main 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Mongo Server Main 需要 API Key 吗?

公开资料标注为无需认证,装好就能连;如果实际调用时报鉴权错误,按官方文档补上凭据。

Mongo Server Main 支持哪些客户端?

公开资料标注支持 Claude Desktop、Claude、Cursor、Windsurf;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

来源信息

继续浏览同类 MCP