Agent Skillsopskat/opskat › mongodb

mongodb

GitHub

提供 MongoDB 集合的查询与修改能力,支持 find、insert、update 等操作。通过 exec 执行命令,使用 JSON 语法构建查询条件,适用于数据库数据检索、写入及变更任务。

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

Trigger Scenarios

需要查询 MongoDB 数据 需要向 MongoDB 插入或更新文档 需要删除 MongoDB 记录 需要聚合分析 MongoDB 数据

Install

npx skills add opskat/opskat --skill mongodb -g -y
More Options

Non-standard path

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

Use without installing

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.

Version History

  • b159e91 Current 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

Same Skill Collection

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

Metadata

Files
0
Version
b159e91
Hash
dfe02ee6
Indexed
2026-07-24 16:28

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 06:54
浙ICP备14020137号-1 $Гость$