McpServerMongodb
McpServerMongodb is an implementation of a MongoDB server built with TypeScript. It offers basic functionalities but has zero stars, indicating a lack of community support. The documentation and support may be limited, so caution is advised when using it.
GitHub Stars
0
User Rating
Not Rated
Favorites
0
Views
6
Forks
0
Issues
0
π 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
βββ 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.mjs
extension for ESM compatibility.ESM, TypeScript, and path aliases are fully supported in tests.
Example test import (in a
.mjs
test 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
.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
0
Followers
0
Repositories
0
Gists
0
Total Contributions
The MongoDB MCP server provides a standardized interface for AI systems to access and manage MongoDB databases. It enables various operations such as creating databases and collections, inserting data, querying using natural language, managing product reviews and inventory, handling support tickets, and generating analytics insights.