MongoDB

MongoDB

Query a MongoDB database directly: introspect collections and their field shapes, and run read-only find queries with filter, projection, sort and limit. Installs read-only; credentials are held encrypted rather than in the connection string.

7 日間無料 · クレジットカード不要 · EU ホスト

MongoDB に何でも聞ける

AnythingMCP 経由で MongoDB に実際のプロンプトを試そう — Claude がツールを呼び出し、回答します。あなたのメッセージで Enter を押すと Cloud にインストールします。

MongoDB を Cloud にインストール
MongoDB · MCP 経由でライブ
共有
Opus 4.7

Claude は AI のため誤ることがあります。回答をご確認ください。

2 分でセットアップ

  1. 1cloud.anythingmcp.com で無料トライアル開始。
  2. 2コネクターストアで MongoDB をクリック。資格情報を貼り付け。
  3. 3MCP API キーを発行し、AI クライアントを MCP URL に向ける。
MongoDB を今すぐインストール

MongoDB のガイド

主要 AI クライアント向けのステップバイステップセットアップ。

MongoDB のセットアップ

コネクタ定義そのものから:認証情報の入手先、必要な権限、このアダプタが呼び出す API。 コネクタ作者により英語で提供されています。

Setup

  1. Create a user with only read on the database the agent should see:
    use admin
    db.createUser({
      user: "amcp_reader",
      pwd: "change-me",
      roles: [{ role: "read", db: "shop" }]
    })
    
  2. Set MONGODB_HOST, MONGODB_PORT (27017), MONGODB_DATABASE, MONGODB_USER and MONGODB_PASSWORD.

MONGODB_AUTH_SOURCE is the field that decides whether this works at all. MongoDB authenticates a user against the database the user was created in, not the one you want to read. A root or admin account created the usual way lives in admin, so MONGODB_AUTH_SOURCE must be admin even though MONGODB_DATABASE is shop. A user created inside the target database with use shop; db.createUser(...) takes the database name instead. Get this wrong and every single call comes back with Authentication failed. and code 18 — a message that says nothing about which database it tried.

MongoDB Atlas uses mongodb+srv:// and a different host shape. This adapter builds a plain mongodb://host:port/db DSN, which works for a self-managed replica set or a standalone server. For Atlas, create a custom connector with the full mongodb+srv://cluster0.abcde.mongodb.net/shop URI instead — the SRV form resolves the replica set from DNS and cannot be assembled from a host and a port.

Queries are JSON, not SQL. mongodb_find takes a JSON object:

{"collection": "orders",
 "filter": {"status": "paid", "total": {"$gt": 100}},
 "projection": {"_id": 0, "orderNo": 1, "total": 1},
 "sort": {"createdAt": -1},
 "limit": 50}

Only collection is required. Extended-JSON types ($oid, $date) are not converted, so match an ObjectId by its containing field where you can, or by the string form if the collection stores it that way.

The convenience tools have no optional arguments. mongodb_find_recent and mongodb_matching build their query by substituting every placeholder in a JSON template, so a missing argument leaves a hole and the spec fails to parse. Pass all of them, or use mongodb_find, which takes the whole spec as one string and lets you leave out whatever you do not need.

mongodb_schema samples one document per collection and reports the field names and inferred types, plus an estimated document count. It is the map to draw before composing a filter — MongoDB has no information_schema, and a collection's shape is a convention rather than a constraint.

How a database connector behaves

  • It installs read-only. The engine rejects anything that is not a read until you flip the switch in the connector's settings. That is a guard rail, not a security boundary: give the connection a read role and the guard rail never has to matter.
  • Credentials live in the encrypted authConfig, not in the connection string. MONGODB_USER and MONGODB_PASSWORD are stored encrypted and spliced into the URI at call time.
  • Results are capped at 1000 documents, and limit is capped at the same number. Aggregate in the query rather than in the agent.

Reachable from where?

  • On AnythingMCP Cloud the server must accept connections from the public internet, which for a production database usually means it should not. Point the connector at a secondary, or self-host AnythingMCP inside the network.
  • Self-hosted, add the host to SSRF_ALLOWED_HOSTS: the outbound guard blocks private address space by default, and 10.0.0.5 is exactly the shape it is there to block.

あなたの AI は MongoDB から 2 クリック先。

コネクターをインストール、資格情報を貼り付け、AI に質問。7 日間無料、クレジットカード不要。