Cover image
mongodb-developer_mongodb-mcp-server
Public

mongodb-developer_mongodb-mcp-server

Try Now
2024-12-15

Mirror ofhttps://github.com/mongodb-developer/mongodb-mcp-server

3 years

Works with Finder

0

Github Watches

1

Github Forks

0

Github Stars

MongoDB MCP Server

A Model Context Protocol server that provides read-only access to MongoDB databases. This server enables LLMs to inspect collection schemas and execute aggregation pipelines.

Components

Tools

  • aggregate

    • Execute MongoDB aggregation pipelines against the connected database
    • Input:
      • collection (string): The collection to query
      • pipeline (array): MongoDB aggregation pipeline stages
      • options (object): Optional aggregation settings
        • allowDiskUse (boolean): Allow operations that require disk usage
        • maxTimeMS (number): Maximum execution time in milliseconds
        • comment (string): Comment to identify the operation
    • Default limit of 1000 documents if no limit stage is specified
    • Default timeout of 30 seconds
  • explain

    • Get execution plans for aggregation pipelines
    • Input:
      • collection (string): The collection to analyze
      • pipeline (array): MongoDB aggregation pipeline stages
      • verbosity (string): Detail level of the explanation
        • Options: "queryPlanner", "executionStats", "allPlansExecution"
        • Default: "queryPlanner"

Resources

The server provides schema information for each collection in the database:

  • Collection Schemas (mongodb://<host>/<collection>/schema)
    • Inferred JSON schema information for each collection
    • Includes field names and data types
    • Schema is derived from sampling collection documents

Usage with Claude Desktop

To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your claude_desktop_config.json:

"mongodb": {
      "command": "npx",
      "args": [
        "-y" ,
        "@pash1986/mcp-server-mongodb"
      ],
     "env" : {
	"MONGODB_URI" : "mongodb+srv://<yourcluster>" // 'mongodb://localhost:27017'
	}
    }

Replace mydb with your database name and adjust the connection string as needed.

Example Usage

Basic Aggregation

{
  "collection": "users",
  "pipeline": [
    { "$match": { "age": { "$gt": 21 } } },
    { "$group": {
      "_id": "$city",
      "avgAge": { "$avg": "$age" },
      "count": { "$sum": 1 }
    }},
    { "$sort": { "count": -1 } },
    { "$limit": 10 }
  ],
  "options": {
    "allowDiskUse": true,
    "maxTimeMS": 60000,
    "comment": "City-wise user statistics"
  }
}

Query Explanation

{
  "collection": "users",
  "pipeline": [
    { "$match": { "age": { "$gt": 21 } } },
    { "$sort": { "age": 1 } }
  ],
  "verbosity": "executionStats"
}

Safety Features

  • Automatic limit of 1000 documents if no limit is specified in the pipeline
  • Default timeout of 30 seconds for all operations
  • Read-only operations only
  • Safe schema inference from collection samples

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • https://duotify.com
  • Professional code reviewer for a unique language, friendly and helpful.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Andris Teikmanis
  • Latvian GPT assistant for developing GPT applications

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Navid RezaeiSarchoghaei
  • Professional Flask/SQLAlchemy code guide. Follow: https://x.com/navid_re

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • https://cantaspinar.com
  • Summarizes videos and answers related questions.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • apappascs
  • Discover the most comprehensive and up-to-date collection of MCP servers in the market. This repository serves as a centralized hub, offering an extensive catalog of open-source and proprietary MCP servers, complete with features, documentation links, and contributors.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • OffchainLabs
  • Go implementation of Ethereum proof of stake

  • huahuayu
  • A unified API gateway for integrating multiple etherscan-like blockchain explorer APIs with Model Context Protocol (MCP) support for AI assistants.

  • deemkeen
  • control your mbot2 with a power combo: mqtt+mcp+llm

    Reviews

    4 (1)
    Avatar
    user_rqBfS14Z
    2025-04-15

    I recently used "Simple MCP Example with Claude and a Local JSON HTTP Server" by sunmer, and it was fantastic! The setup was straightforward, and the example provided clear insights into integrating Claude with a local JSON HTTP server. Highly recommend for developers looking to understand MCP applications better. Check it out [here](https://mcp.so/server/node-simple-mcp-example/sunmer).