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

mongo-mcp

v0.2.0

Published

MCP server for interacting with MongoDB databases

Downloads

175

Readme

🗄️ MongoDB MCP for Claude

Node.js 18+ License: MIT

A Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.

✨ Features

  • 🔍 Collection schema inspection
  • 📊 Document querying and filtering
  • 📈 Index management
  • 📝 Document operations (insert, update, delete)

🚀 Quick Start

To get started, find your mongodb connection url and add this configuration to your Claude Desktop config file:

MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": [
        "mongo-mcp",
        "mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
      ]
    }
  }
}

Prerequisites

  • Node.js 18+
  • npx
  • Docker and Docker Compose (for local sandbox testing only)
  • MCP Client (Claude Desktop App for example)

Test Sandbox Setup

If you don't have a mongo db server to connect to and want to create a sample sandbox, follow these steps

  1. Start MongoDB using Docker Compose:
docker-compose up -d
  1. Seed the database with test data:
npm run seed

Configure Claude Desktop

Add this configuration to your Claude Desktop config file:

MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

Local Development Mode:

{
  "mcpServers": {
    "mongodb": {
      "command": "node",
      "args": [
        "dist/index.js",
        "mongodb://root:example@localhost:27017/test?authSource=admin"
      ]
    }
  }
}

Test Sandbox Data Structure

The seed script creates three collections with sample data:

Users

  • Personal info (name, email, age)
  • Nested address with coordinates
  • Arrays of interests
  • Membership dates

Products

  • Product details (name, SKU, category)
  • Nested specifications
  • Price and inventory info
  • Tags and ratings

Orders

  • Order details with items
  • User references
  • Shipping and payment info
  • Status tracking

🎯 Example Prompts

Try these prompts with Claude to explore the functionality:

Basic Operations

"What collections are available in the database?"
"Show me the schema for the users collection"
"Find all users in San Francisco"

Advanced Queries

"Find all electronics products that are in stock and cost less than $1000"
"Show me all orders from the user [email protected]"
"List the products with ratings above 4.5"

Index Management

"What indexes exist on the users collection?"
"Create an index on the products collection for the 'category' field"
"List all indexes across all collections"

Document Operations

"Insert a new product with name 'Gaming Laptop' in the products collection"
"Update the status of order with ID X to 'shipped'"
"Find and delete all products that are out of stock"

📝 Available Tools

The server provides these tools for database interaction:

Query Tools

  • find: Query documents with filtering and projection
  • listCollections: List available collections
  • insertOne: Insert a single document
  • updateOne: Update a single document
  • deleteOne: Delete a single document

Index Tools

  • createIndex: Create a new index
  • dropIndex: Remove an index
  • indexes: List indexes for a collection

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.