nodejs-mcp-mongodb
This server provides MCP tools for querying a MongoDB database for business metrics and user data. It includes three tools:
get_business_summary: Returns a summary with total users, active users, paid users, pending payments, and new users from the last 7 days.
get_new_users: Accepts a
daysparameter (1 or more) and returns users created within that period.get_pending_payments: Returns all customers with pending payments.
The server operates locally over stdio, designed for MCP clients like Claude Desktop. It can connect to local or Atlas MongoDB instances via environment variables configuration, and also supports seeding sample data for testing.
Provides tools for querying MongoDB to retrieve business summaries, new users, and pending payments from a MongoDB database.
Click on "Deploy 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., "@nodejs-mcp-mongodb Show me the business summary"
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.
nodejs-mcp-mongodb
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_summaryReturns:
total users
active users
paid users
pending payments
new users (last 7 days)
get_new_usersInput:
days(number)
Returns users created during the given period.
get_pending_paymentsReturns all customers with pending payments.
Related MCP server: jobs-mcp-server
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 installCreate your env file:
cp .env.example .envUpdate
.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 seedBuild 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 startDevelopment
Run directly with TypeScript:
npm run devConnecting 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.jsonAdd a
mcpServersentry (merge with any existing config — don't overwrite the whole file):{ "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" } } } }Use an absolute path to your Node binary, not just
"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.
Available Tools
3 toolsget_business_summaryA
Get business summary metrics: total users, active users, paid users, pending payments, and new users in the last 7 days
Inputs: no named parameters.
get_new_usersA
Get users created within the last N days
Inputs: days (required).
get_pending_paymentsA
Get all customers with pending payments
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
get_business_summary provides aggregate metrics, while get_new_users and get_pending_payments return detailed lists. There is conceptual overlap since new users and pending payments are part of the summary, but the granularity difference helps distinguish them.
All three tools follow a consistent 'get_<noun>' pattern in snake_case, making the API naming predictable and uniform.
With three tools, the server is tightly scoped to business analytics. This is an appropriate size for a focused read-only reporting API.
The summary tool covers five metrics, but dedicated detail tools exist only for new users and pending payments. Missing detail tools for active users, paid users, and total users create an imbalance, though the core summary is present.
Maintenance
Related MCP Connectors
MCP server for the Seline Analytics API
MCP server for Codat — companies, connections, invoices, bills and financial statements.
MCP server for Product Management
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceFull featured MCP Server for MongoDB database analysis.61 npm207MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that exposes a MongoDB healthcare jobs collection, enabling listing, searching, creating, updating, deleting jobs and getting summary counts.-
- AlicenseNot gradedqualityDmaintenanceA lightweight MCP server for MongoDB 3.6+ providing read, write, metadata, and management tools.12 npm1MIT
- FlicenseAqualityDmaintenanceMCP server for the WhatsMyBudget Analytics API, providing tools to query budget periods, categories, accounts, and summaries.26-