================== /// MCP /// /// MCP /// ================== [server:online] [protocol:ready]
mcp-mongo-server
by kiliczsh
Model-Context-Protocol (MCP) server that lets LLMs inspect schemas and run queries/aggregations on MongoDB, with optional read-only mode and smart ObjectId conversion.
249
40
Open Source01
query
Execute MongoDB queries
02
aggregate
Run aggregation pipelines
03
count
Count matching documents
04
update
Modify documents
05
insert
Add new documents
06
createIndex
Create collection indexes
07
serverInfo
Get MongoDB server details
Installation
1. Prerequisites
• Node.js ≥ 18 and npm/yarn/pnpm
• Running MongoDB (local Docker container or remote cluster).
Example local Docker:
docker run -d -p 27017:27017 --name mongo mongo:7
2. Install the server package
Global CLI (recommended for quick start):
npm install -g mcp-mongo-server
Project dependency:
npm install mcp-mongo-server --save
3. Create a minimal configuration file (mcp.config.js / mcp.config.mjs)
module.exports = {
dbUri: process.env.MONGO_URI || "mongodb://localhost:27017/mcp", // Mongo connection string
port: process.env.MCP_PORT || 8080, // HTTP port
apiKey: process.env.MCP_API_KEY, // optional auth key
collections: ["documents"] // mongo collections to search
};
4. Launch the server
• From CLI (global):
• With npx:
mcp-mongo-server --config ./mcp.config.js
npx mcp-mongo-server --config ./mcp.config.js
5. Verify
-e MONGO_URI=mongodb://host.docker.internal:27017/mcp \
-e MCP_API_KEY=secret123 \
-p 8080:8080 kiliczsh/mcp-mongo-server
curl http://localhost:8080/health → 200 OK
Environment Variables quick-start
export MONGO_URI="mongodb://localhost:27017/mcp"
export MCP_PORT=8080
export MCP_API_KEY=secret123
mcp-mongo-server
Docker
docker run -d \
TypeScript projects can also import and embed the server:
import { createServer } from 'mcp-mongo-server';
createServer({ dbUri: 'mongodb://…' }).start();
Documentation
License: MIT License
Updated 7/15/2025