MongoDB MCP Server
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.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MongoDB MCP Serverlist all collections in my ecommerce database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π 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
Related MCP server: MongoDB MCP Server
π 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 installConfigure 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.tsOr 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 testTests 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
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.34MIT
- Alicense-qualityDmaintenanceA powerful Model Context Protocol (MCP) server implementation that provides standardized interaction with MongoDB databases, supporting complete CRUD operations, async patterns, and real-time updates via SSE.MIT
- AlicenseAqualityBmaintenanceA Model Context Protocol server that enables interaction with MongoDB databases and MongoDB Atlas, allowing users to perform database operations and manage Atlas resources through natural language.22187,267Apache 2.0
- Alicense-qualityDmaintenanceA Model Context Protocol (MCP) server for MongoDB operations, enabling AI assistants to interact with MongoDB databases through a standardized interface.284MIT
Related MCP Connectors
MCP (Model Context Protocol) server for Appwrite
MCP server for managing Prisma Postgres.
A MCP server built for developers enabling Git based project management with project and personalβ¦
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/franciscorojas27/McpServerMongodb'
If you have feedback or need assistance with the MCP directory API, please join our Discord server