MongoDB MCP Server is an MCP server that provides tools and prompts for interacting directly with a MongoDB database. Built using Node.js and Mongoose, this server allows developers and data engineers to manage user records within a MongoDB instance using standard Model Context Protocol clients like Claude for Desktop and Cursor. The server handles common database tasks through dedicated operations such as creating user profiles, looking up specific users by their unique email addresses, and retrieving paginated lists of stored users. It includes comprehensive error management and graceful shutdown routines that ensure database connections close cleanly during process termination signals. Designed with a single-file architecture, it serves both as a functional database adapter and as an educational reference implementation for connecting local or remote MongoDB instances to large language model interfaces.
Category: Databases & Data Stores
Tags: database, mongodb, nosql, query
bash git clone https://github.com/jb-7-jay/learn-mcp-server-mongo cd learn-mcp-mongo npm install 3. Copy the example environment file and set your database connection: bash cp .env.example .env 4. Update MONGODB_URI in .env if your configuration differs from mongodb://localhost:27017. 5. Register the server in Claude Desktop by editing ~/Library/Application Support/Claude/claude_desktop_config.json: json { "mcpServers": { "mcp-mongo": { "command": "node", "args": ["/absolute/path/to/server.js"] } } } 6. Restart Claude for Desktop to load the tools.Part of MCP Servers
The server includes three primary tools for user management: create-user to add a new document with name, email, and age; get-user to locate an individual record using an email address; and list-users to view stored documents with pagination support.
The server is built to work with any client supporting the Model Context Protocol, including Claude for Desktop and the Cursor code editor. Setup requires referencing the node executable and the absolute path to server.js in your client configuration.
You need the latest LTS release of Node.js and MongoDB version 8.0 or higher running locally or accessible via a remote connection string. A supported client like Claude for Desktop or Cursor is also required.
Copy the provided .env.example file to .env in the project directory, then update the MONGODB_URI variable with your custom MongoDB connection string before launching the server.