Skip to main content
Glama

MCP MongoDB Server


NPM-VersionNPM-DownloadsNPM-Lizenz Schmiedeabzeichen

Ein Model Context Protocol-Server, der LLMs die Interaktion mit MongoDB-Datenbanken ermöglicht. Dieser Server bietet Funktionen zur Überprüfung von Sammlungsschemata und zur Ausführung von MongoDB-Operationen über eine standardisierte Schnittstelle.

Demo

MCP MongoDB Server Demo | Claude Desktop

Hauptmerkmale

Intelligente Objekt-ID-Behandlung

  • Intelligente Konvertierung zwischen String-IDs und MongoDB ObjectId

  • Konfigurierbar mit dem Parameter objectIdMode :

    • "auto" : Konvertierung basierend auf Feldnamen (Standard)

    • "none" : Keine Konvertierung

    • "force" : Erzwingt die ObjectId aller String-ID-Felder

Flexible Konfiguration

  • Umgebungsvariablen :

    • MCP_MONGODB_URI : MongoDB-Verbindungs-URI

    • MCP_MONGODB_READONLY : Aktiviert den Nur-Lese-Modus, wenn auf „true“ gesetzt

  • Befehlszeilenoptionen :

    • --read-only oder -r : Verbindung im schreibgeschützten Modus herstellen

Schreibgeschützter Modus

  • Schutz vor Schreiboperationen (Update, Insert, CreateIndex)

  • Nutzt die sekundäre Lesepräferenz von MongoDB für optimale Leistung

  • Ideal für die sichere Verbindung mit Produktionsdatenbanken

MongoDB-Operationen

  • Lesevorgänge :

    • Abfragedokumente mit optionaler Ausführungsplananalyse

    • Ausführen von Aggregationspipelines

    • Zählen Sie Dokumente, die den Kriterien entsprechen

    • Abrufen von Sammlungsschemainformationen

  • Schreibvorgänge (wenn nicht im Nur-Lese-Modus):

    • Dokumente aktualisieren

    • Neue Dokumente einfügen

    • Erstellen von Indizes

LLM-Integration

  • Sammlungsvervollständigungen für eine verbesserte LLM-Interaktion

  • Schemainferenz für ein besseres Kontextverständnis

  • Sammlungsanalyse für Dateneinblicke

Installation

Globale Installation

npm install -g mcp-mongo-server

Für die Entwicklung

# Clone repository git clone https://github.com/kiliczsh/mcp-mongo-server.git cd mcp-mongo-server # Install dependencies npm install # Build npm run build # Development with auto-rebuild npm run watch

Verwendung

Grundlegende Verwendung

# Start server with MongoDB URI npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database # Connect in read-only mode npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database --read-only

Umgebungsvariablen

Sie können den Server mithilfe von Umgebungsvariablen konfigurieren. Dies ist besonders nützlich für CI/CD-Pipelines, Docker-Container oder wenn Sie keine Verbindungsdetails in Befehlsargumenten offenlegen möchten:

# Set MongoDB connection URI export MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database" # Enable read-only mode export MCP_MONGODB_READONLY="true" # Run server (will use environment variables if no URI is provided) npx -y mcp-mongo-server

Verwenden von Umgebungsvariablen in der Claude Desktop-Konfiguration:

{ "mcpServers": { "mongodb-env": { "command": "npx", "args": [ "-y", "mcp-mongo-server" ], "env": { "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database", "MCP_MONGODB_READONLY": "true" } } } }

Verwenden von Umgebungsvariablen mit Docker:

# Build docker build -t mcp-mongo-server . # Run docker run -it -d -e MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database" -e MCP_MONGODB_READONLY="true" mcp-mongo-server # or edit docker-compose.yml and run docker-compose up -d

Integration mit Claude Desktop

Manuelle Konfiguration

Fügen Sie die Serverkonfiguration zur Konfigurationsdatei von Claude Desktop hinzu:

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

Ansatz mit Befehlszeilenargumenten:

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] }, "mongodb-readonly": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database", "--read-only" ] } } }

Ansatz mit Umgebungsvariablen:

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server" ], "env": { "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database" } }, "mongodb-readonly": { "command": "npx", "args": [ "-y", "mcp-mongo-server" ], "env": { "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database", "MCP_MONGODB_READONLY": "true" } } } }

GitHub-Paketnutzung:

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "github:kiliczsh/mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] }, "mongodb-readonly": { "command": "npx", "args": [ "-y", "github:kiliczsh/mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database", "--read-only" ] } } }

Integration mit Windsurf und Cursor

Der MCP MongoDB-Server kann mit Windsurf und Cursor auf ähnliche Weise wie Claude Desktop verwendet werden.

Windsurf-Konfiguration

Fügen Sie den Server zu Ihrer Windsurf-Konfiguration hinzu:

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] } } }

Cursorkonfiguration

Fügen Sie für Cursor die Serverkonfiguration zu Ihren Einstellungen hinzu:

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] } } }

Sie können den Ansatz mit Umgebungsvariablen auch sowohl mit Windsurf als auch mit Cursor verwenden und dabei dem gleichen Muster folgen, das in der Claude Desktop-Konfiguration gezeigt wird.

Automatisierte Installation

Schmiedearbeiten verwenden :

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

Verwenden von mcp-get :

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

Verfügbare Tools

Abfragevorgänge

  • Abfrage : Führen Sie MongoDB-Abfragen aus

    { collection: "users", filter: { age: { $gt: 30 } }, projection: { name: 1, email: 1 }, limit: 20, explain: "executionStats" // Optional }
  • aggregate : Führen Sie Aggregationspipelines aus

    { collection: "orders", pipeline: [ { $match: { status: "completed" } }, { $group: { _id: "$customerId", total: { $sum: "$amount" } } } ], explain: "queryPlanner" // Optional }
  • count : Zählt übereinstimmende Dokumente

    { collection: "products", query: { category: "electronics" } }

Schreibvorgänge

  • Update : Dokumente ändern

    { collection: "posts", filter: { _id: "60d21b4667d0d8992e610c85" }, update: { $set: { title: "Updated Title" } }, upsert: false, multi: false }
  • einfügen : Neue Dokumente hinzufügen

    { collection: "comments", documents: [ { author: "user123", text: "Great post!" }, { author: "user456", text: "Thanks for sharing" } ] }
  • createIndex : Sammlungsindizes erstellen

    { collection: "users", indexes: [ { key: { email: 1 }, unique: true, name: "email_unique_idx" } ] }

Systembetrieb

  • serverInfo : MongoDB-Serverdetails abrufen

    { includeDebugInfo: true // Optional }

Debuggen

Da MCP-Server über Standarddio kommunizieren, kann das Debuggen schwierig sein. Verwenden Sie den MCP-Inspektor für bessere Übersicht:

npm run inspector

Dadurch wird eine URL für den Zugriff auf die Debugging-Tools in Ihrem Browser bereitgestellt.

Ausführen von Evaluierungen

Das Evals-Paket lädt einen MCP-Client, der anschließend die Datei index.ts ausführt, sodass zwischen den Tests kein Neuaufbau erforderlich ist. Sie können Umgebungsvariablen laden, indem Sie dem Befehl npx voranstellen. Die vollständige Dokumentation finden Sie hier .

OPENAI_API_KEY=your-key npx mcp-eval src/evals/evals.ts src/schemas/tools.ts

Lizenz

Dieser MCP-Server ist unter der MIT-Lizenz lizenziert. Das bedeutet, dass Sie die Software unter den Bedingungen der MIT-Lizenz frei verwenden, ändern und verbreiten dürfen. Weitere Informationen finden Sie in der LICENSE-Datei im Projekt-Repository.

Deploy Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Ein Model Context Protocol-Server, der LLMs die Interaktion mit MongoDB-Datenbanken ermöglicht. Dieser Server bietet Funktionen zur Überprüfung von Sammlungsschemata und zur Ausführung von MongoDB-Operationen über eine standardisierte Schnittstelle.

  1. Demo
    1. Hauptmerkmale
      1. Intelligente Objekt-ID-Behandlung
      2. Flexible Konfiguration
      3. Schreibgeschützter Modus
      4. MongoDB-Operationen
      5. LLM-Integration
    2. Installation
      1. Globale Installation
      2. Für die Entwicklung
    3. Verwendung
      1. Grundlegende Verwendung
      2. Umgebungsvariablen
    4. Integration mit Claude Desktop
      1. Manuelle Konfiguration
      2. GitHub-Paketnutzung:
    5. Integration mit Windsurf und Cursor
      1. Windsurf-Konfiguration
      2. Cursorkonfiguration
      3. Automatisierte Installation
    6. Verfügbare Tools
      1. Abfragevorgänge
      2. Schreibvorgänge
      3. Systembetrieb
    7. Debuggen
      1. Ausführen von Evaluierungen
        1. Lizenz

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            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.
            Last updated -
            109
            169
            MIT License
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.
            Last updated -
            109
            1
            MIT License
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.
            Last updated -
            109
            MIT License
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases, allowing them to query collections, inspect schemas, and manage data seamlessly through natural language.

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/kiliczsh/mcp-mongo-server'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server