Agent Skillsopskat/opskat › mongodb

mongodb

GitHub

提供MongoDB数据库的查询、修改及管理功能,支持通过命令行语法执行CRUD操作、聚合及集合管理。

internal/ai/skills/mongodb/SKILL.md opskat/opskat

触发场景

需要查询或筛选MongoDB数据 需要向MongoDB插入、更新或删除文档 需要列出数据库或集合

安装

npx skills add opskat/opskat --skill mongodb -g -y
更多选项

非标准路径

npx skills add https://github.com/opskat/opskat/tree/main/internal/ai/skills/mongodb -g -y

不安装直接使用

npx skills use opskat/opskat@mongodb

指定 Agent (Claude Code)

npx skills add opskat/opskat --skill mongodb -a claude-code -g -y

安装 repo 全部 skill

npx skills add opskat/opskat --all -g -y

预览 repo 内 skill

npx skills add opskat/opskat --list

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 users
  • insertOne users --query='{"document":{"name":"alice"}}'
  • updateMany users --query='{"filter":{"active":false},"update":{"$set":{"archived":true}}}'
  • deleteMany logs --query='{"filter":{"level":"debug"}}'
  • listDatabases
  • listCollections --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, skip
  • findOne: filter, projection (sort / limit / skip are silently ignored)
  • insertOne: document · insertMany: documents
  • updateOne / updateMany: filter, update
  • deleteOne / deleteMany: filter
  • aggregate: pipeline
  • countDocuments: filter

Notes

  • Always single-quote --query — it is JSON and contains spaces and braces.
  • find returns at most 100 documents when limit is omitted. Pass an explicit limit when you need to know you have the whole result set.
  • Every operation except listDatabases needs a database. --db names it; if you omit --db, the asset's configured default database is used. When the asset has no default database configured, omitting --db fails — pass it explicitly.
  • listDatabases and listCollections take no collection; every other operation requires one.
  • Omitting --query means "no filter": deleteMany logs deletes every document in the collection, and updateMany without an update sub-key fails. Pass an explicit filter whenever 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 --db and --query exist.
  • The scope parameter is not used by MongoDB assets; use --db instead.
  • Server version vs driver: the default driver requires MongoDB 4.2+. For MongoDB 3.6–4.0, set legacy_compat: true on the asset (UI: “Legacy compatibility” under Advanced). Without it, connection and exec commands fail against older servers.

Asset config (for put_asset)

field type required notes
host string yes
port number no Defaults to 27017
username string yes MongoDB account name
password string no Write-only. Encrypted in the asset; does not create a credential
credential_id number no Existing managed password credential ID
database string no Default database
legacy_compat boolean no Use the v1 driver for MongoDB 3.6–4.0; default false (v2 driver, 4.2+)
ssh_asset_id number no SSH asset to tunnel through; 0 detaches

password and credential_id are mutually exclusive. Plaintext is never returned, is encrypted in the asset, and never creates a managed credential. Auth source is fixed to admin; it is not configurable through put_asset.

版本历史

  • b159e91 当前 2026-08-19 20:20

    新增 legacy_compat 配置以支持 MongoDB 3.6-4.0 旧版驱动兼容;重构代码合并 v1/v2 驱动逻辑,消除镜像复制漂移。

  • d6c7a6e 2026-08-16 07:29

    修正 findOne 仅支持 filter/projection 及 find 省略 limit 时封顶 100 条的事实性错误。

  • aeb4bc3 2026-07-24 16:28

同 Skill 集合

internal/ai/skills/database/SKILL.md
internal/ai/skills/etcd/SKILL.md
internal/ai/skills/k8s/SKILL.md
internal/ai/skills/kafka/SKILL.md
internal/ai/skills/local/SKILL.md
internal/ai/skills/oss/SKILL.md
internal/ai/skills/rdp/SKILL.md
internal/ai/skills/redis/SKILL.md
internal/ai/skills/serial/SKILL.md
internal/ai/skills/ssh/SKILL.md
internal/ai/skills/vnc/SKILL.md
plugin/opsctl/skills/opsctl/SKILL.md

元信息

文件数
0
版本
d919872
Hash
dfe02ee6
收录时间
2026-07-24 16:28

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-27 23:48
浙ICP备14020137号-1 $访客地图$