npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pash1986/mongodb-mcp-server

v0.1.7

Published

MongoDB MCP server for local mongodb queries

Downloads

51

Readme

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.