‹ 首页

db-mongo

@evolution-foundation · 收录于 5 天前 · 上游提交 2 个月前

Query MongoDB databases configured in .env (DB_MONGO_N_*). Use when the user asks to query, explore, or audit data in a MongoDB database. Picks connection by label (e.g. 'orders-dev', 'analytics-prod') or numeric index. Read-only by default — writes refused unless DB_MONGO_N_ALLOW_WRITE=true on that block.

适合你,如果需要通过自然语言查询 MongoDB 数据库

/ 通过 npx 安装 校验哈希
npx oh-my-skill add evolution-foundation/evo-nexus/db-mongo
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- evolution-foundation/evo-nexus/db-mongo
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify evolution-foundation/evo-nexus/db-mongo
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
509GitHub stars
~929最小装载
~929含声明引用
~3.7K文本包总量
索引托管

怎么用

商店整理自技能原文 · 版本 7f5dd76 · 表述以原文为准
它做什么

Claude 可以查询、探索和审计 MongoDB 数据库中的数据,执行查找文档、聚合管道、列出集合和数据库统计等操作,默认只读,禁止写入。

什么时候触发

当用户要求查询、探索或审计 MongoDB 数据库中的数据时触发。需要预先在 .env 中配置好连接信息。

装好后可以这样说
Claude 将返回该集合最多 10 条文档。
Claude 会执行聚合管道并返回结果。
Claude 会显示配置的 MongoDB 连接标签。
技能原文 SKILL.md作者撰写 · Apache-2.0 · 7f5dd76

db-mongo

Query MongoDB databases declared in .env. Same numbered block pattern as every other db-* and SOCIAL_*_N_* integration.

Setup — one-time, per database

Add a block to .env (gitignored). Two ways to define a connection:

Option A — URI (recommended for Atlas / managed)
DB_MONGO_1_LABEL=orders-dev
DB_MONGO_1_URI=mongodb+srv://user:pw@cluster0.abc.mongodb.net/orders?retryWrites=true
# DB_MONGO_1_DATABASE=orders          # optional if in URI
# DB_MONGO_1_ALLOW_WRITE=false
# DB_MONGO_1_QUERY_TIMEOUT=30
# DB_MONGO_1_MAX_ROWS=1000
Option B — components
DB_MONGO_2_LABEL=analytics-prod
DB_MONGO_2_HOST=mongo.prod.internal
DB_MONGO_2_PORT=27017
DB_MONGO_2_DATABASE=analytics
DB_MONGO_2_USER=agent_readonly
DB_MONGO_2_PASSWORD=...
# DB_MONGO_2_AUTH_SOURCE=admin        # optional
# DB_MONGO_2_TLS=true                 # optional

URI wins when both are set. LABEL is always required.

Usage

All commands output a single JSON line on stdout (safe to pipe).

List configured connections
python3 .claude/skills/db-mongo/scripts/db_client.py accounts
Health-check a connection (MongoDB ping)
python3 .claude/skills/db-mongo/scripts/db_client.py test orders-dev
Find documents
# All (up to MAX_ROWS)
python3 .claude/skills/db-mongo/scripts/db_client.py find orders-dev customers

# With filter (JSON)
python3 .claude/skills/db-mongo/scripts/db_client.py find orders-dev customers \
  '{"status": "active"}' 20
Aggregation pipeline
python3 .claude/skills/db-mongo/scripts/db_client.py aggregate orders-dev orders \
  '[{"$match": {"status": "paid"}}, {"$group": {"_id": "$product", "total": {"$sum": "$amount"}}}]'
Explore database
# List collections
python3 .claude/skills/db-mongo/scripts/db_client.py collections orders-dev

# DB stats (size, object count, index size)
python3 .claude/skills/db-mongo/scripts/db_client.py stats orders-dev
Output shape

Successful find/aggregate:

{
  "ok": true,
  "query_id": "uuid-v4",
  "label": "orders-dev",
  "collection": "customers",
  "documents": [{"_id": "...", "email": "a@b.com"}],
  "row_count": 1,
  "truncated": false,
  "execution_time_ms": 12
}
Guardrails
  • Read-only by default. Aggregation pipelines containing $out or $merge (write stages) are refused unless ALLOW_WRITE=true. find is always safe; no separate write commands are exposed in v1.
  • Query timeout applied at the server selection, socket, and connect levels.
  • Result size capped at MAX_ROWS (default 1000). For aggregations we stop iterating the cursor at that point.
  • Credentials never leave .env; accounts strips password before returning.
Error codes
  • no_connections, not_found, ambiguous, config_error — same as other db-* skills
  • driver_missingpymongo not installed
  • connection_failed — network, auth, TLS, or timeout
  • invalid_filter / invalid_pipeline — JSON parse failed
  • write_blocked — aggregation with $out/$merge on ALLOW_WRITE=false
  • usage — wrong CLI args
Workflow
  1. accounts to confirm the connection label.
  2. collections to see what's in there.
  3. find or aggregate with the smallest query that answers the question.
  4. If a pipeline is expensive, ask the user whether to $limit earlier or add indexes before running.
Dependencies
  • Python 3.10+
  • pymongo — not pre-installed; uv pip install pymongo on first use.
Deep-dive references

Mongo isn't covered by PlanetScale's database-skills upstream. When you need authoritative reference, go to the Mongo docs directly:

按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。