KosmoKrator

database

MongoDB Atlas MCP Integration for LangChain

Connect MongoDB Atlas to LangChain through the local KosmoKrator MCP gateway with scoped tools, credentials, and write policy.

9 functions 5 read 4 write API key auth

Connect MongoDB Atlas to LangChain

Bridge LangChain agents to local KosmoKrator integration tools through MCP or headless CLI calls.

Use the MCP gateway when the agent should discover tools, or wrap kosmo integrations:call for fixed chains. The gateway is local, scoped to this integration, and starts with --write=deny so LangChain can inspect read-capable tools without receiving write access by default.

MongoDB Atlas MCP Config for LangChain

Keep the gateway scoped to the integration and operation class needed by the chain.

{
  "mcpServers": {
    "kosmokrator-mongodb": {
      "type": "stdio",
      "command": "kosmo",
      "args": [
        "mcp:serve",
        "--integration=mongodb",
        "--write=deny"
      ]
    }
  }
}

Run the Gateway Manually

kosmokrator mcp:serve --integration=mongodb --write=deny

Why Use KosmoKrator Here

Scoped tools

Expose only MongoDB Atlas instead of a broad multi-service tool list.

Local credentials

Reuse credentials already configured for the KosmoKrator CLI and Lua runtime.

Write policy

Start read-only, then opt into ask or allow for trusted workspaces.

MongoDB Atlas Tools Visible to LangChain

LangChain sees stable MCP tool names generated from the MongoDB Atlas integration catalog.

MCP toolSource functionTypeDescription
integration__mongodb__mongodb_find mongodb.mongodb_find Read Query documents from a MongoDB Atlas collection. Supports filtering, projection, sorting, pagination (limit/skip). Returns an array of matching documents.
integration__mongodb__mongodb_find_one mongodb.mongodb_find_one Read Find a single document in a MongoDB Atlas collection. Returns the first matching document or null if no match is found.
integration__mongodb__mongodb_insert_one mongodb.mongodb_insert_one Write Insert a single document into a MongoDB Atlas collection. Returns the inserted document ID.
integration__mongodb__mongodb_insert_many mongodb.mongodb_insert_many Write Insert multiple documents into a MongoDB Atlas collection in a single operation. Returns the inserted document IDs.
integration__mongodb__mongodb_update_one mongodb.mongodb_update_one Write Update a single document in a MongoDB Atlas collection. Uses a filter to match the document and an update operations object (e.g., {"$set": {"field": "value"}}).
integration__mongodb__mongodb_delete_one mongodb.mongodb_delete_one Write Delete a single document from a MongoDB Atlas collection. Uses a filter to match the document to delete.
integration__mongodb__mongodb_aggregate mongodb.mongodb_aggregate Read Run an aggregation pipeline on a MongoDB Atlas collection. Supports all pipeline stages ($match, $group, $sort, $project, $limit, $lookup, etc.).
integration__mongodb__mongodb_list_collections mongodb.mongodb_list_collections Read List all collections in a MongoDB Atlas database. Useful for discovering what data is available before running queries.
integration__mongodb__mongodb_get_current_user mongodb.mongodb_get_current_user Read Verify connectivity to MongoDB Atlas and get current user/session information. Useful for testing that credentials are working.

Related MongoDB Atlas Pages