Nodejs Mongodb
БесплатноНе проверенMCP server that exposes MongoDB business data via tools for summary statistics, new users, and pending payments.
Описание
MCP server that exposes MongoDB business data via tools for summary statistics, new users, and pending payments.
README
Simple MCP (Model Context Protocol) server built with Node.js, TypeScript, the official MCP SDK, and MongoDB.
Features
This server provides three MCP tools:
get_business_summary- Returns:
- total users
- active users
- paid users
- pending payments
- new users (last 7 days)
- Returns:
get_new_users- Input:
days(number)
- Returns users created during the given period.
- Input:
get_pending_payments- Returns all customers with pending payments.
Transport
This server currently runs over stdio — the standard transport for local MCP servers. The client (e.g. Claude Desktop, Claude Code) launches this server as a subprocess and communicates over stdin/stdout. This is the right choice for a server that runs locally against your own database.
Note: The legacy HTTP+SSE transport is deprecated in the MCP spec in favor of Streamable HTTP. This repo doesn't implement a remote transport yet — stdio only, by design, for local use. Streamable HTTP support (for hosting this as a remote/shared server) is a possible future addition.
Project Structure
src/index.ts- MCP server and tool handlerssrc/config/env.ts- environment loadingsrc/db/mongo.ts- MongoDB connection helpersrc/services/users.ts- MongoDB queries for tool responsesseed/seed.ts- sample MongoDB seed script.env.example- required environment variables
Setup
- Install dependencies:
npm install
- Create your env file:
cp .env.example .env
- Update
.envvalues:
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB_NAME=mcp_business
Works with a local MongoDB (including Docker) or MongoDB Atlas — just use the appropriate connection string (mongodb://... for local, mongodb+srv://... for Atlas).
4. Seed sample data:
npm run seed
- Build the server:
npm run build
This compiles to dist/src/index.js (note: nested under dist/src/, not directly in dist/).
6. Run the MCP server over stdio:
npm start
Development
Run directly with TypeScript:
npm run dev
Connecting to Claude Desktop (macOS)
- Build the project first (
npm install && npm run build) and note the absolute path todist/src/index.js. - Find your Node binary path:
which node(if you usenvm, this will be a versioned path like~/.nvm/versions/node/vX.X.X/bin/node). - Open Claude Desktop's config file:
~/Library/Application Support/Claude/claude_desktop_config.json - Add a
mcpServersentry (merge with any existing config — don't overwrite the whole file):
Use an absolute path to your Node binary, not just{ "mcpServers": { "mongodb-business": { "command": "/absolute/path/to/node", "args": ["/absolute/path/to/nodejs-mcp-mongodb/dist/src/index.js"], "env": { "MONGODB_URI": "mongodb://localhost:27017", "MONGODB_DB_NAME": "mcp_business" } } } }"node"— GUI apps on macOS don't always inherit your shell's PATH. - Fully quit Claude Desktop (Cmd+Q) and reopen it — the config is only read on startup.
- Check the tools/connectors panel in the chat box for
mongodb-businesswith its 3 tools listed.
Troubleshooting
- "Server disconnected" /
MODULE_NOT_FOUND: Double-check the build output path isdist/src/index.js, notdist/index.js. - Tool calls fail with a generic internal error: Check the MCP log at
~/Library/Logs/Claude/mcp-server-<name>.logon macOS. If the log doesn't show a clear cause, test the server directly by piping a JSON-RPC request into it via stdin to see the raw error. - Works when run manually but not from Claude Desktop: Usually an environment variable mismatch — confirm the
envblock inclaude_desktop_config.jsonexactly matches your working.envfile (the subprocess Claude Desktop spawns does not inherit your shell's environment). - Using MongoDB Atlas: make sure your current IP is allowlisted under Atlas → Network Access, and that any special characters in your password are URL-encoded in the connection string.
- First tool call fails, and every retry after fails identically: this indicates a failed initial DB connection getting cached — restart the MCP server process (fully quit and reopen the client) to clear it.
Known Limitations
- No remote transport (stdio only) — not yet suitable for multi-client/hosted use.
- No automated tests yet.
- Query results from
get_new_users/get_pending_paymentsare not paginated or capped — fine for demo-scale data, but should be limited before pointing this at a large production collection.
Установка Nodejs Mongodb
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/kawaljain/nodejs-mcp-mongodbFAQ
Nodejs Mongodb MCP бесплатный?
Да, Nodejs Mongodb MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Nodejs Mongodb?
Нет, Nodejs Mongodb работает без API-ключей и переменных окружения.
Nodejs Mongodb — hosted или self-hosted?
Доступен hosted-вариант: Unyly запускает сервер в облаке, локальная установка не обязательна.
Как установить Nodejs Mongodb в Claude Desktop, Claude Code или Cursor?
Открой Nodejs Mongodb на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
GitHub
PRs, issues, code search, CI status
автор: GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
автор: mcpdotdirectCompare Nodejs Mongodb with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development
