MongoDB MCP Server
OfficialMongoDB MCP サーバー
MongoDB データベースおよび MongoDB Atlas と対話するためのモデル コンテキスト プロトコル サーバー。
📚 目次
Related MCP server: MongoDB MCP Server for LLMs
前提条件
Node.js (v20.10.0 以降)
node -vMongoDB 接続文字列または Atlas API 資格情報。設定しない限りサーバーは起動しません。
Atlasツールを使用するには***、サービスアカウントのAtlas API認証情報が***必要です。MongoDB Atlasでサービスアカウントを作成し、その認証情報を認証に使用できます。詳細はAtlas APIアクセスをご覧ください。
MongoDB 接続文字列がある場合は、それを使用して MongoDB インスタンスに直接接続できます。
設定
クイックスタート
ほとんどの MCP クライアントでは、MCP サーバーを追加するために構成ファイルを作成または変更する必要があります。
注: 設定ファイルの構文はクライアントによって異なる場合があります。最新の構文については、以下のリンクを参照してください。
ウィンドサーフィン: https://docs.windsurf.com/windsurf/mcp
VSCode : https://code.visualstudio.com/docs/copilot/chat/mcp-servers
クロード デスクトップ: https://modelcontextprotocol.io/quickstart/user
カーソル: https://docs.cursor.com/context/model-context-protocol
オプション1: 接続文字列引数
接続文字列を args 経由で渡すことができます。必ず有効なユーザー名とパスワードを使用してください。
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb://localhost:27017/myDatabase"
]
}
}
}注: 接続文字列は、ローカル インスタンスでも Atlas クラスターでも、任意の MongoDB クラスターに接続するように構成できます。
オプション 2: Atlas API 資格情報引数
Atlas APIサービスアカウントの認証情報を使用してください。Atlas APIアクセスセクションのすべての手順に従う必要があります。
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--apiClientId",
"your-atlas-service-accounts-client-id",
"--apiClientSecret",
"your-atlas-service-accounts-client-secret"
]
}
}
}オプション3: コマンド引数を使用したスタンドアロンサービス
npx コマンドを使用してサーバーを起動します。
npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret"引数の完全なリストについては、構成オプションを参照してください。
Atlas サービス アカウントの資格情報を設定するには、Atlas API アクセスを参照してください。
オプション4: 環境変数を使用したスタンドアロンサービス
npx -y mongodb-mcp-server設定ファイルで環境変数を使用することも、環境変数を設定して npx 経由でサーバーを実行することもできます。
🛠️ サポートされているツール
ツールリスト
MongoDB アトラスツール
atlas-list-orgs- MongoDB Atlas組織の一覧atlas-list-projects- MongoDB Atlas プロジェクトを一覧表示しますatlas-create-project- 新しい MongoDB Atlas プロジェクトを作成しますatlas-list-clusters- MongoDB Atlas クラスターを一覧表示しますatlas-inspect-cluster- 特定の MongoDB Atlas クラスターを検査するatlas-create-free-cluster- 無料の MongoDB Atlas クラスターを作成するatlas-connect-cluster- MongoDB Atlas クラスターに接続しますatlas-inspect-access-list- MongoDB Atlas クラスターへのアクセス権を持つ IP/CIDR 範囲を検査しますatlas-create-access-list- MongoDB Atlas クラスターの IP/CIDR アクセス リストを構成するatlas-list-db-users- MongoDB Atlas データベース ユーザーの一覧を表示しますatlas-create-db-user- MongoDB Atlas データベース ユーザーを作成しますatlas-list-alerts- プロジェクトの MongoDB Atlas アラートを一覧表示する
注意: アトラス ツールは、構成セクションで資格情報を設定した場合にのみ使用できます。
MongoDB データベースツール
connect- MongoDBインスタンスに接続するfind- MongoDB コレクションに対して検索クエリを実行するaggregate- MongoDB コレクションに対して集計を実行するcount- MongoDBコレクション内のドキュメント数を取得するinsert-one- MongoDB コレクションに単一のドキュメントを挿入するinsert-many- MongoDB コレクションに複数のドキュメントを挿入するcreate-index- MongoDB コレクションのインデックスを作成するupdate-one- MongoDB コレクション内の単一のドキュメントを更新するupdate-many- MongoDB コレクション内の複数のドキュメントを更新するrename-collection- MongoDB コレクションの名前を変更するdelete-one- MongoDB コレクションから 1 つのドキュメントを削除しますdelete-many- MongoDB コレクションから複数のドキュメントを削除するdrop-collection- MongoDBデータベースからコレクションを削除するdrop-database- MongoDB データベースを削除するlist-databases- MongoDB 接続のすべてのデータベースを一覧表示しますlist-collections- 指定されたデータベースのすべてのコレクションを一覧表示するcollection-indexes- コレクションのインデックスを記述するcollection-schema- コレクションのスキーマを記述するcollection-storage-size- コレクションのサイズをMB単位で取得するdb-stats- MongoDB データベースに関する統計情報を返す
構成
MongoDB MCP サーバーは、次の優先順位 (最高から最低) に従って複数の方法を使用して構成できます。
コマンドライン引数
環境変数
設定オプション
オプション | 説明 |
| 認証用の Atlas API クライアント ID |
| 認証用の Atlas API クライアント シークレット |
| 直接データベース接続用の MongoDB 接続文字列 (オプションでユーザーはツール呼び出しごとにこれを通知することを選択できます) |
| ログを保存するフォルダ |
| 無効にするツール名、操作タイプ、および/またはツールのカテゴリの配列 |
| trueに設定すると、読み取りとメタデータ操作タイプのみが許可され、作成/更新/削除操作は無効になります。 |
| 無効に設定すると、テレメトリ収集が無効になります |
ログパス
デフォルトのログの場所は次のとおりです。
Windows:
%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logsmacOS/Linux:
~/.mongodb/mongodb-mcp/.app-logs
無効なツール
特定のツールまたはツールのカテゴリを無効にするには、 disabledToolsオプションを使用します。このオプションは文字列の配列を受け入れ、各文字列はツール名、操作の種類、またはカテゴリのいずれかになります。
配列の構築方法は、使用する構成方法の種類によって異なります。
環境変数の設定には、コンマ区切りの文字列を使用します:
export MDB_MCP_DISABLED_TOOLS="create,update,delete,atlas,collectionSchema"。コマンドライン引数の設定では、スペースで区切られた文字列を使用します:
--disabledTools create update delete atlas collectionSchema。
ツールのカテゴリ:
atlas- クラスターの一覧表示、クラスターの作成などの MongoDB Atlas ツール。mongodb- 検索、集計などの MongoDB データベース ツール。
操作の種類:
create- クラスターの作成、ドキュメントの挿入など、リソースを作成するツール。update- ドキュメントの更新、コレクションの名前変更など、リソースを更新するツール。delete- ドキュメントの削除、コレクションのドロップなど、リソースを削除するツール。read- クラスターの検索、集計、一覧表示など、リソースを読み取るツール。metadata- リスト データベース、リスト コレクション、コレクション スキーマなどのメタデータを読み取るツール。
読み取り専用モード
readOnly設定オプションを使用すると、MCP サーバーが「読み取り」および「メタデータ」操作タイプのツールのみを使用するように制限できます。有効にすると、「作成」、「更新」、「削除」操作タイプのツールはすべてサーバーに登録されなくなります。
これは、データやインフラストラクチャを変更せずに、分析のために MongoDB データへのアクセスを提供するシナリオに役立ちます。
読み取り専用モードを有効にするには、次の操作を行います。
環境変数:
export MDB_MCP_READ_ONLY=trueコマンドライン引数:
--readOnly
読み取り専用モードがアクティブな場合、この制限により登録できなかったツールを示すメッセージがサーバー ログに表示されます。
テレメトリー
telemetry設定オプションを使用すると、テレメトリ収集を無効にすることができます。有効にすると、MCPサーバーは使用状況データを収集し、MongoDBに送信します。
テレメトリを無効にするには、次の操作を実行します。
環境変数:
export MDB_MCP_TELEMETRY=disabledコマンドライン引数:
--telemetry disabledDO_NOT_TRACK環境変数:
export DO_NOT_TRACK=1
アトラス API アクセス
Atlas API ツールを使用するには、MongoDB Atlas でサービス アカウントを作成する必要があります。
サービス アカウントを作成します。
cloud.mongodb.comで MongoDB Atlas にログインします。
アクセスマネージャ > 組織アクセスに移動します
新規追加 > アプリケーション > サービス アカウントをクリックします
サービス アカウントの名前、説明、有効期限を入力します (例:「MCP、MCP サーバー アクセス、7 日間」)
適切な権限を選択します(フルアクセスの場合は、組織の所有者を使用します)
「作成」をクリック
サービス アカウントの詳細については、 MongoDB Atlas のドキュメントを参照してください。
クライアント資格情報を保存します:
作成後、クライアントIDとクライアントシークレットが表示されます。
**重要:**クライアントシークレットは再度表示されないため、すぐにコピーして保存してください。
アクセス リスト エントリの追加:
APIアクセスリストにIPアドレスを追加する
MCP サーバーを構成します。
以下のいずれかの設定方法を使用して、
apiClientIdとapiClientSecretを設定します。
設定方法
環境変数
環境変数を、 MDB_MCP_というプレフィックスの後にアンダースコア付きの大文字のオプション名を付けて設定します。
# 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"
MCP 構成ファイルの例
環境変数を使用した接続文字列
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": ["-y", "mongodb-mcp-server"],
"env": {
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
}
}
}
}環境変数を使用した Atlas API 資格情報
{
"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"
}
}
}
}コマンドライン引数
サーバーの起動時に、構成オプションをコマンドライン引数として渡します。
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/logsMCP 構成ファイルの例
コマンドライン引数を使用した接続文字列
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--connectionString",
"mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
]
}
}
}コマンドライン引数を使用した Atlas API 認証情報
{
"mcpServers": {
"MongoDB": {
"command": "npx",
"args": [
"-y",
"mongodb-mcp-server",
"--apiClientId",
"your-atlas-service-accounts-client-id",
"--apiClientSecret",
"your-atlas-service-accounts-client-secret"
]
}
}
}🤝 貢献する
貢献に興味がありますか?素晴らしい!コードの貢献、標準、新しいツールの追加、トラブルシューティング情報に関するガイドラインについては、貢献ガイドをご覧ください。
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