ai-agent-readonly-context
Use when the user is WIRING CUB-SCOUT INTO AN AI AGENT (Claude / Codex / a custom LLM workflow) and needs the patterns for read-only context, MCP gateway tools, deterministic context snapshots, and the prompt-shape that makes cub-scout's output reliable for LLMs. Natural phrasing: "set up cub-scout as a Claude tool", "expose cub-scout to my agent over MCP", "give the LLM a deterministic snapshot of this cluster", "what cub-scout patterns work well for AI agents?", "MCP config for cub-scout in Claude Code", "best practices for wiring cub-scout into Codex / Cursor / Continue", "AI-ready cluster context", "prompt template for cub-scout output". Composes `mcp serve` + `context-pack` + `--presentation ai` + the structured JSON contracts. Do NOT load for: a specific verb invocation (load the corresponding scout-* skill), authoring an MCP server in general (this is about wiring CUB-SCOUT specifically), or any mutating workflow (cub-scout never mutates; the read-only triad is the whole point of this skill).
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 14
- Forks
- 1
01 前言 Front Matter
- name
- ai-agent-readonly-context
- phase
- cross-cutting
- description
- Use when the user is WIRING CUB-SCOUT INTO AN AI AGENT (Claude / Codex / a custom LLM workflow) and needs the patterns for read-only context, MCP gateway tools, deterministic context snapshots, and the prompt-shape that makes cub-scout's output reliable for LLMs. Natural phrasing: "set up cub-scout as a Claude tool", "expose cub-scout to my agent over MCP", "give the LLM a deterministic snapshot of this cluster", "what cub-scout patterns work well for AI agents?", "MCP config for cub-scout in Claude Code", "best practices for wiring cub-scout into Codex / Cursor / Continue", "AI-ready cluster context", "prompt template for cub-scout output". Composes `mcp serve` + `context-pack` + `--presentation ai` + the structured JSON contracts. Do NOT load for: a specific verb invocation (load the corresponding scout-* skill), authoring an MCP server in general (this is about wiring CUB-SCOUT specifically), or any mutating workflow (cub-scout never mutates; the read-only triad is the whole point of this skill).
- allowed-tools
- Bash(./cub-scout mcp *) Bash(cub-scout mcp *) Bash(cub scout mcp *) Bash(./cub-scout context-pack *) Bash(cub-scout context-pack *) Bash(cub scout context-pack *) Bash(./cub-scout doctor *) Bash(cub-scout doctor *) Bash(cub scout doctor *) Bash(./cub-scout explain *) Bash(cub-scout explain *) Bash(cub scout explain *) Bash(./cub-scout trace *) Bash(cub-scout trace *) Bash(cub scout trace *) Bash(./cub-scout status) Bash(cub-scout status) Bash(cub scout status) Bash(./cub-scout version) Bash(cub-scout version) Bash(cub scout version)
03 SKILL.md 正文
ai-agent-readonly-context
The agent-integration loop. The user is wiring cub-scout into an AI agent — Claude Code, Codex, Cursor, Continue, a custom MCP-aware LLM — and needs the patterns that make cub-scout's output reliable for LLMs.
Three patterns matter here, plus the prompt shape that ties them together:
- MCP gateway (
mcp serve) — long-running tool surface the agent calls live - context-pack (
context-pack --format json) — deterministic one-shot snapshot the agent reasons over --presentation ai— output format with bracket notation + uppercase markers that LLMs parse reliably
Plus the read-only invariant: every cub-scout tool an agent can call is categorically non-mutating. cub-scout is the safest possible AI surface because the worst-case prompt-injection still can't apply / edit / delete anything.
When to use
Explicit phrasings:
- "Set up cub-scout as a Claude tool"
- "Expose cub-scout to my agent over MCP"
- "Give the LLM a deterministic snapshot of this cluster"
- "What cub-scout patterns work well for AI agents?"
- "MCP config for cub-scout in Claude Code / Codex / Cursor / Continue"
- "Best practices for wiring cub-scout into [agent framework]"
- "AI-ready cluster context for my LLM workflow"
- "Prompt template for cub-scout output"
- "How do I make cub-scout JSON parseable by an LLM?"
Implicit intents:
- The user is integrating, not running cub-scout interactively
- The user values determinism (same input → same bytes)
- The user values read-only safety (prompt injection can't escalate to cluster mutation)
- The user may be combining cub-scout with
cub/kubectl/ other tools in the agent's tool set
Do not load for
- A specific verb invocation — load the matching
scout-*skill - Authoring an MCP server in general (this is about wiring cub-scout specifically) — use the MCP-server-authoring docs from the agent host
- Mutating workflows. cub-scout never mutates; the read-only triad is the whole point of this skill.
- ConfigHub-side MCP integration — that's
cub, a separate tool surface
The patterns
Pattern 1 — MCP gateway (live tool calls)
cub-scout mcp serve is a long-running MCP server exposing cub-scout's verbs as tools. Register it in your agent host's MCP config:
// .claude/mcp_servers.json (Claude Code) — STDIO transport (preferred)
{
"mcpServers": {
"cub-scout": {
"command": "cub-scout",
"args": ["mcp", "serve"],
"env": {
"KUBECONFIG": "${env:HOME}/.kube/config"
}
}
}
}
The agent host calls tools/list to discover tools and tools/call to invoke them. cub-scout's mcp_test.go covers the exact catalog:
Standalone-mode tools (8, always available):
doctor— cluster-level diagnostic with structured nextStepsmap— resource inventory with ownership classificationscan— risk + misconfiguration findingstrace— ownership + source chain (one resource)explain— plain-English per-resource reportgitops_status— GitOps/controller delivery status and coverage evidencegitops_settings— the delivery settings each Argo CD and Flux deployer declares (auto-sync, self-heal, prune, suspension); declared settings only, no verdict (preview)release_check— whether one exact, digest-pinned configuration release reached a target, stage by stage; no application-success claim
Connected-mode tools (13, added when the ConfigHub session check passes; since v2.14.0 that check and most of these reads go through the ConfigHub SDK, with no cub binary):
compare_three_way— DRY/WET/LIVE with rolled-up agreementcompare_source_truth— strategy-typed verdict (target + namespace + strategy required)confighub_attestations— attestations ConfigHub records directly against one exact revision (space, unit and revision required); recorded claims, not an approval verdictconfighub_changeorder_get— exact-space reported ChangeOrder Stage/State and declarations; evaluated outcomes unknown, including Completedconfighub_changesets— governed ChangeSet history from ConfigHubconfighub_k8s_resources— ConfigHub Resource-backed intended Kubernetes resourcesconfighub_k8s_types— ConfigHub Resource-backed intended Kubernetes type surveyconfighub_live_status— ConfigHub Space live-status writeback with freshnessconfighub_releases— bounded ConfigHub Release historyconfighub_resources— generic ConfigHub Resource entity queriesconfighub_unit_events— bounded ConfigHub UnitEvent historyconfighub_units— ConfigHub unit + fleet inventoryconfighub_unit_get— exact ConfigHub unit details + applied/live revision
Use the standard MCP tools/list request to dump the registered catalog from
the running server. See references/mcp-tool-catalog.md for per-tool parameters, return shape, and the list of verbs intentionally NOT in the catalog.
Pattern 2 — context-pack (deterministic snapshot)
cub-scout context-pack --format json produces a one-shot deterministic JSON snapshot of the cluster. Same input → same bytes. Safe to feed an LLM with prompt caching; safe to diff in CI.
$ cub-scout context-pack --format json > cluster-ctx.json
$ wc -l cluster-ctx.json
2347 cluster-ctx.json
$ jq '.ownership | group_by(.type) | map({type: .[0].type, count: length})' cluster-ctx.json
[
{"type": "argo", "count": 47},
{"type": "flux", "count": 12},
{"type": "helm", "count": 8},
{"type": "native", "count": 23},
{"type": "unknown", "count": 3}
]
The pack carries:
version— cub-scout build tag + context-pack schema versioncapturedAt— RFC 3339 timestamp (the ONLY non-deterministic field; everything else is reproducible)cluster— kubeconfig context + server URLmode—standaloneorconnectedresources[]— per-workload kind / name / namespace / ownership classificationattribution[]— per-resource attribution evidence (cause,managerHint,gitSource,bindingSource)omissions[]— explicit non-claims (e.g., resources skipped due to CrashLoop, unsupported kinds)
For lower-level JSON artifacts outside context-pack, prefer the shared
observation metadata when present. map list --format json, snapshot,
summary list --format json, and watch/bot events expose
observation.source, observation.mode, observation.observedAt, and
observation.freshness so an agent can tell whether it is reasoning over a
fresh live read, stored summary evidence, a point-in-time snapshot, or an event
from a polling observer.
Feed it to the LLM as a system message context block:
You have read-only access to a Kubernetes cluster snapshot via the JSON below.
Cluster: <cluster name>
Mode: <standalone|connected>
Captured at: <RFC3339>
<cluster-ctx.json>
You can also call the following MCP tools for deeper reads: ...
Pattern 3 — --presentation ai
For agent prompts that consume ASCII output (not JSON), --presentation ai produces a structured form LLMs parse reliably. Uppercase markers; bracket notation; consistent label-value separators.
$ cub-scout explain deploy/api -n prod --presentation ai
[explain]
Resource: Deployment/api in prod
Owner: Argo CD application "payments-api" [label:argocd.argoproj.io/instance]
Drift: Detected
Mutation cause: manual-edit [manager: kubectl-edit; controller co-signal: argocd-controller]
Git source: https://github.com/org/platform-config @abc123 path=apps/prod/api
Events: ImagePullBackOff (5 mins ago, repeating)
Recommended actions:
- [read-only] Image ghcr.io/org/api:v2.3.0 cannot be pulled; check ghcr.io status
- [read-only] If image is correct, verify imagePullSecrets
[end explain]
vs. the default human form:
$ cub-scout explain deploy/api -n prod
Resource: Deployment/api in prod
Owner: Argo CD application "payments-api"
(label:argocd.argoproj.io/instance)
...
The AI form is denser, less ambiguous, and parseable with regex if needed.
Available on doctor / explain / trace (per #352 / #359). The --presentation paired flag emits both forms for human + AI dual-purpose output.
The read-only invariant
This is the value proposition for AI integration. cub-scout's MCP tool catalog is closed and read-only by construction:
- Every tool wraps a read-only cub-scout verb with
--format jsonor a read-onlycublist/get query - Every verb is non-mutating
- The tool catalog is verified by
cmd/cub-scout/mcp_test.go— adding a tool requires a code change + a passing test - The receipt capability's
FilterNextSteps(pkg/agent/receipt_predicates.go) strips mutatingactionType/nextCommandfrom any structured next-step hint before emit TestReceiptPackageReadOnlyClientstatically greps the receipt source for any mutating K8s client method
Consequence: even with a fully-compromised prompt, an LLM calling cub-scout's MCP tools cannot apply / edit / patch / delete anything. The blast radius is reads.
This is unusual — most operational tools mix read and write surfaces. cub-scout's #410 / #428 architectural-triad work made the read-only carve-out a code-enforced invariant, not a convention. That's what makes cub-scout the safest Kubernetes MCP surface for AI agents today.
Worked example: Claude Code integration
// .claude/mcp_servers.json
{
"mcpServers": {
"cub-scout": {
"command": "cub-scout",
"args": ["mcp", "serve"]
}
}
}
// .claude/skills.json — load the relevant scout-* skills
{
"skills": [
"scout-observe", "scout-diagnose", "scout-compare", "scout-attribute",
"scout-verify", "scout-mcp",
"triage-unhealthy-workload", "investigate-drift"
]
}
User prompt: "deploy/api in prod is broken, what's going on?"
Agent's likely loop:
- Trigger
triage-unhealthy-workloadskill - Call MCP tool
doctor(scope: namespace=prod) - Call MCP tool
explain(deploy/api -n prod) - Call MCP tool
trace(deploy/api -n prod) - Read structured
nextSteps[]+events[]from the responses - Synthesize human-language explanation; route the mutation suggestion to the user
The agent NEVER calls a mutating MCP tool because there are none registered. The user drives kubectl rollout undo / argocd app rollback from a separate context if needed.
Configuration tips
- Prefer STDIO over HTTP for agent integration — lower latency, easier to sandbox, no port management.
- Set
KUBECONFIGexplicitly in the MCP env block so the server picks up the right cluster context. Don't rely on the agent host inheriting it. - For multi-cluster contexts, run one
mcp serveinstance per cluster on different ports / paths, OR use the--context <name>flag to switch contexts in-process. cub-scout doesn't support multi-context-in-one-server today (a singlemcp serveis one context). - Cache
context-packaggressively. It's deterministic; an LLM with prompt caching benefits enormously from caching the snapshot across multiple queries. - Use connected mode if the agent is doing source-truth / governance work. Check
confighub_readsincub-scout status --jsonfirst (cub auth statuschecks the same session whencubis installed); the agent should refuse to claim source-truth verdicts in standalone mode.
Tool boundary
- Allowed:
mcp serve(long-running but no mutation),context-pack,status,version, plus the read-only verbs the agent will indirectly call through MCP. - Not allowed: any mutating verb. The MCP gateway never registers one; the static guards in cub-scout enforce it.
- MCP and the triad: cub-scout (evidence) ↔ MCP (transport) ↔ Pilot or agent (judge / actor). The MCP layer is plumbing; it never decides.
References
scout-mcp— the verb-group skill formcp serveandcontext-pack- MCP tool descriptions audit:
#377 --presentationflag:#352(doctor / explain),#359(trace)- Connected MCP trust surface:
docs/reference/json-contracts.md§ "MCP connected trust guidance" - Context-pack format:
docs/howto/context-pack-v2.md - Examples:
examples/ai-integration/,examples/mcp-gateway/,examples/ai-agent-quest/ - Read-only triad:
#410,#428
Constraints
- The MCP tool catalog is closed. Adding tools requires a code change + a passing
mcp_test.gotest. Don't claim cub-scout has a mutating MCP tool — it doesn't, by design. context-packis deterministic (same input, same bytes) EXCEPT for thecapturedAttimestamp. If you need byte-identical output across runs, set a fixedcapturedAtin your wrapper.- For agent hosts that don't speak MCP yet, fall back to invoking cub-scout verbs directly via shell tools with
--format json --presentation ai. The structured output is the same. - This skill's read-only invariant doesn't extend to
cub. If the agent has BOTH cub-scout AND cub MCP tools registered, the cub side IS mutation-capable. Use a separate allowed-tools policy for that surface.
04 同仓库更多 Skills
triage-unhealthy-workload
Use when the user is responding to a broken Kubernetes workload UNDER TIME PRESSURE — pager-going-off, CI-red, "prod is down" framing. Natural phrasing: "deploy/api is CrashLoopBackOff, what now?", "the rollout is stuck, help", "this pod won't start", "pager fired on payments", "everything is red in argocd", "what should I check first?", "give me a triage plan for this workload". Composes doctor → explain → trace into a tight ~30-second loop the operator can run in a pager-acknowledged context. Do NOT load for: a planned investigation without urgency (use scout-diagnose directly), a drift question (use investigate-drift), or anything mutating (cub-scout never mutates — route to kubectl with the user driving).
scout-verify
Use when the user wants a TYPED, FINGERPRINTED, IMMUTABLE evidence artifact about a Kubernetes resource — the Verify verb group of cub-scout (the receipt capability shipped in #446). Natural phrasing: "produce a receipt that this is in compliance", "give me an attestation that the cluster matches Git", "I need a verifiable record for the audit trail", "build a receipt verifying no manual edits since deploy", "verify deploy/api against source-truth and save the artifact", "validate this receipt has not been tampered with", "show me what receipts we have", "is this receipt tampered with?", "attach evidence to my CI gate". Load whenever intent is receipt / attestation / evidence-artifact / tamper-evident-record / verified-record / audit-trail / postmortem-evidence / acceptance-judge-input. Do NOT load for: a live comparison without a persisted artifact (use scout-compare), interpreting a single field's provenance (use scout-attribute), or actually applying a fix (cub-scout never mutates — route to cub / argocd / kubectl with the user driving).
scout-observe
Use when the user wants to SEE what is running in a Kubernetes cluster, who owns it, and how it is structured — the read-only Observe verb group of cub-scout. Natural phrasing: "what is running in my cluster?", "give me a map of resources", "who owns this Deployment?", "trace this back to its source", "show me the ownership tree", "scan this cluster for risk", "dump the cluster as JSON", "stream cluster events", "run cub-scout as a bot", "what is the connection status?", "is this cluster healthy?". Load when intent is observe / inventory / map / show / list / trace / scan / dump / stream / bot / health-check over a Kubernetes cluster. Do NOT load for: explaining WHY something is broken (use scout-diagnose), comparing cluster state to intended state (use scout-compare), provenance of individual field values (use scout-attribute), or any action that mutates the cluster (cub-scout never mutates — route to cub or kubectl with the user driving).
scout-mcp
Use when the user wants to expose cub-scout to an AI agent over MCP, wants a deterministic AI-ready snapshot of cluster context, or wants cub-scout running as a read-only event bot — the Integrate verb group. Natural phrasing: "start the MCP server", "expose cub-scout to Claude / Codex / my agent", "give me an AI-ready context pack of this cluster", "set up the MCP gateway", "what MCP tools does cub-scout expose?", "run cub-scout as a bot", "produce JSON context for an LLM to reason about this cluster". Load whenever intent is mcp / mcp-gateway / mcp-serve / context-pack / bot / agent-context / ai-snapshot / llm-context / model-context-protocol. Do NOT load for: actually running a non-integrate verb (those are scout-observe / scout-diagnose / scout-compare / scout-attribute / scout-ingest / scout-govern / scout-verify), or `cub` MCP integration (that's a separate tool surface).
scout-ingest
Use when the user wants to ADOPT existing Kubernetes / GitOps workload structure into ConfigHub after observing the live cluster — the adoption/import verb group of cub-scout. Natural phrasing: "discover workloads in this cluster and propose ConfigHub units", "show me the import proposal before I apply", "import this Argo Application set", "bring my Flux Kustomizations into ConfigHub", "preview what would land in ConfigHub if I imported this repo", "parse my git repo as a ConfigHub import bundle", "import a cluster aggregator", "what would --git-path produce for this repo?". Load whenever intent is adopt / import / ingest / preview / propose / parse-repo / discovery / aggregator / bring-into-confighub / what-would-confighub-see. Do NOT load for: questions about who changed a resource, whether it was edited by hand or drifted (use scout-attribute or investigate-drift); reading an exported `kubectl get -o yaml` dump to answer a question about the cluster (that is not an import); basic live-cluster inventory (use scout-observe), troubleshooting (use scout-diagnose), comparing live state to ConfigHub (use scout-compare), or the actual write to ConfigHub via `cub variant upload` (that is `cub`, not cub-scout — route to cub skills). Important: `cub-scout import apply` IS the mutating write into ConfigHub — this skill teaches the read-only preview path and explicitly refuses to invoke `import apply` itself.
scout-govern
Use when the user wants to consume CONNECTED ConfigHub governance signals from cub-scout — the Govern verb group. Natural phrasing: "show me the ChangeSet history for this unit", "what is the blast radius if I change this unit?", "which clusters in my fleet are outliers?", "show me yesterday's connected summary", "render this view across the fleet", "audit who changed this", "where did the last apply come from?", "list ConfigHub bundles I have", "show me the catalog of past snapshots". Load whenever intent is history / impact / blast-radius / fleet-outliers / summary / view / audit / bundle / catalog / connected-context. Do NOT load for: live cluster comparison (use scout-compare), receipts (use scout-verify), inventory of running pods (use scout-observe), or any mutation via cub. Most of this skill requires `cub auth login` — say so upfront.