MongoDB MCP Server
OfficialMongoDB MCP-Server
Ein Model Context Protocol-Server für die Interaktion mit MongoDB-Datenbanken und MongoDB Atlas.
📚 Inhaltsverzeichnis
Related MCP server: MongoDB MCP Server for LLMs
Voraussetzungen
Node.js (v20.10.0 oder höher)
node -vEine MongoDB-Verbindungszeichenfolge oder Atlas-API-Anmeldeinformationen. Der Server wird nicht gestartet, sofern nicht eine entsprechende Konfiguration vorgenommen wurde .
Für die Nutzung der Atlas-Tools sind Atlas-API-Anmeldeinformationen für Servicekonten erforderlich. Sie können in MongoDB Atlas ein Servicekonto erstellen und dessen Anmeldeinformationen zur Authentifizierung verwenden. Weitere Informationen finden Sie unter Atlas-API-Zugriff .
Wenn Sie über eine MongoDB-Verbindungszeichenfolge verfügen, können Sie diese direkt verwenden, um eine Verbindung zu Ihrer MongoDB-Instanz herzustellen.
Aufstellen
Schnellstart
Für die meisten MCP-Clients muss zum Hinzufügen des MCP-Servers eine Konfigurationsdatei erstellt oder geändert werden.
Hinweis: Die Syntax der Konfigurationsdatei kann je nach Client unterschiedlich sein. Die aktuell erwartete Syntax finden Sie unter den folgenden Links:
Windsurfen : https://docs.windsurf.com/windsurf/mcp
VSCode : https://code.visualstudio.com/docs/copilot/chat/mcp-servers
Claude Desktop : https://modelcontextprotocol.io/quickstart/user
Cursor : https://docs.cursor.com/context/model-context-protocol
Option 1: Verbindungszeichenfolgenargumente
Sie können Ihre Verbindungszeichenfolge über Argumente übergeben. Achten Sie darauf, einen gültigen Benutzernamen und ein gültiges Kennwort zu verwenden.
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb://localhost:27017/myDatabase"
]
}
}
}HINWEIS: Die Verbindungszeichenfolge kann so konfiguriert werden, dass eine Verbindung zu jedem MongoDB-Cluster hergestellt wird, unabhängig davon, ob es sich um eine lokale Instanz oder einen Atlas-Cluster handelt.
Option 2: Atlas-API-Anmeldeinformationen-Argumente
Verwenden Sie die Anmeldeinformationen Ihres Atlas API-Dienstkontos. Befolgen Sie alle Schritte im Abschnitt „Atlas API-Zugriff“ .
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--apiClientId",
"your-atlas-service-accounts-client-id",
"--apiClientSecret",
"your-atlas-service-accounts-client-secret"
]
}
}
}Option 3: Standalone-Dienst mit Befehlsargumenten
Starten Sie den Server mit dem Befehl npx:
npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret"Eine vollständige Liste der Argumente finden Sie unter Konfigurationsoptionen
Informationen zum Konfigurieren Ihrer Atlas-Dienstkonten-Anmeldeinformationen finden Sie unter Atlas API Access
Option 4: Standalone-Dienst mit Umgebungsvariablen
npx -y mongodb-mcp-serverSie können Umgebungsvariablen in der Konfigurationsdatei verwenden oder sie festlegen und den Server über npx ausführen.
Verbindungszeichenfolge über Umgebungsvariablen im Beispiel der MCP-Datei
Atlas-API-Anmeldeinformationen über Umgebungsvariablen im Beispiel der MCP-Datei
🛠️ Unterstützte Tools
Werkzeugliste
MongoDB Atlas Tools
atlas-list-orgs– Listet MongoDB Atlas-Organisationen aufatlas-list-projects– Listet MongoDB Atlas-Projekte aufatlas-create-project– Erstellt ein neues MongoDB Atlas-Projektatlas-list-clusters– Listet MongoDB Atlas-Cluster aufatlas-inspect-cluster– Untersuchen Sie einen bestimmten MongoDB Atlas-Clusteratlas-create-free-cluster– Erstellen Sie einen kostenlosen MongoDB Atlas-Clusteratlas-connect-cluster– Stellt eine Verbindung zum MongoDB Atlas-Cluster heratlas-inspect-access-list– Überprüfen Sie IP/CIDR-Bereiche mit Zugriff auf MongoDB Atlas-Clusteratlas-create-access-list– IP/CIDR-Zugriffsliste für MongoDB Atlas-Cluster konfigurierenatlas-list-db-users– Listet MongoDB Atlas-Datenbankbenutzer aufatlas-create-db-user– Erstellt einen MongoDB Atlas-Datenbankbenutzeratlas-list-alerts– MongoDB Atlas-Warnmeldungen für ein Projekt auflisten
HINWEIS: Atlas-Tools sind nur verfügbar, wenn Sie im Konfigurationsabschnitt Anmeldeinformationen festlegen.
MongoDB-Datenbanktools
connect- Verbindung zu einer MongoDB-Instanz herstellenfind- Führen Sie eine Suchabfrage für eine MongoDB-Sammlung ausaggregate- Führen Sie eine Aggregation für eine MongoDB-Sammlung auscount- Anzahl der Dokumente in einer MongoDB-Sammlung ermittelninsert-one- Fügt ein einzelnes Dokument in eine MongoDB-Sammlung eininsert-many- Mehrere Dokumente in eine MongoDB-Sammlung einfügencreate-index- Erstellen Sie einen Index für eine MongoDB-Sammlungupdate-one- Aktualisieren Sie ein einzelnes Dokument in einer MongoDB-Sammlungupdate-many- Mehrere Dokumente in einer MongoDB-Sammlung aktualisierenrename-collection- Umbenennen einer MongoDB-Sammlungdelete-one- Löschen Sie ein einzelnes Dokument aus einer MongoDB-Sammlungdelete-many- Löschen Sie mehrere Dokumente aus einer MongoDB-Sammlungdrop-collection- Entfernen Sie eine Sammlung aus einer MongoDB-Datenbankdrop-database- Entfernen einer MongoDB-Datenbanklist-databases- Listet alle Datenbanken für eine MongoDB-Verbindung auflist-collections- Listet alle Sammlungen für eine bestimmte Datenbank aufcollection-indexes- Beschreiben Sie die Indizes für eine Sammlungcollection-schema- Beschreiben Sie das Schema für eine Sammlungcollection-storage-size- Größe einer Sammlung in MB ermittelndb-stats- Gibt Statistiken zu einer MongoDB-Datenbank zurück
Konfiguration
Der MongoDB MCP-Server kann mit mehreren Methoden konfiguriert werden, mit der folgenden Priorität (von der höchsten zur niedrigsten):
Befehlszeilenargumente
Umgebungsvariablen
Konfigurationsoptionen
Option | Beschreibung |
| Atlas API-Client-ID zur Authentifizierung |
| Atlas-API-Client-Geheimnis zur Authentifizierung |
| MongoDB-Verbindungszeichenfolge für direkte Datenbankverbindungen (optional können Benutzer diese bei jedem Tool-Aufruf angeben) |
| Ordner zum Speichern von Protokollen |
| Eine Reihe von Werkzeugnamen, Operationstypen und/oder Werkzeugkategorien, die deaktiviert werden |
| Wenn auf „true“ gesetzt, sind nur Lese- und Metadatenoperationstypen zulässig, wodurch Erstellungs-/Aktualisierungs-/Löschoperationen deaktiviert werden. |
| Wenn diese Option deaktiviert ist, wird die Telemetrieerfassung deaktiviert. |
Protokollpfad
Der Standardspeicherort des Protokolls ist wie folgt:
Windows:
%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logsmacOS/Linux:
~/.mongodb/mongodb-mcp/.app-logs
Deaktivierte Tools
Mit der Option disabledTools können Sie bestimmte Werkzeuge oder Werkzeugkategorien deaktivieren. Diese Option akzeptiert ein Array von Zeichenfolgen, wobei jede Zeichenfolge ein Werkzeugname, ein Vorgangstyp oder eine Kategorie sein kann.
Die Art und Weise, wie das Array erstellt wird, hängt von der Art der von Ihnen verwendeten Konfigurationsmethode ab:
Verwenden Sie für die Konfiguration von Umgebungsvariablen eine durch Kommas getrennte Zeichenfolge:
export MDB_MCP_DISABLED_TOOLS="create,update,delete,atlas,collectionSchema".Verwenden Sie für die Konfiguration von Befehlszeilenargumenten eine durch Leerzeichen getrennte Zeichenfolge:
--disabledTools create update delete atlas collectionSchema.
Werkzeugkategorien:
atlas– MongoDB Atlas-Tools, z. B. Cluster auflisten, Cluster erstellen usw.mongodb– MongoDB-Datenbanktools wie Suchen, Aggregieren usw.
Betriebsarten:
create– Tools zum Erstellen von Ressourcen, z. B. Cluster erstellen, Dokument einfügen usw.update– Tools zum Aktualisieren von Ressourcen, z. B. zum Aktualisieren von Dokumenten, Umbenennen von Sammlungen usw.delete– Tools zum Löschen von Ressourcen, z. B. Dokumente löschen, Sammlungen löschen usw.read– Tools, die Ressourcen lesen, z. B. Suchen, Aggregieren, Cluster auflisten usw.metadata– Tools, die Metadaten lesen, wie Listendatenbanken, Listensammlungen, Sammlungsschemata usw.
Schreibgeschützter Modus
Mit der Konfigurationsoption readOnly können Sie den MCP-Server so einschränken, dass nur Tools mit den Operationstypen „Lesen“ und „Metadaten“ verwendet werden. Wenn diese Option aktiviert ist, werden Tools mit den Operationstypen „Erstellen“, „Aktualisieren“ oder „Löschen“ nicht beim Server registriert.
Dies ist für Szenarien nützlich, in denen Sie Zugriff auf MongoDB-Daten zur Analyse gewähren möchten, ohne Änderungen an den Daten oder der Infrastruktur zuzulassen.
Sie können den schreibgeschützten Modus folgendermaßen aktivieren:
Umgebungsvariable :
export MDB_MCP_READ_ONLY=trueBefehlszeilenargument :
--readOnly
Wenn der schreibgeschützte Modus aktiv ist, wird in den Serverprotokollen eine Meldung angezeigt, die angibt, welche Tools sich aufgrund dieser Einschränkung nicht registrieren konnten.
Telemetrie
Mit der telemetry können Sie die Telemetrieerfassung deaktivieren. Wenn diese Option aktiviert ist, sammelt der MCP-Server Nutzungsdaten und sendet sie an MongoDB.
Sie können die Telemetrie folgendermaßen deaktivieren:
Umgebungsvariable :
export MDB_MCP_TELEMETRY=disabledBefehlszeilenargument :
--telemetry disabledUmgebungsvariable DO_NOT_TRACK :
export DO_NOT_TRACK=1
Atlas-API-Zugriff
Um die Atlas-API-Tools zu verwenden, müssen Sie ein Dienstkonto in MongoDB Atlas erstellen:
Erstellen Sie ein Dienstkonto:
Melden Sie sich bei MongoDB Atlas unter cloud.mongodb.com an.
Navigieren Sie zu Access Manager > Organisationszugriff
Klicken Sie auf „Neu hinzufügen“ > „Anwendungen“ > „Dienstkonten“.
Geben Sie den Namen, die Beschreibung und das Ablaufdatum Ihres Service-Kontos ein (z. B. „MCP, MCP-Serverzugriff, 7 Tage“).
Wählen Sie die entsprechenden Berechtigungen aus (für Vollzugriff verwenden Sie „Organisationseigentümer“)
Klicken Sie auf „Erstellen“
Weitere Informationen zu Dienstkonten finden Sie in der MongoDB Atlas-Dokumentation .
Client-Anmeldeinformationen speichern:
Nach der Erstellung werden Ihnen die Client-ID und das Client-Geheimnis angezeigt
Wichtig: Kopieren und speichern Sie das Client Secret sofort, da es nicht mehr angezeigt wird
Zugriffslisteneintrag hinzufügen:
Fügen Sie Ihre IP-Adresse zur API-Zugriffsliste hinzu
Konfigurieren Sie den MCP-Server:
Verwenden Sie eine der folgenden Konfigurationsmethoden, um Ihre
apiClientIdundapiClientSecretfestzulegen
Konfigurationsmethoden
Umgebungsvariablen
Legen Sie Umgebungsvariablen mit dem Präfix MDB_MCP_ fest, gefolgt vom Optionsnamen in Großbuchstaben mit Unterstrichen:
# Set Atlas API credentials (via Service Accounts)
export MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id"
export MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret"
# Set a custom MongoDB connection string
export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
export MDB_MCP_LOG_PATH="/path/to/logs"
Beispiele für MCP-Konfigurationsdateien
Verbindungszeichenfolge mit Umgebungsvariablen
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
}
}
}
}Atlas-API-Anmeldeinformationen mit Umgebungsvariablen
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server"],
"env": {
"MDB_MCP_API_CLIENT_ID": "your-atlas-service-accounts-client-id",
"MDB_MCP_API_CLIENT_SECRET": "your-atlas-service-accounts-client-secret"
}
}
}
}Befehlszeilenargumente
Übergeben Sie beim Starten des Servers Konfigurationsoptionen als Befehlszeilenargumente:
npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret" --connectionString="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" --logPath=/path/to/logsBeispiele für MCP-Konfigurationsdateien
Verbindungszeichenfolge mit Befehlszeilenargumenten
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
]
}
}
}Atlas-API-Anmeldeinformationen mit Befehlszeilenargumenten
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--apiClientId",
"your-atlas-service-accounts-client-id",
"--apiClientSecret",
"your-atlas-service-accounts-client-secret"
]
}
}
}🤝 Beitragen
Möchten Sie mitwirken? Super! In unserem Leitfaden für Mitwirkende finden Sie Richtlinien zu Codebeiträgen, Standards, dem Hinzufügen neuer Tools und Informationen zur Fehlerbehebung.
Available Tools
28 toolsaggregateARead-only
Run an aggregation against a MongoDB collection
Inputs: database (required), pipeline (required), collection (required), connectionId (required), +1 more. Returns: count, documents, appliedLimits
aggregate-dbCRead-only
Run an aggregation against a MongoDB database
Inputs: database (required), pipeline (required), connectionId (required), responseBytesLimit. Returns: documents, appliedLimits, aggResultsCount
atlas-connect-clusterARead-only
Connect to MongoDB Atlas cluster and get back a connectionId to pass to the other MongoDB tools. Each call establishes a new, independent connection — multiple connections can be active at the same time.
Inputs: projectId (required), clusterName (required), connectionType. Returns: state, connectionId, addedCurrentIp, sharedTierTier, +4 more
atlas-get-performance-advisorARead-only
Get MongoDB Atlas performance advisor recommendations and suggestions, which includes the operations: suggested indexes, drop index suggestions, schema suggestions, and a sample of the most recent (max 50) slow query logs
Inputs: projectId (required), clusterName (required), since, namespaces, +1 more. Returns: projectId, clusterName, slowQueryLogs, suggestedIndexes, +2 more
atlas-inspect-access-listARead-only
Inspect Ip/CIDR ranges with access to your MongoDB Atlas clusters.
Inputs: projectId (required). Returns: entries, projectId, totalCount
atlas-inspect-clusterBRead-only
Inspect metadata of a MongoDB Atlas cluster
Inputs: projectId (required), clusterName (required). Returns: name, state, paused, region, +5 more
atlas-list-alertsARead-only
List triggered alerts for a MongoDB Atlas project. These are alerts Atlas has raised, not the alert configurations that define them. Defaults to OPEN alerts; set status to TRACKING or CLOSED to see others.
Inputs: projectId (required), limit, status, pageNum. Returns: alerts, status, projectId, totalCount
atlas-list-clustersBRead-only
List MongoDB Atlas clusters
Inputs: projectId. Returns: clusters, projectId, totalCount, projectName
atlas-list-db-usersARead-only
List MongoDB Atlas database users
Inputs: projectId (required). Returns: users, projectId, totalCount
atlas-list-orgsBRead-only
List MongoDB Atlas organizations
Inputs: limit, pageNum. Returns: totalCount, organizations
atlas-list-projectsBRead-only
List MongoDB Atlas projects.
Inputs: limit, orgId, pageNum. Returns: orgId, projects, totalCount
atlas-streams-discoverARead-only
Discover and inspect Atlas Stream Processing resources. Also use for 'why is my processor failing', 'what workspaces do I have', 'show processor stats', or 'check processor health'. Use 'list-workspaces' to see all workspaces in a project. Use inspect actions for details on a specific resource. Use 'diagnose-processor' for a combined health report including state, stats, connection health, and recent errors. Use 'get-networking' for PrivateLink and account details.
Inputs: action (required), projectId (required), limit, region, +5 more. Returns: dlq, tier, stats, pipeline, +9 more
collection-indexesARead-only
Describe the indexes for a collection
Inputs: database (required), collection (required), connectionId (required). Returns: searchIndexes, classicIndexes, searchIndexesCount, classicIndexesCount
collection-schemaCRead-only
Describe the schema for a collection
Inputs: database (required), collection (required), connectionId (required), sampleSize, +1 more. Returns: schema, fieldsCount
collection-storage-sizeBRead-only
Gets the size of the collection
Inputs: database (required), collection (required), connectionId (required). Returns: size, units
connectARead-only
Connect to a MongoDB instance and get back a connectionId to pass to the other MongoDB tools. Each call establishes a new, independent connection — multiple connections can be active at the same time. A connection with the id "preconfigured" already exists for the connection string the server was configured with — there is no need to call this tool to use it.
Inputs: connectionString (required), connectionName. Returns: connectionId
countARead-only
Gets the number of documents in a MongoDB collection using db.collection.count() and query as an optional filter parameter
Inputs: database (required), collection (required), connectionId (required), query. Returns: count
db-statsARead-only
Returns statistics that reflect the use state of a single database
Inputs: database (required), connectionId (required). Returns: stats
disconnectCRead-only
Close a MongoDB connection and revoke its connectionId. Disconnecting the "preconfigured" connection only closes it — it reconnects automatically on next use because the server configuration still declares it.
Inputs: connectionId (required). Returns: outcome
explainBRead-only
Returns statistics describing the execution of the winning plan chosen by the query optimizer for the evaluated method
Inputs: method (required), database (required), collection (required), connectionId (required), +1 more. Returns: method, verbosity, explainResult
exportARead-only
Export a query or aggregation results in the specified EJSON format.
Inputs: database (required), collection (required), exportTitle (required), connectionId (required), +2 more.
findBRead-only
Run a find query against a MongoDB collection
Inputs: database (required), collection (required), connectionId (required), sort, +4 more. Returns: documents, appliedLimits, queryResultsCount
list-collectionsARead-only
List all collections for a given database
Inputs: database (required), connectionId (required). Returns: totalCount, collections
list-connectionsARead-only
List the active MongoDB connections and their connectionIds. Use this to discover the "preconfigured" connection or to find a connectionId established earlier.
Inputs: no named parameters. Returns: connections
list-databasesARead-only
List all databases for a MongoDB connection
Inputs: connectionId (required). Returns: databases, totalCount
list-knowledge-sourcesARead-only
List available data sources in the MongoDB Assistant knowledge base. Use this to explore available data sources or to find search filter parameters to use in search-knowledge.
Inputs: no named parameters.
mongodb-logsARead-only
Returns the most recent logged mongod events
Inputs: connectionId (required), type, limit. Returns: logs, shownCount, totalLinesWritten
search-knowledgeARead-only
Search for information in the MongoDB Assistant knowledge base. This includes official documentation, curated expert guidance, and other resources provided by MongoDB. Supports filtering by data source and version.
Inputs: query (required), limit, dataSources.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 28 tools
Most tools have distinct purposes: find, count, aggregate, export, and explain are clearly separate query operations. The Atlas tools are well-prefixed and target different resources. Minor confusion exists between aggregate and aggregate-db, and between connect and atlas-connect-cluster, but descriptions clarify the distinction.
Naming conventions are mixed: some tools use verb-first style (find, count, export, connect), some use noun-only (collection-indexes, db-stats), and the Atlas group consistently uses atlas-* prefix. This is readable but lacks a uniform pattern, making it less predictable.
With 28 tools, the server exceeds the 25-tool threshold for 'too many'. While the breadth reflects both core MongoDB operations and Atlas management, the large count can overwhelm agents, especially with many similar list/inspect tools. A leaner set or grouping would improve usability.
The tool surface is heavily read/analysis-oriented (find, aggregate, explain, export) and includes Atlas admin operations, but it lacks fundamental write/update/delete operations for documents and collections. Agents cannot perform mutations, which is a significant gap for a MongoDB server.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
The Telnyx MCP server is an official implementation of the Model Context Protocol that enables AI clients (like Claude Desktop, Cursor, and OpenAI Agents) to interact with Telnyx's telephony, messaging, and AI assistant APIs. It provides comprehensive capabilities including making and managing phone calls, sending SMS/MMS messages, purchasing and configuring phone numbers, creating AI assistants with custom instructions, managing cloud storage buckets, scraping and embedding website content, and handling integration secrets. The server exists as both a local implementation and a remotely hosted version, allowing developers to integrate real-world communication infrastructure directly into AI applications.
Related MCP Servers
- AlicenseAqualityDmaintenanceA Model Context Protocol server that provides read-only access to MongoDB databases, enabling AI assistants to directly query and analyze MongoDB data while maintaining data safety.149MIT
- AlicenseNot gradedqualityDmaintenanceA 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.1MIT
- AlicenseNot gradedqualityDmaintenanceA 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.MIT
- AlicenseAqualityBmaintenanceA Model Context Protocol server that enables interaction with MongoDB databases and MongoDB Atlas, allowing users to perform database operations and manage Atlas resources through natural language.22Apache 2.0