KosmoKrator

database

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.

9 functions 5 read 4 write API key auth

MongoDB Atlas CLI Setup

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

# 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 use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_key MONGODB_API_KEY Secret secret yes API Key
cluster_url MONGODB_CLUSTER_URL URL url yes Cluster URL

Call MongoDB Atlas Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

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

Use the provider shortcut form for shorter human-facing commands.

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

Agent Discovery Commands

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

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

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to MongoDB Atlas.

mongodb.mongodb_find

Read read

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

Parameters
database, collection, filter, projection, sort, limit, skip

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

mongodb.mongodb_find_one

Read read

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

Parameters
database, collection, filter, projection

Generic CLI call

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

Provider shortcut

kosmo integrations:mongodb mongodb_find_one '{"database":"example_database","collection":"example_collection","filter":"example_filter","projection":"example_projection"}' --json

mongodb.mongodb_insert_one

Write write

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

Parameters
database, collection, document

Generic CLI call

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

Provider shortcut

kosmo integrations:mongodb mongodb_insert_one '{"database":"example_database","collection":"example_collection","document":"example_document"}' --json

mongodb.mongodb_insert_many

Write write

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

Parameters
database, collection, documents

Generic CLI call

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

Provider shortcut

kosmo integrations:mongodb mongodb_insert_many '{"database":"example_database","collection":"example_collection","documents":"example_documents"}' --json

mongodb.mongodb_update_one

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

Parameters
database, collection, filter, update

Generic CLI call

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

Provider shortcut

kosmo integrations:mongodb mongodb_update_one '{"database":"example_database","collection":"example_collection","filter":"example_filter","update":"example_update"}' --json

mongodb.mongodb_delete_one

Write write

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

Parameters
database, collection, filter

Generic CLI call

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

Provider shortcut

kosmo integrations:mongodb mongodb_delete_one '{"database":"example_database","collection":"example_collection","filter":"example_filter"}' --json

mongodb.mongodb_aggregate

Read read

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

Parameters
database, collection, pipeline

Generic CLI call

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

Provider shortcut

kosmo integrations:mongodb mongodb_aggregate '{"database":"example_database","collection":"example_collection","pipeline":"example_pipeline"}' --json

mongodb.mongodb_list_collections

Read read

List all collections in a MongoDB Atlas database. Useful for discovering what data is available before running queries.

Parameters
database

Generic CLI call

kosmo integrations:call mongodb.mongodb_list_collections '{"database":"example_database"}' --json

Provider shortcut

kosmo integrations:mongodb mongodb_list_collections '{"database":"example_database"}' --json

mongodb.mongodb_get_current_user

Read read

Verify connectivity to MongoDB Atlas and get current user/session information. Useful for testing that credentials are working.

Parameters
none

Generic CLI call

kosmo integrations:call mongodb.mongodb_get_current_user '{}' --json

Provider shortcut

kosmo integrations:mongodb mongodb_get_current_user '{}' --json

Function Schemas

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

mongodb.mongodb_find

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

Operation
Read read
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

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

Operation
Read read
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

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

Operation
Write write
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

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

Operation
Write write
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

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

Operation
Write write
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_delete_one

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

Operation
Write write
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_aggregate

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

Operation
Read read
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}}}]).

mongodb.mongodb_list_collections

List all collections in a MongoDB Atlas database. Useful for discovering what data is available before running queries.

Operation
Read read
Schema command
kosmo integrations:schema mongodb.mongodb_list_collections --json
ParameterTypeRequiredDescription
database string yes The database name to list collections from.

mongodb.mongodb_get_current_user

Verify connectivity to MongoDB Atlas and get current user/session information. Useful for testing that credentials are working.

Operation
Read read
Schema command
kosmo integrations:schema mongodb.mongodb_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

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.