Get the FREE Ultimate OpenClaw Setup Guide →

mongo

MCP server for mongoDB

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio matteturtle09-mongo-mcp-server npx -y mongo-mcp-server \
  --env MONGO_URI="MongoDB connection string (e.g., mongodb://user:pass@host:port/db)"

How to use

This MCP server exposes MongoDB querying capabilities through MCP tools. The primary tool available is get-collection-documents, which retrieves documents from a specified collection within a database. To use it, provide the collection name and database name; the server will return a list of documents present in that collection. The tool is useful for quick data inspection, debugging queries, and integrating MongoDB data retrieval into larger MCP workflows.

How to install

Prerequisites:

  • Node.js and npm installed on your machine
  • Network access to the MongoDB instance you intend to query

Installation steps:

  1. Ensure npm is up to date:
npm install -g npm
  1. Install or run the MCP server via npx (no local install required):
npx -y mongo-mcp-server
  1. Alternatively, install the package locally or globally if you prefer:
npm install mongo-mcp-server
  1. Configure the MongoDB connection string via environment variables (see mcp_config for env vars).
  2. Start the server and begin issuing MCP tool calls (e.g., get-collection-documents).

Note: If your environment requires authentication or TLS, ensure MONGO_URI provides the appropriate connection string.

Additional notes

Environment variables:

  • MONGO_URI: Required. The MongoDB connection string. Example: mongodb://user:password@host:27017/database Common issues:
  • Unable to connect: verify network access to MongoDB, correct host/port, and authentication credentials in MONGO_URI.
  • Missing collection or database: ensure the collection and database names are correct and exist.
  • Timeouts: consider increasing server timeout settings if querying large collections. Configuration options may vary depending on the MCP server implementation; consult the project's docs for any additional flags or capabilities.

Related MCP Servers

Sponsor this space

Reach thousands of developers