Includes automated tests with Jest and ts-jest, utilizing in-memory MongoDB for testing database operations without requiring an external MongoDB instance.
Provides tools for managing MongoDB databases, collections, documents, indexes, and bulk operations, allowing users to register and interact with MongoDB instances through the MCP protocol.
Runs on Node.js (v18+ recommended) and leverages ESM modules for a modern JavaScript development experience when working with MongoDB.
Built with full TypeScript support, providing type safety and modern development workflows for MongoDB operations through the MCP protocol.
🚀 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
.mjs
extension for full ESM compatibility with Jest
📁 Project Structure
🚦 Getting Started
Prerequisites
- Node.js (v18+ recommended)
- TypeScript
- MongoDB instance (local or remote)
Installation
- Clone the repository:
- Install dependencies:
- Configure your MongoDB URI in
src/config.json
:
🏃 Running the Server
You can run the server using tsx:
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
:
- 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).
- Tests are located in the
tests/
directory and use the.mjs
extension for ESM compatibility. - ESM, TypeScript, and path aliases are fully supported in tests.
- Example test import (in a
.mjs
test file):
🛠️ 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
.js
extensions for internal modules. - All Jest test files must use the
.mjs
extension 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
.js
extensions for ESM compatibility. - All Jest test files must use the
.mjs
extension for ESM compatibility. - See
jest.config.cjs
andtsconfig.json
for details.
👤 Author
Francisco Antonio Rojas Fariña
📄 License
MIT
This server cannot be installed
A modular server that enables management of MongoDB databases, collections, documents, indexes, and bulk operations through the Model Context Protocol (MCP) interface.
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 access to MongoDB databases. This server enables LLMs to inspect collection schemas and execute read-only queries.Last updated -8817217TypeScriptMIT License
- -securityAlicense-qualityAn MCP server that enables users to create and manage MongoDB Atlas clusters, users, and network access through natural language commands.Last updated -7410JavaScriptMIT License
- -securityAlicense-qualityAn MCP server that enables large language models to interact directly with MongoDB databases, allowing them to query collections, inspect schemas, and manage data through natural language.Last updated -340MIT License