agent-mongo
npx skills add https://github.com/shhac/agent-mongo --skill agent-mongo
Agent 安装分布
Skill 文档
MongoDB exploration with agent-mongo
agent-mongo is a read-only CLI binary on $PATH. All output is JSON to stdout. Errors go to stderr as { "error": "..." } with non-zero exit.
Quick start (connections)
Set up a connection:
agent-mongo connection add local "mongodb://localhost:27017/myapp" --default
agent-mongo connection test
For authenticated connections, store credentials separately:
agent-mongo credential add acme --username deploy --password secret
agent-mongo connection add prod "mongodb+srv://cluster.example.net/myapp" --credential acme --default
Exploring a database
agent-mongo db list # all databases with sizes
agent-mongo collection list myapp # all collections in myapp
agent-mongo collection schema myapp users # infer schema from samples
agent-mongo collection indexes myapp users # index key patterns
agent-mongo collection stats myapp orders # document count, sizes
agent-mongo db stats myapp # database-level statistics
Querying documents
agent-mongo query find myapp users --filter '{"age":{"$gte":21}}' --limit 10
agent-mongo query find myapp orders --sort '{"createdAt":-1}' --projection '{"status":1,"total":1}'
agent-mongo query get myapp users 665a1b2c3d4e5f6a7b8c9d0e # by _id (auto-detects ObjectId)
agent-mongo query count myapp orders --filter '{"status":"pending"}'
agent-mongo query sample myapp users --size 10 # random documents
agent-mongo query distinct myapp orders status # unique values
Aggregation
agent-mongo query aggregate myapp orders --pipeline '[{"$group":{"_id":"$status","count":{"$sum":1}}}]'
agent-mongo query aggregate myapp events --pipeline '[{"$match":{"type":"purchase"}},{"$group":{"_id":"$userId","total":{"$sum":"$amount"}}}]'
Write stages ($out, $merge) are rejected â the CLI is strictly read-only.
Connection management
agent-mongo connection list # saved connections + defaults
agent-mongo connection add staging "mongodb://..." --credential acme
agent-mongo connection update prod --credential new-cred
agent-mongo connection set-default staging
agent-mongo connection remove old-conn
agent-mongo connection test -c prod # verify connectivity
Connection resolution: -c flag > AGENT_MONGO_CONNECTION env > config default > error listing available connections.
Credential management
agent-mongo credential add acme --username deploy --password secret
agent-mongo credential list # passwords always redacted
agent-mongo credential remove acme --force # even if connections reference it
Credentials are stored separately from connections. When you rotate a password, just re-add the credential â all connections referencing it pick up the new auth automatically.
Truncation
Any string field exceeding truncation.maxLength (default 200) gets truncated with ⦠and a companion {field}Length key showing original length.
agent-mongo --full query find myapp posts # expand all fields
agent-mongo --expand description query find myapp posts # expand specific field
These are global flags â place them before or after the command.
Configuration
agent-mongo config list-keys # all keys with defaults/ranges
agent-mongo config set defaults.limit 50
agent-mongo config get query.timeout
agent-mongo config reset # restore defaults
Key settings: defaults.limit (20), defaults.sampleSize (5), defaults.schemaSampleSize (100), query.timeout (30000ms), query.maxDocuments (100), truncation.maxLength (200).
Safety
- Read-only: No write operations exist
- Aggregation:
$outand$mergestages rejected - Result cap:
query.maxDocuments(default 100) - Timeout:
query.timeout(default 30s)
Per-command usage docs
Every command group has a usage subcommand with detailed, LLM-optimized docs:
agent-mongo usage # top-level overview
agent-mongo connection usage # connection + credential commands
agent-mongo credential usage # credential management
agent-mongo db usage # database commands
agent-mongo collection usage # collection commands
agent-mongo query usage # all query commands
agent-mongo config usage # settings keys, defaults, validation
Use agent-mongo <command> usage when you need deep detail on a specific domain before acting.
References
- references/commands.md: full command map + all flags
- references/output.md: JSON output shapes + field details