mongo-mcp
A local MCP server that connects Claude Desktop to a MongoDB database, enabling listing, finding, adding, and deleting users via natural language.
README
mongo-mcp
A local MCP (Model Context Protocol) server that connects Claude Desktop to a real MongoDB database running in Docker. Supports listing, finding, adding, and deleting users via natural language in Claude.
What It Does
Exposes four tools Claude can call:
| Tool | What it does |
|---|---|
list_users |
Returns all users in the database |
get_user |
Finds a user by name or email |
add_user |
Adds a new user with duplicate email check |
delete_user |
Deletes a user by their MongoDB _id |
Prerequisites
| Requirement | Version |
|---|---|
| Node.js | v18 or higher |
| Docker Desktop | Latest |
| Claude Desktop | Latest |
Step 1 — Install Docker Desktop
- Download Docker Desktop from docker.com/products/docker-desktop
- Run the installer — all defaults are fine
- When prompted to enable WSL2, click Yes
- Restart your computer after installation
- Open Docker Desktop and wait for it to fully start (whale icon appears in system tray)
If your WSL is outdated, open PowerShell as Administrator and run:
wsl --update
Verify Docker works by opening a regular PowerShell (not as Administrator) and running:
docker --version
Step 2 — Run MongoDB in Docker
Pull the official MongoDB image (one time only):
docker pull mongo
Start a MongoDB container:
docker run -d --name mongodb -p 27017:27017 mongo
What each flag means:
-d— runs in the background so it doesn't lock your terminal--name mongodb— gives the container a name you can reference later-p 27017:27017— maps MongoDB's port to your machine so Node.js can connect vialocalhost:27017
Verify it's running:
docker ps
You should see mongodb in the list with status Up.
Test that MongoDB is responding:
docker exec -it mongodb mongosh --eval "db.runCommand({ ping: 1 })"
You should see { ok: 1 }.
Managing the container day to day
You only need docker run once. After that:
# Start MongoDB
docker start mongodb
# Stop MongoDB
docker stop mongodb
# Check if it's running
docker ps
Step 3 — Clone and Install
git clone https://github.com/YOUR_USERNAME/mongo-mcp.git
cd mongo-mcp
npm install
Step 4 — Verify the Server Runs
Make sure MongoDB is running first (docker start mongodb), then:
node server.js
You should see:
Connected to MongoDB
The server will sit and wait — that's normal. Hit Ctrl+C to stop it.
Step 5 — Connect to Claude Desktop
Claude Desktop reads its config from a JSON file. The correct path depends on how Claude was installed.
Finding your config file
Microsoft Store / MSIX install:
Run this in PowerShell to open the file Claude actually reads:
$pkg = (Get-AppxPackage -Name "*Claude*").PackageFamilyName
$cfg = Join-Path $env:LOCALAPPDATA "Packages\$pkg\LocalCache\Roaming\Claude\claude_desktop_config.json"
notepad $cfg
⚠️ The "Edit Config" button inside Claude Desktop opens a different file that the Store version does not read. Always use the PowerShell command above.
Classic install:
%APPDATA%\Claude\claude_desktop_config.json
Config format
Add mongo-mcp to the mcpServers block. Merge it in alongside any existing servers — do not overwrite the whole file.
{
"mcpServers": {
"mongo-mcp": {
"command": "C:\\Program Files\\nodejs\\node.exe",
"args": [
"C:\\Users\\YOUR_USERNAME\\mongo-mcp\\server.js"
]
}
}
}
Replace:
C:\\Program Files\\nodejs\\node.exewith your actual Node.js path. Find it withwhere.exe nodein PowerShell.YOUR_USERNAMEwith your Windows username.
⚠️ Windows paths in JSON require double backslashes. A single
\will cause the config to fail silently.
Fully restart Claude Desktop
Closing the window is not enough — Claude keeps running in the system tray.
- Right-click the Claude icon in the system tray
- Select Quit
- Relaunch Claude Desktop
Verify the connection
$pkg = (Get-AppxPackage -Name "*Claude*").PackageFamilyName
$logDir = Join-Path $env:LOCALAPPDATA "Packages\$pkg\LocalCache\Roaming\Claude\logs"
Get-Content "$logDir\mcp.log" -Tail 20
You should see:
[info] [mongo-mcp] Server started and connected successfully
[info] [mongo-mcp] Message from server: {"result":{"tools":[{"name":"list_users"...}]}}
Testing
Ask Claude these in order:
"List all users"— should say no users yet"Add a user named Dharhshini with email d@example.com""Add a user with email d@example.com"— should block duplicate"List all users"— should show the new user"Find the user named Dharhshini""Find the user with email d@example.com""Delete the user with ID [paste _id from step 4]""List all users"— should be empty again
Project Structure
mongo-mcp/
├── server.js # MCP server with all four tools
├── package.json
└── README.md
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Connected to MongoDB not shown |
MongoDB container not running | Run docker start mongodb |
| Server not appearing in Claude | Wrong config path or single backslashes | Use the PowerShell command to find config, double all backslashes |
| Tools don't appear | Claude not fully restarted | Right-click tray → Quit, then relaunch |
Invalid ID format on delete |
Copied ID incorrectly | Copy the full _id value from list output |
Built With
- Model Context Protocol SDK —
@modelcontextprotocol/sdk - MongoDB Node.js Driver —
mongodb - Zod —
zod - Docker
- Claude Desktop
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 模型以安全和受控的方式获取实时的网络信息。