# mcp-mongo-server

> MCP Server

The MCP MongoDB Server provides LLMs access to MongoDB databases, enabling schema inspection and operation execution through a Model Context Protocol, and supports read-only mode for enhanced safety.

## Overview

- **Category:** Database
- **Language:** JavaScript
- **Stars:** 283
- **Forks:** 8
- **Owner:** kiliczsh
- **GitHub:** https://github.com/kiliczsh/mcp-mongo-server
- **Homepage:** https://www.npmjs.com/package/mcp-mongo-server
- **Created:** 2024-12-04T19:30:40+00:00
- **Updated:** 2025-03-28T13:49:54+00:00
- **Source:** https://model-context-protocol.com/servers/mcp-mongodb-server-llm-database-access

## Setup

## Setup

1.  Install dependencies:

   ```bash
npm install
```

2.  Build the server:

   ```bash
npm run build
```

3.  For development with auto-rebuild:

   ```bash
npm run watch
```

4.  To use with Claude Desktop, add the server config to `claude_desktop_config.json` (On MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`, On Windows: `%APPDATA%/Claude/claude_desktop_config.json`) with the provided JSON configuration.

5.  Debugging: Use the MCP Inspector:

   ```bash
npm run inspector
```

6.  Install MCP MongoDB Server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/mcp-mongo-server):

   ```bash
npx -y @smithery/cli install mcp-mongo-server --client claude
```

7.  Install using mcp-get:

   ```bash
npx @michaellatman/mcp-get@latest install mcp-mongo-server
```

## Tools

## Available Tools

1.  Read-Only Mode (Connect to MongoDB in read-only mode to prevent write operations).
2.  Resources (List and access collections via `mongodb://` URIs).
3.  query (Execute MongoDB queries with optional execution plan analysis).
4.  aggregate (Execute MongoDB aggregation pipelines with optional execution plan analysis).
5.  update (Update documents in a collection).
6.  serverInfo (Get MongoDB server information and status).
7.  insert (Insert documents into a collection).
8.  createIndex (Create indexes on a collection).
9.  count (Count documents matching a query).
10. analyze_collection (Analyze collection structure and contents).
