mongodb
GitHub提供 MongoDB 集合的查询与修改能力,支持 find、insert、update、delete 及聚合等操作。通过 exec 执行命令,使用 JSON 语法传递查询参数,适用于数据检索、写入、更新及批量处理场景。
Trigger Scenarios
Install
npx skills add opskat/opskat --skill mongodb -g -y
SKILL.md
Frontmatter
{
"name": "mongodb",
"description": "Query and modify MongoDB collections via exec, using an operation + collection + JSON query syntax."
}
MongoDB assets
Command syntax
<operation> [collection] [--db=<database>] [--query=<json>]
find users --query='{"filter":{"age":{"$gt":21}},"limit":10}'findOne users --query='{"filter":{"_id":"abc"}}'aggregate events --query='{"pipeline":[{"$match":{"type":"click"}}]}'countDocuments usersinsertOne users --query='{"document":{"name":"alice"}}'updateMany users --query='{"filter":{"active":false},"update":{"$set":{"archived":true}}}'deleteMany logs --query='{"filter":{"level":"debug"}}'listDatabaseslistCollections --db=analytics
Supported operations: find, findOne, insertOne, insertMany, updateOne,
updateMany, deleteOne, deleteMany, aggregate, countDocuments,
listDatabases, listCollections. Anything else is rejected.
Query sub-keys
--query is a single JSON object. Which sub-keys apply depends on the operation:
find:filter,sort,projection,limit,skipfindOne:filter,projection(sort/limit/skipare silently ignored)insertOne:document·insertMany:documentsupdateOne/updateMany:filter,updatedeleteOne/deleteMany:filteraggregate:pipelinecountDocuments:filter
Notes
- Always single-quote
--query— it is JSON and contains spaces and braces. findreturns at most 100 documents whenlimitis omitted. Pass an explicitlimitwhen you need to know you have the whole result set.- Every operation except
listDatabasesneeds a database.--dbnames it; if you omit--db, the asset's configured default database is used. When the asset has no default database configured, omitting--dbfails — pass it explicitly. listDatabasesandlistCollectionstake no collection; every other operation requires one.- Omitting
--querymeans "no filter":deleteMany logsdeletes every document in the collection, andupdateManywithout anupdatesub-key fails. Pass an explicitfilterwhenever you mean a subset. - Quote a collection name containing spaces (
countDocuments 'my coll'). A collection name starting with--cannot be expressed — it is read as a flag. - The command line is shell-tokenized but not shell-executed:
$,|,>,&and similar shell metacharacters produce an error rather than expanding or redirecting. Wrap values containing them in single quotes. - Unknown flags are rejected rather than ignored; only
--dband--queryexist. - The
scopeparameter is not used by MongoDB assets; use--dbinstead.
Asset config (for put_asset)
| field | type | required | notes |
|---|---|---|---|
host |
string | yes | |
port |
number | yes | No server-side default — pass 27017 explicitly |
username |
string | yes | |
password |
string | no | Stored encrypted; never echoed back |
database |
string | no | Default database |
ssh_asset_id |
number | no | SSH asset to tunnel through; 0 detaches |
Auth source is fixed to admin; it is not configurable through put_asset.
Version History
-
d6c7a6e
Current 2026-08-16 07:29
修正 findOne 仅支持 filter/projection 及 find 省略 limit 时封顶 100 条的事实性错误。
- aeb4bc3 2026-07-24 16:28


