@cubis/foundry 0.3.47 → 0.3.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,318 @@
1
+ /**
2
+ * Cubis Foundry MCP Server – declarative tool registry.
3
+ *
4
+ * Defines all built-in tools in a single registry array.
5
+ * Server.ts reads from this registry to auto-register tools,
6
+ * eliminating per-tool import boilerplate.
7
+ *
8
+ * When adding a new tool:
9
+ * 1. Create toolName.ts with name/description/schema/handler exports
10
+ * 2. Add a ToolRegistryEntry here
11
+ * 3. Done — server.ts picks it up automatically.
12
+ */
13
+
14
+ import { z } from "zod";
15
+ import type { VaultManifest } from "../vault/types.js";
16
+ import type { ConfigScope } from "../cbxConfig/types.js";
17
+
18
+ // ─── Core types ─────────────────────────────────────────────
19
+
20
+ export type ToolCategory = "skill" | "postman" | "stitch";
21
+
22
+ export interface ToolRegistryEntry {
23
+ /** Tool name exposed to MCP clients. */
24
+ name: string;
25
+ /** One-line description for MCP discovery. */
26
+ description: string;
27
+ /** Zod schema (the `.shape` is extracted at registration time). */
28
+ schema: z.ZodObject<z.ZodRawShape>;
29
+ /** Tool category for grouping and documentation. */
30
+ category: ToolCategory;
31
+ /**
32
+ * Handler factory. Receives shared runtime context and returns the
33
+ * concrete async handler that server.tool() expects.
34
+ */
35
+ createHandler: (
36
+ ctx: ToolRuntimeContext,
37
+ ) => (args: unknown) => Promise<unknown>;
38
+ }
39
+
40
+ export interface ToolRuntimeContext {
41
+ manifest: VaultManifest;
42
+ charsPerToken: number;
43
+ summaryMaxLength: number;
44
+ defaultConfigScope: ConfigScope | "auto";
45
+ }
46
+
47
+ // ─── Tool imports ───────────────────────────────────────────
48
+
49
+ import {
50
+ skillListCategoriesName,
51
+ skillListCategoriesDescription,
52
+ skillListCategoriesSchema,
53
+ handleSkillListCategories,
54
+ } from "./skillListCategories.js";
55
+
56
+ import {
57
+ skillBrowseCategoryName,
58
+ skillBrowseCategoryDescription,
59
+ skillBrowseCategorySchema,
60
+ handleSkillBrowseCategory,
61
+ } from "./skillBrowseCategory.js";
62
+
63
+ import {
64
+ skillSearchName,
65
+ skillSearchDescription,
66
+ skillSearchSchema,
67
+ handleSkillSearch,
68
+ } from "./skillSearch.js";
69
+
70
+ import {
71
+ skillGetName,
72
+ skillGetDescription,
73
+ skillGetSchema,
74
+ handleSkillGet,
75
+ } from "./skillGet.js";
76
+
77
+ import {
78
+ skillBudgetReportName,
79
+ skillBudgetReportDescription,
80
+ skillBudgetReportSchema,
81
+ handleSkillBudgetReport,
82
+ } from "./skillBudgetReport.js";
83
+
84
+ import {
85
+ postmanGetModeName,
86
+ postmanGetModeDescription,
87
+ postmanGetModeSchema,
88
+ handlePostmanGetMode,
89
+ } from "./postmanGetMode.js";
90
+
91
+ import {
92
+ postmanSetModeName,
93
+ postmanSetModeDescription,
94
+ postmanSetModeSchema,
95
+ handlePostmanSetMode,
96
+ } from "./postmanSetMode.js";
97
+
98
+ import {
99
+ postmanGetStatusName,
100
+ postmanGetStatusDescription,
101
+ postmanGetStatusSchema,
102
+ handlePostmanGetStatus,
103
+ } from "./postmanGetStatus.js";
104
+
105
+ import {
106
+ stitchGetModeName,
107
+ stitchGetModeDescription,
108
+ stitchGetModeSchema,
109
+ handleStitchGetMode,
110
+ } from "./stitchGetMode.js";
111
+
112
+ import {
113
+ stitchSetProfileName,
114
+ stitchSetProfileDescription,
115
+ stitchSetProfileSchema,
116
+ handleStitchSetProfile,
117
+ } from "./stitchSetProfile.js";
118
+
119
+ import {
120
+ stitchGetStatusName,
121
+ stitchGetStatusDescription,
122
+ stitchGetStatusSchema,
123
+ handleStitchGetStatus,
124
+ } from "./stitchGetStatus.js";
125
+
126
+ // ─── Scope helper ───────────────────────────────────────────
127
+
128
+ function withDefaultScope(
129
+ args: unknown,
130
+ defaultScope: ConfigScope | "auto",
131
+ ): Record<string, unknown> {
132
+ const safeArgs =
133
+ args && typeof args === "object" ? (args as Record<string, unknown>) : {};
134
+ return {
135
+ ...safeArgs,
136
+ scope: typeof safeArgs.scope === "string" ? safeArgs.scope : defaultScope,
137
+ };
138
+ }
139
+
140
+ // ─── Registry ───────────────────────────────────────────────
141
+
142
+ export const TOOL_REGISTRY: readonly ToolRegistryEntry[] = [
143
+ // ── Skill vault tools ─────────────────────────────────────
144
+ {
145
+ name: skillListCategoriesName,
146
+ description: skillListCategoriesDescription,
147
+ schema: skillListCategoriesSchema,
148
+ category: "skill",
149
+ createHandler: (ctx) => async () =>
150
+ handleSkillListCategories(ctx.manifest, ctx.charsPerToken),
151
+ },
152
+ {
153
+ name: skillBrowseCategoryName,
154
+ description: skillBrowseCategoryDescription,
155
+ schema: skillBrowseCategorySchema,
156
+ category: "skill",
157
+ createHandler: (ctx) => async (args) =>
158
+ handleSkillBrowseCategory(
159
+ args as z.infer<typeof skillBrowseCategorySchema>,
160
+ ctx.manifest,
161
+ ctx.summaryMaxLength,
162
+ ctx.charsPerToken,
163
+ ),
164
+ },
165
+ {
166
+ name: skillSearchName,
167
+ description: skillSearchDescription,
168
+ schema: skillSearchSchema,
169
+ category: "skill",
170
+ createHandler: (ctx) => async (args) =>
171
+ handleSkillSearch(
172
+ args as z.infer<typeof skillSearchSchema>,
173
+ ctx.manifest,
174
+ ctx.summaryMaxLength,
175
+ ctx.charsPerToken,
176
+ ),
177
+ },
178
+ {
179
+ name: skillGetName,
180
+ description: skillGetDescription,
181
+ schema: skillGetSchema,
182
+ category: "skill",
183
+ createHandler: (ctx) => async (args) =>
184
+ handleSkillGet(
185
+ args as z.infer<typeof skillGetSchema>,
186
+ ctx.manifest,
187
+ ctx.charsPerToken,
188
+ ),
189
+ },
190
+ {
191
+ name: skillBudgetReportName,
192
+ description: skillBudgetReportDescription,
193
+ schema: skillBudgetReportSchema,
194
+ category: "skill",
195
+ createHandler: (ctx) => async (args) =>
196
+ handleSkillBudgetReport(
197
+ args as z.infer<typeof skillBudgetReportSchema>,
198
+ ctx.manifest,
199
+ ctx.charsPerToken,
200
+ ),
201
+ },
202
+
203
+ // ── Postman tools ─────────────────────────────────────────
204
+ {
205
+ name: postmanGetModeName,
206
+ description: postmanGetModeDescription,
207
+ schema: postmanGetModeSchema,
208
+ category: "postman",
209
+ createHandler: (ctx) => async (args) =>
210
+ handlePostmanGetMode(
211
+ withDefaultScope(args, ctx.defaultConfigScope) as z.infer<
212
+ typeof postmanGetModeSchema
213
+ >,
214
+ ),
215
+ },
216
+ {
217
+ name: postmanSetModeName,
218
+ description: postmanSetModeDescription,
219
+ schema: postmanSetModeSchema,
220
+ category: "postman",
221
+ createHandler: (ctx) => async (args) =>
222
+ handlePostmanSetMode(
223
+ withDefaultScope(args, ctx.defaultConfigScope) as z.infer<
224
+ typeof postmanSetModeSchema
225
+ >,
226
+ ),
227
+ },
228
+ {
229
+ name: postmanGetStatusName,
230
+ description: postmanGetStatusDescription,
231
+ schema: postmanGetStatusSchema,
232
+ category: "postman",
233
+ createHandler: (ctx) => async (args) =>
234
+ handlePostmanGetStatus(
235
+ withDefaultScope(args, ctx.defaultConfigScope) as z.infer<
236
+ typeof postmanGetStatusSchema
237
+ >,
238
+ ),
239
+ },
240
+
241
+ // ── Stitch tools ──────────────────────────────────────────
242
+ {
243
+ name: stitchGetModeName,
244
+ description: stitchGetModeDescription,
245
+ schema: stitchGetModeSchema,
246
+ category: "stitch",
247
+ createHandler: (ctx) => async (args) =>
248
+ handleStitchGetMode(
249
+ withDefaultScope(args, ctx.defaultConfigScope) as z.infer<
250
+ typeof stitchGetModeSchema
251
+ >,
252
+ ),
253
+ },
254
+ {
255
+ name: stitchSetProfileName,
256
+ description: stitchSetProfileDescription,
257
+ schema: stitchSetProfileSchema,
258
+ category: "stitch",
259
+ createHandler: (ctx) => async (args) =>
260
+ handleStitchSetProfile(
261
+ withDefaultScope(args, ctx.defaultConfigScope) as z.infer<
262
+ typeof stitchSetProfileSchema
263
+ >,
264
+ ),
265
+ },
266
+ {
267
+ name: stitchGetStatusName,
268
+ description: stitchGetStatusDescription,
269
+ schema: stitchGetStatusSchema,
270
+ category: "stitch",
271
+ createHandler: (ctx) => async (args) =>
272
+ handleStitchGetStatus(
273
+ withDefaultScope(args, ctx.defaultConfigScope) as z.infer<
274
+ typeof stitchGetStatusSchema
275
+ >,
276
+ ),
277
+ },
278
+ ];
279
+
280
+ // ─── Helpers ────────────────────────────────────────────────
281
+
282
+ /** Get tools filtered by category. */
283
+ export function getToolsByCategory(
284
+ category: ToolCategory,
285
+ ): ToolRegistryEntry[] {
286
+ return TOOL_REGISTRY.filter((t) => t.category === category);
287
+ }
288
+
289
+ /** Get all registered tool names. */
290
+ export function getRegisteredToolNames(): string[] {
291
+ return TOOL_REGISTRY.map((t) => t.name);
292
+ }
293
+
294
+ /** Build a summary of the registry for documentation/rule-file generation. */
295
+ export function buildRegistrySummary(): {
296
+ categories: Record<
297
+ string,
298
+ { tools: Array<{ name: string; description: string }> }
299
+ >;
300
+ totalTools: number;
301
+ } {
302
+ const categories: Record<
303
+ string,
304
+ { tools: Array<{ name: string; description: string }> }
305
+ > = {};
306
+
307
+ for (const tool of TOOL_REGISTRY) {
308
+ if (!categories[tool.category]) {
309
+ categories[tool.category] = { tools: [] };
310
+ }
311
+ categories[tool.category].tools.push({
312
+ name: tool.name,
313
+ description: tool.description,
314
+ });
315
+ }
316
+
317
+ return { categories, totalTools: TOOL_REGISTRY.length };
318
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubis/foundry",
3
- "version": "0.3.47",
3
+ "version": "0.3.48",
4
4
  "description": "Cubis Foundry CLI for workflow-first AI agent environments",
5
5
  "type": "module",
6
6
  "bin": {
@@ -36,6 +36,22 @@
36
36
  "generate:platform-assets": "node scripts/generate-platform-assets.mjs",
37
37
  "sync:skill-mirrors": "node scripts/sync-skill-mirrors.mjs",
38
38
  "generate:skills-index": "node scripts/generate-skills-index.mjs",
39
+ "generate:mcp-manifest": "node scripts/generate-mcp-manifest.mjs",
40
+ "generate:mcp-rules-block": "node scripts/generate-mcp-rules-block.mjs",
41
+ "inject:mcp-rules:codex": "node scripts/generate-mcp-rules-block.mjs --inject workflows/workflows/agent-environment-setup/platforms/codex/rules/AGENTS.md",
42
+ "inject:mcp-rules:antigravity": "node scripts/generate-mcp-rules-block.mjs --inject workflows/workflows/agent-environment-setup/platforms/antigravity/rules/GEMINI.md",
43
+ "inject:mcp-rules:copilot-agents": "node scripts/generate-mcp-rules-block.mjs --inject workflows/workflows/agent-environment-setup/platforms/copilot/rules/AGENTS.md",
44
+ "inject:mcp-rules:copilot": "node scripts/generate-mcp-rules-block.mjs --inject workflows/workflows/agent-environment-setup/platforms/copilot/rules/copilot-instructions.md",
45
+ "inject:mcp-rules:all": "npm run inject:mcp-rules:codex && npm run inject:mcp-rules:antigravity && npm run inject:mcp-rules:copilot-agents && npm run inject:mcp-rules:copilot",
46
+ "check:mcp-rules:codex": "node scripts/generate-mcp-rules-block.mjs --check workflows/workflows/agent-environment-setup/platforms/codex/rules/AGENTS.md",
47
+ "check:mcp-rules:antigravity": "node scripts/generate-mcp-rules-block.mjs --check workflows/workflows/agent-environment-setup/platforms/antigravity/rules/GEMINI.md",
48
+ "check:mcp-rules:copilot-agents": "node scripts/generate-mcp-rules-block.mjs --check workflows/workflows/agent-environment-setup/platforms/copilot/rules/AGENTS.md",
49
+ "check:mcp-rules:copilot": "node scripts/generate-mcp-rules-block.mjs --check workflows/workflows/agent-environment-setup/platforms/copilot/rules/copilot-instructions.md",
50
+ "check:mcp-rules:all": "npm run check:mcp-rules:codex && npm run check:mcp-rules:antigravity && npm run check:mcp-rules:copilot-agents && npm run check:mcp-rules:copilot",
51
+ "generate:all": "npm run generate:skills-index && npm run generate:mcp-manifest && npm run inject:mcp-rules:all",
52
+ "validate:mcp-skills": "node scripts/validate-mcp-skills.mjs",
53
+ "validate:mcp-skills:strict": "node scripts/validate-mcp-skills.mjs --strict",
54
+ "validate:mcp-manifest": "node scripts/generate-mcp-manifest.mjs --check",
39
55
  "generate:powers": "node \"workflows/scripts/generate-powers.mjs\"",
40
56
  "generate:powers:force": "node \"workflows/scripts/generate-powers.mjs\" --force",
41
57
  "generate:powers:from-skills": "node \"workflows/scripts/generate-powers.mjs\" --from-skills",
@@ -19,9 +19,10 @@ This file defines mandatory behavior for Antigravity projects installed via `cbx
19
19
  Before executing workflows, agents, or code edits, publish a short `Decision Log` that is visible to the user:
20
20
 
21
21
  1. Rule file(s) read at startup (at minimum `.agent/rules/GEMINI.md`, plus any additional rule files loaded).
22
- 2. Workflow decision (`/workflow` or direct mode) and why it was chosen.
23
- 3. Agent routing decision (`@agent` or direct mode) and why it was chosen.
24
- 4. Skill loading decision (skill names loaded) and why they were chosen.
22
+ 2. MCP status: confirm Foundry MCP server (`cbx-mcp`) is reachable; if unavailable, declare "MCP offline — fallback mode" and continue without blocking.
23
+ 3. Workflow decision (`/workflow` or direct mode) and why it was chosen.
24
+ 4. Agent routing decision (`@agent` or direct mode) and why it was chosen.
25
+ 5. Skill loading decision: skill IDs selected, how they were discovered, and why.
25
26
 
26
27
  If routing changes during the task, publish a `Decision Update` before continuing.
27
28
  Keep this user-visible summary concise and factual; do not expose private chain-of-thought.
@@ -32,6 +33,7 @@ Keep this user-visible summary concise and factual; do not expose private chain-
32
33
  2. Otherwise choose the best workflow by intent from `.agent/workflows` and use matching `.gemini/commands/*.toml` when available.
33
34
  3. For cross-domain tasks, use orchestrated delegation with `@orchestrator`.
34
35
  4. Keep one primary workflow; use others only as supporting references.
36
+ 5. Before executing any workflow, check if a matching skill exists via `skill_search`; load with `skill_get` to prime context before the workflow runs (→ §5 MCP Skill Engine).
35
37
 
36
38
  ## 3) Request Classifier
37
39
 
@@ -66,52 +68,81 @@ Use the best specialist first:
66
68
  - Debugging/performance: `@debugger`, `@performance-optimizer`
67
69
  - Cross-domain orchestration: `@orchestrator`
68
70
 
69
- ## 5) Skill Loading Policy
71
+ ### MCP Skill Priming (Required Before Delegation)
70
72
 
71
- ## MCP-first Skill Discovery Order (Required)
73
+ Before handing off to any specialist agent, prime context with the relevant domain skill (→ §5 MCP Skill Engine):
72
74
 
73
- 1. Use `skill_search` first to narrow candidate skills.
74
- 2. Use `skill_browse_category` second to inspect category-level candidates.
75
- 3. Use `skill_get` only for final selected skills that must be loaded.
76
- 4. Keep pointer-first flow; avoid loading full skill text prematurely.
75
+ 1. Run `skill_search <domain>` to find the best matching skill.
76
+ 2. If a strong match exists, load it with `skill_get <id>` before delegating.
77
+ 3. Include the loaded skill ID in the Decision Log for the routing decision.
77
78
 
78
- ## Skill Log Completion Block (Required)
79
+ This ensures the specialist starts with accurate domain knowledge, not just role intent.
79
80
 
80
- After finishing skill selection/loading, publish:
81
+ ## 5) MCP Skill Engine
81
82
 
82
- - `selected_skills`: skill IDs selected for the task
83
- - `loaded_skills`: skill IDs loaded via `skill_get`
84
- - `skipped_skills`: considered but not loaded
83
+ The Foundry MCP server is the primary knowledge layer. Use tools decisively — discover first, load only when committed.
85
84
 
86
- ## Context Budget Block (Required, Estimated)
85
+ ### Tool Namespace Reference
87
86
 
88
- Immediately after the Skill Log block, publish estimated budget fields:
87
+ | Prefix | Tools | When to use |
88
+ | ----------- | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
89
+ | `skill_*` | `skill_list_categories`, `skill_search`, `skill_browse_category`, `skill_get`, `skill_budget_report` | Domain expertise for any implementation, debug, or review task |
90
+ | `postman_*` | `postman_get_mode`, `postman_set_mode`, `postman_get_status` | API testing or Postman configuration tasks |
91
+ | `stitch_*` | `stitch_get_mode`, `stitch_set_profile`, `stitch_get_status` | Stitch data pipeline tasks |
89
92
 
90
- - `full_catalog_est_tokens`
91
- - `loaded_est_tokens`
92
- - `estimated_savings_tokens`
93
- - `estimated_savings_percent`
93
+ ### Discovery Flow (Mandatory Order)
94
94
 
95
- Mark all context/token values as deterministic estimates (not provider metering).
95
+ Stop at the earliest step that gives enough signal. Do not jump ahead.
96
96
 
97
- ### Smart Skill Selection (Adaptive)
97
+ 1. `skill_list_categories` run once per session if domain is unknown; see what exists
98
+ 2. `skill_search <keyword>` — fast keyword match across all skills; always try this first
99
+ 3. `skill_browse_category <category>` — explore if search is too broad or returns 0 results
100
+ 4. `skill_get <id>` — load full skill content; only when committed to using it
101
+ 5. `skill_budget_report` — verify token cost after loading; triggers the compact ctx stamp
98
102
 
99
- Use an adaptive load policy to control context size:
103
+ **Hard rules:**
100
104
 
101
- 1. Q&A/explanations: do not load skills unless the user explicitly asks for one.
102
- 2. Implementation/debug/review: load at most 1 primary skill and 1 supporting skill.
103
- 3. Cross-domain orchestration: use additional skills only when domains clearly differ.
104
- 4. Explicit skill mention by user always takes precedence.
105
+ - Never call `skill_get` without a prior `skill_search` or `skill_browse_category`
106
+ - Never call `skill_get` with a workflow ID `workflow-*` are routes, not skills; keep workflow mentions in the Decision Log
107
+ - Never reload a skill already loaded this session — reuse content already in context
108
+ - If `skill_search` returns 0 results, try `skill_browse_category`, then fall back to built-in knowledge
105
109
 
106
- ### General Loading Rules
110
+ ### Adaptive Load Policy
107
111
 
108
- 1. Load only skills needed for the active request.
109
- 2. Prefer progressive disclosure: start from `SKILL.md`, then specific sections.
110
- 3. Keep context lean; avoid loading unrelated skill documents.
111
- 4. If a mapped skill is missing, continue with best fallback and state it.
112
- 5. Keep user-visible decision logs concise: selected skill(s) and one-line rationale.
112
+ | Request type | Skills to load via `skill_get` |
113
+ | ---------------------------------------------- | --------------------------------------------------------------- |
114
+ | Q&A / explanation | None — answer from knowledge; load only if user explicitly asks |
115
+ | Single-domain implementation, debug, or review | 1 primary + 1 supporting (max) |
116
+ | Multi-domain / orchestration | 1 per distinct domain, hard cap at 3 |
117
+ | User explicitly names a skill | Always load it — overrides all caps |
113
118
 
114
- After the skill log is complete, append the Context Budget block in the same response/update.
119
+ ### Graceful Degradation
120
+
121
+ If MCP tools are unavailable (server down, timeout, tool not listed):
122
+
123
+ 1. Announce briefly: "MCP unavailable — continuing with built-in knowledge."
124
+ 2. Proceed using codebase context and expertise; do not block on MCP.
125
+ 3. Never fabricate or hallucinate skill content.
126
+ 4. Retry once on transient network errors; accept failure after the retry.
127
+
128
+ ### Skill Log (Required After Any `skill_get` Call)
129
+
130
+ Append one compact inline line — no separate structured block:
131
+
132
+ ```
133
+ Skills: loaded=<id> | skipped=<id> (reason)
134
+ ```
135
+
136
+ Follow immediately with the compact ctx stamp (see § Context Budget Tracking).
137
+
138
+ ### Anti-Patterns (Never Do These)
139
+
140
+ - Loading skills speculatively "just in case" they might be useful
141
+ - Calling `skill_get` before running `skill_search` or `skill_browse_category`
142
+ - Using partial or guessed skill IDs in `skill_get`
143
+ - Publishing verbose budget fields (`full_catalog_est_tokens`, `loaded_est_tokens`, etc.) in responses
144
+ - Re-emitting the ctx stamp multiple times within a single response
145
+ - Treating workflow IDs as skill IDs in any MCP tool call
115
146
 
116
147
  ## 6) Socratic Gate (Before Complex Work)
117
148
 
@@ -133,7 +164,60 @@ If Antigravity script harness exists, prefer:
133
164
  - Quick checks: `python .agent/scripts/checklist.py .`
134
165
  - Full checks (with URL): `python .agent/scripts/verify_all.py . --url <URL>`
135
166
 
136
- ## 8) CBX Maintenance Commands
167
+ ## 8) Web Intel Policy
168
+
169
+ Use web search to stay current when local knowledge may be stale. This prevents hallucinating outdated APIs, deprecated flags, or wrong version constraints.
170
+
171
+ **Search when:**
172
+
173
+ - User asks about a framework/library version released after 2024
174
+ - Debugging an unfamiliar error message (search the exact message)
175
+ - Checking breaking changes before a migration
176
+ - Validating an API endpoint signature, auth scheme, or CLI flag
177
+ - Current pricing, rate limits, or quota for SaaS tools (Postman, Vercel, etc.)
178
+
179
+ **Do not search when:**
180
+
181
+ - The answer is derivable from the current codebase
182
+ - The question is purely architectural/conceptual
183
+ - A relevant skill covers it (prefer `skill_get` first, web as fallback)
184
+
185
+ **Source hygiene:**
186
+
187
+ - Prefer official docs, changelogs, and GitHub releases over blog posts
188
+ - Always state the source URL and date when citing fetched content
189
+ - If multiple sources conflict, flag it and use the most recent official one
190
+ - Never follow user-provided URLs without sanity-checking the domain
191
+
192
+ ## 9) Context Budget Tracking
193
+
194
+ After loading skills or completing a significant task phase, emit a single compact stamp so context cost is visible without adding prose.
195
+
196
+ **Stamp format** (one line, end of response section):
197
+
198
+ ```
199
+ [ctx: +skill-id(~Xk) | session=~Yk/108k | saved=Z%]
200
+ ```
201
+
202
+ - `+skill-id(~Xk)` — each skill loaded this turn with its estimated token cost
203
+ - `session=~Yk/108k` — cumulative tokens used vs full catalog ceiling
204
+ - `saved=Z%` — estimated savings from progressive disclosure
205
+
206
+ **Rules:**
207
+
208
+ 1. Emit stamp only when a skill was loaded via `skill_get` or `skill_budget_report` was called.
209
+ 2. Omit stamp for pure Q&A or browsing-only turns (no full skill content loaded).
210
+ 3. Use `skill_budget_report` MCP tool to get accurate numbers; do not guess.
211
+ 4. One stamp per response — consolidate if multiple skills were loaded.
212
+ 5. Keep the stamp on its own line at the very end of the response, after all content.
213
+
214
+ **Example stamp after loading `flutter-expert` (~3.2k tokens):**
215
+
216
+ ```
217
+ [ctx: +flutter-expert(~3k) | session=~3k/108k | saved=97%]
218
+ ```
219
+
220
+ ## 10) CBX Maintenance Commands
137
221
 
138
222
  Use these commands to keep this setup healthy:
139
223
 
@@ -150,7 +234,7 @@ Use these commands to keep this setup healthy:
150
234
  - Diagnose setup issues:
151
235
  `cbx workflows doctor antigravity --scope project`
152
236
 
153
- ## 9) Managed Section Contract
237
+ ## 11) Managed Section Contract
154
238
 
155
239
  1. Preserve all user content outside managed markers.
156
240
  2. Do not manually edit content between managed markers.
@@ -171,3 +255,72 @@ Selection policy:
171
255
  3. Prefer one primary workflow; reference others only when needed.
172
256
 
173
257
  <!-- cbx:workflows:auto:end -->
258
+
259
+ <!-- cbx:mcp:auto:start version=1 -->
260
+ ## Cubis Foundry MCP Tool Catalog (auto-managed)
261
+
262
+ The Foundry MCP server provides progressive-disclosure skill discovery and integration management tools.
263
+
264
+ ### Skill Vault
265
+
266
+ - **123** skills across **22** categories
267
+ - Estimated full catalog: ~108,488 tokens
268
+
269
+ Categories:
270
+ - `ai`: 1 skill(s)
271
+ - `api`: 3 skill(s)
272
+ - `architecture`: 3 skill(s)
273
+ - `backend`: 14 skill(s)
274
+ - `data`: 4 skill(s)
275
+ - `design`: 6 skill(s)
276
+ - `devops`: 20 skill(s)
277
+ - `documentation`: 3 skill(s)
278
+ - `frontend`: 9 skill(s)
279
+ - `game-dev`: 1 skill(s)
280
+ - `general`: 26 skill(s)
281
+ - `localization`: 1 skill(s)
282
+ - `marketing`: 2 skill(s)
283
+ - `mobile`: 7 skill(s)
284
+ - `observability`: 1 skill(s)
285
+ - `payments`: 1 skill(s)
286
+ - `performance`: 2 skill(s)
287
+ - `practices`: 5 skill(s)
288
+ - `saas`: 1 skill(s)
289
+ - `security`: 4 skill(s)
290
+ - `testing`: 6 skill(s)
291
+ - `tooling`: 3 skill(s)
292
+
293
+ ### Built-in Tools
294
+
295
+ **Skill Discovery:**
296
+ - `skill_list_categories`: List all skill categories available in the vault. Returns category names and skill counts.
297
+ - `skill_browse_category`: Browse skills within a specific category. Returns skill IDs and short descriptions.
298
+ - `skill_search`: Search skills by keyword. Matches against skill IDs and descriptions.
299
+ - `skill_get`: Get full content of a specific skill by ID. Returns SKILL.md content and referenced files.
300
+ - `skill_budget_report`: Report estimated context/token budget for selected and loaded skills.
301
+
302
+ **Postman Integration:**
303
+ - `postman_get_mode`: Get current Postman MCP mode from cbx_config.
304
+ - `postman_set_mode`: Set Postman MCP mode in cbx_config.
305
+ - `postman_get_status`: Get Postman integration status and active profile.
306
+
307
+ **Stitch Integration:**
308
+ - `stitch_get_mode`: Get Stitch MCP mode from cbx_config.
309
+ - `stitch_set_profile`: Switch active Stitch profile in cbx_config.
310
+ - `stitch_get_status`: Get Stitch integration status and active profile.
311
+
312
+ ### Skill Discovery Flow
313
+
314
+ Use progressive disclosure to minimize context usage:
315
+ 1. `skill_list_categories` → see available categories and counts
316
+ 2. `skill_browse_category` → browse skills in a category with short descriptions
317
+ 3. `skill_search` → search by keyword across all skills
318
+ 4. `skill_get` → load full content of a specific skill (only tool that reads full content)
319
+ 5. `skill_budget_report` → check token usage for selected/loaded skills; use result to emit the § Context Budget Tracking stamp
320
+
321
+ ### Connection
322
+
323
+ - **stdio**: `cbx mcp serve --transport stdio --scope auto`
324
+ - **HTTP**: `cbx mcp serve --transport http --scope auto --port 3100`
325
+
326
+ <!-- cbx:mcp:auto:end -->