KosmoKrator

data

MongoDB Atlas CLI for AI Agents

Use the MongoDB Atlas CLI from KosmoKrator to call MongoDB Atlas tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

MongoDB Atlas CLI Setup

MongoDB Atlas can be configured headlessly with `kosmokrator integrations:configure mongodb`.

Install, configure, and verify
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure mongodb --set api_key="$MONGODB_API_KEY" --set cluster_url="$MONGODB_CLUSTER_URL" --enable --read allow --write ask --json
kosmokrator integrations:doctor mongodb --json
kosmokrator integrations:status --json

Credentials

Authentication type: API key api_key. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.

KeyEnv varTypeRequiredLabel
api_key MONGODB_API_KEY Secret secret yes API Key
cluster_url MONGODB_CLUSTER_URL URL url yes Data API Endpoint URL
data_source MONGODB_DATA_SOURCE Text text no Data Source

Command Patterns

The generic command is stable across every integration. The provider shortcut is shorter for humans.

Generic CLI call
kosmo integrations:call mongodb.mongodb_find '{"database":"example_database","collection":"example_collection","filter":"example_filter","projection":"example_projection","sort":"example_sort","limit":1,"skip":1}' --json
Provider shortcut
kosmo integrations:mongodb mongodb_find '{"database":"example_database","collection":"example_collection","filter":"example_filter","projection":"example_projection","sort":"example_sort","limit":1,"skip":1}' --json

Discovery

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

Discovery commands
kosmo integrations:docs mongodb --json
kosmo integrations:docs mongodb.mongodb_find --json
kosmo integrations:schema mongodb.mongodb_find --json
kosmo integrations:search "MongoDB Atlas" --json
kosmo integrations:list --json

Automation Contexts

The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.

CLI Functions

Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.

mongodb.mongodb_find

Query documents from a MongoDB Atlas collection. Supports filtering, projection, sorting, pagination (limit/skip). Returns an array of matching documents.

Read read
Parameters
database, collection, filter, projection, sort, limit, skip
Generic call
kosmo integrations:call mongodb.mongodb_find '{"database":"example_database","collection":"example_collection","filter":"example_filter","projection":"example_projection","sort":"example_sort","limit":1,"skip":1}' --json
Shortcut
kosmo integrations:mongodb mongodb_find '{"database":"example_database","collection":"example_collection","filter":"example_filter","projection":"example_projection","sort":"example_sort","limit":1,"skip":1}' --json

mongodb.mongodb_find_one

Find a single document in a MongoDB Atlas collection. Returns the first matching document or null if no match is found.

Read read
Parameters
database, collection, filter, projection
Generic call
kosmo integrations:call mongodb.mongodb_find_one '{"database":"example_database","collection":"example_collection","filter":"example_filter","projection":"example_projection"}' --json
Shortcut
kosmo integrations:mongodb mongodb_find_one '{"database":"example_database","collection":"example_collection","filter":"example_filter","projection":"example_projection"}' --json

mongodb.mongodb_insert_one

Insert a single document into a MongoDB Atlas collection. Returns the inserted document ID.

Write write
Parameters
database, collection, document
Generic call
kosmo integrations:call mongodb.mongodb_insert_one '{"database":"example_database","collection":"example_collection","document":"example_document"}' --json
Shortcut
kosmo integrations:mongodb mongodb_insert_one '{"database":"example_database","collection":"example_collection","document":"example_document"}' --json

mongodb.mongodb_insert_many

Insert multiple documents into a MongoDB Atlas collection in a single operation. Returns the inserted document IDs.

Write write
Parameters
database, collection, documents
Generic call
kosmo integrations:call mongodb.mongodb_insert_many '{"database":"example_database","collection":"example_collection","documents":"example_documents"}' --json
Shortcut
kosmo integrations:mongodb mongodb_insert_many '{"database":"example_database","collection":"example_collection","documents":"example_documents"}' --json

mongodb.mongodb_update_one

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"}}).

Write write
Parameters
database, collection, filter, update
Generic call
kosmo integrations:call mongodb.mongodb_update_one '{"database":"example_database","collection":"example_collection","filter":"example_filter","update":"example_update"}' --json
Shortcut
kosmo integrations:mongodb mongodb_update_one '{"database":"example_database","collection":"example_collection","filter":"example_filter","update":"example_update"}' --json

mongodb.mongodb_update_many

Update multiple documents in a MongoDB Atlas collection. Uses a filter to match documents and an update operations object such as {"$set": {"status": "active"}}.

Write write
Parameters
database, collection, filter, update
Generic call
kosmo integrations:call mongodb.mongodb_update_many '{"database":"example_database","collection":"example_collection","filter":"example_filter","update":"example_update"}' --json
Shortcut
kosmo integrations:mongodb mongodb_update_many '{"database":"example_database","collection":"example_collection","filter":"example_filter","update":"example_update"}' --json

mongodb.mongodb_delete_one

Delete a single document from a MongoDB Atlas collection. Uses a filter to match the document to delete.

Write write
Parameters
database, collection, filter
Generic call
kosmo integrations:call mongodb.mongodb_delete_one '{"database":"example_database","collection":"example_collection","filter":"example_filter"}' --json
Shortcut
kosmo integrations:mongodb mongodb_delete_one '{"database":"example_database","collection":"example_collection","filter":"example_filter"}' --json

mongodb.mongodb_delete_many

Delete multiple documents from a MongoDB Atlas collection. Use a precise filter; an empty filter can delete every document in the collection.

Write write
Parameters
database, collection, filter
Generic call
kosmo integrations:call mongodb.mongodb_delete_many '{"database":"example_database","collection":"example_collection","filter":"example_filter"}' --json
Shortcut
kosmo integrations:mongodb mongodb_delete_many '{"database":"example_database","collection":"example_collection","filter":"example_filter"}' --json

mongodb.mongodb_aggregate

Run an aggregation pipeline on a MongoDB Atlas collection. Supports all pipeline stages ($match, $group, $sort, $project, $limit, $lookup, etc.).

Read read
Parameters
database, collection, pipeline
Generic call
kosmo integrations:call mongodb.mongodb_aggregate '{"database":"example_database","collection":"example_collection","pipeline":"example_pipeline"}' --json
Shortcut
kosmo integrations:mongodb mongodb_aggregate '{"database":"example_database","collection":"example_collection","pipeline":"example_pipeline"}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

mongodb.mongodb_find 7 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_find --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
filter object no MongoDB query filter (e.g., {"status": "active"}). Defaults to {} (all documents).
projection object no Fields to include/exclude (e.g., {"name": 1, "_id": 0}).
sort object no Sort specification (e.g., {"createdAt": -1}).
limit integer no Maximum number of documents to return.
skip integer no Number of documents to skip (for pagination).
mongodb.mongodb_find_one 4 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_find_one --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
filter object no MongoDB query filter (e.g., {"_id": {"$oid": "..."}}). Defaults to {} (first document).
projection object no Fields to include/exclude (e.g., {"name": 1, "_id": 0}).
mongodb.mongodb_insert_one 3 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_insert_one --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
document object yes The document to insert (e.g., {"name": "Alice", "age": 30}). Do not include _id unless you want a custom value.
mongodb.mongodb_insert_many 3 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_insert_many --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
documents array yes Array of documents to insert (e.g., [{"name": "Alice"}, {"name": "Bob"}]).
mongodb.mongodb_update_one 4 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_update_one --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
filter object yes MongoDB query filter to match the document (e.g., {"_id": {"$oid": "..."}}).
update object yes Update operations (e.g., {"$set": {"status": "active"}}). Use MongoDB update operators like $set, $inc, $push, etc.
mongodb.mongodb_update_many 4 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_update_many --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
filter object yes MongoDB query filter to match documents. Use a specific filter for destructive or broad updates.
update object yes Update operations such as {"$set": {"status": "active"}}.
mongodb.mongodb_delete_one 3 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_delete_one --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
filter object yes MongoDB query filter to match the document to delete (e.g., {"_id": {"$oid": "..."}}).
mongodb.mongodb_delete_many 3 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_delete_many --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
filter object yes MongoDB query filter to match documents to delete.
mongodb.mongodb_aggregate 3 parameters
Schema command
kosmo integrations:schema mongodb.mongodb_aggregate --json
ParameterTypeRequiredDescription
database string yes The database name.
collection string yes The collection name.
pipeline array yes Array of pipeline stages (e.g., [{"$match": {"status": "active"}}, {"$group": {"_id": "$category", "count": {"$sum": 1}}}]).

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.