MongoDB MCP Server
A modular server that enables management of MongoDB databases, collections, documents, indexes, and bulk operations through the Model Context Protocol (MCP) interface.
README
🚀 MongoDB MCP Server
A modular, well-documented server for managing MongoDB databases, collections, documents, indexes, and bulk operations using the Model Context Protocol (MCP). Built for extensibility, clarity, and ease of use. Fully compatible with ESM, TypeScript, and modern testing workflows.
✨ Features
- 📦 Register and manage MongoDB databases, collections, documents, indexes, and bulk operations via MCP tools
- ⚡ Bulk operations support
- 📝 Fully documented codebase (English, JSDoc)
- ⚙️ Easy configuration via
config.json - 🧩 Clean, modular architecture
- 🧪 Automated tests with Jest, ts-jest, and in-memory MongoDB
- 🔗 Modern ESM + TypeScript + path aliases
- 🧾 Test files use
.mjsextension for full ESM compatibility with Jest
📁 Project Structure
├── src/
│ ├── main.ts # Main entry point, server initialization
│ ├── config.json # MongoDB connection config
│ ├── mongo/ # MongoDB operation classes
│ └── tools/ # MCP tool registration modules
├── tests/ # Jest test suites (in-memory MongoDB, .mjs)
├── package.json
├── tsconfig.json
├── jest.config.cjs
└── README.md
🚦 Getting Started
Prerequisites
- Node.js (v18+ recommended)
- TypeScript
- MongoDB instance (local or remote)
Installation
-
Clone the repository:
git clone <your-repo-url> cd <your-repo> -
Install dependencies:
npm install -
Configure your MongoDB URI in
src/config.json:{ "mongo_uri": "mongodb://localhost:27017" }
🏃 Running the Server
You can run the server using tsx:
npx tsx src/main.ts
Or use the provided VS Code launch configuration.
⚙️ VS Code MCP Integration Example
To use this server as an MCP backend in VS Code, add the following to your settings.json:
"mcp": {
"inputs": [],
"servers": {
"mongo-local": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"tsx",
"C:/Users/<your-username>/Desktop/McpServerMongodb/src/main.ts"
]
}
}
},
- Replace
<your-username>with your actual Windows username or adjust the path to where your project is located. - This will allow VS Code to launch your MCP MongoDB server as a local backend.
🧪 Running Tests
All core logic is covered by automated tests using Jest, ts-jest, and mongodb-memory-server for a real MongoDB environment in-memory (no external DB required).
npm test
-
Tests are located in the
tests/directory and use the.mjsextension for ESM compatibility. -
ESM, TypeScript, and path aliases are fully supported in tests.
-
Example test import (in a
.mjstest file):import { MongoDatabaseOps } from "@mongo/mongoDatabaseOps.js";
🛠️ Usage & Development
- The server exposes MCP tools for database, collection, document, index, and bulk operations.
- You can extend or customize tools in the
src/tools/directory. - All business logic for MongoDB operations is in
src/mongo/. - Use path aliases (
@mongo/,@tools/) for clean imports. - All code and tests use ESM imports with explicit
.jsextensions for internal modules. - All Jest test files must use the
.mjsextension for full ESM compatibility.
🧑💻 Code Quality
- All files are documented in English using JSDoc.
- Modular and maintainable structure.
- Follows best practices for clarity and extensibility.
- Robust error handling and configuration management.
🧩 ESM, TypeScript & Jest Notes
- Project uses ESM (
type: "module"),moduleResolution: "nodenext", and path aliases intsconfig.json. - Jest is configured to transform ESM dependencies (e.g.,
mongodb-memory-server) and support TypeScript/ESM viats-jest. - All internal imports must use
.jsextensions for ESM compatibility. - All Jest test files must use the
.mjsextension for ESM compatibility. - See
jest.config.cjsandtsconfig.jsonfor details.
👤 Author
Francisco Antonio Rojas Fariña
📄 License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。