capix-mcp 2.1.1 → 2.2.0

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.
Files changed (41) hide show
  1. package/README.md +51 -72
  2. package/dist/prompts.d.ts +6 -1
  3. package/dist/prompts.d.ts.map +1 -1
  4. package/dist/prompts.js +41 -75
  5. package/dist/prompts.js.map +1 -1
  6. package/dist/route-families.d.ts +47 -0
  7. package/dist/route-families.d.ts.map +1 -0
  8. package/dist/route-families.js +96 -0
  9. package/dist/route-families.js.map +1 -0
  10. package/dist/server.d.ts +5 -5
  11. package/dist/server.js +8 -8
  12. package/dist/server.js.map +1 -1
  13. package/dist/tools/define-tool.d.ts +6 -0
  14. package/dist/tools/define-tool.d.ts.map +1 -1
  15. package/dist/tools/define-tool.js +1 -0
  16. package/dist/tools/define-tool.js.map +1 -1
  17. package/dist/tools/factory.d.ts +42 -0
  18. package/dist/tools/factory.d.ts.map +1 -0
  19. package/dist/tools/factory.js +363 -0
  20. package/dist/tools/factory.js.map +1 -0
  21. package/dist/tools/generate.d.ts +108 -0
  22. package/dist/tools/generate.d.ts.map +1 -0
  23. package/dist/tools/generate.js +149 -0
  24. package/dist/tools/generate.js.map +1 -0
  25. package/dist/tools/infra-context.d.ts +15 -11
  26. package/dist/tools/infra-context.d.ts.map +1 -1
  27. package/dist/tools/infra-context.js +43 -92
  28. package/dist/tools/infra-context.js.map +1 -1
  29. package/dist/tools/memes.d.ts +31 -0
  30. package/dist/tools/memes.d.ts.map +1 -0
  31. package/dist/tools/memes.js +175 -0
  32. package/dist/tools/memes.js.map +1 -0
  33. package/dist/tools.d.ts +47 -7
  34. package/dist/tools.d.ts.map +1 -1
  35. package/dist/tools.js +341 -891
  36. package/dist/tools.js.map +1 -1
  37. package/dist/types.d.ts +17 -2
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js +0 -2
  40. package/dist/types.js.map +1 -1
  41. package/package.json +3 -3
package/dist/server.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Capix MCP Server — the McpServer assembly + transport wiring.
3
3
  *
4
- * `createCapixMcpServer(client)` builds an {@link McpServer} with all 64
5
- * tools, the capix:// resources, and the guided prompts registered. Each tool
6
- * registration wires:
4
+ * `createCapixMcpServer(client)` builds an {@link McpServer} with every tool
5
+ * in the registry (TOOL_COUNT), the capix:// resources, and the guided
6
+ * prompts registered. Each tool registration wires:
7
7
  * - inputSchema → the tool's Zod raw shape (validated by the SDK)
8
8
  * - outputSchema → the tool's Zod raw output shape
9
9
  * - annotations → readOnlyHint / destructiveHint / idempotentHint derived
@@ -40,10 +40,10 @@ import { registerPrompts } from "./prompts.js";
40
40
  import { CapixApiError } from "./types.js";
41
41
  /** MCP tool annotations derived from a tool's billing/approval/scope flags. */
42
42
  function annotationsFor(tool) {
43
- const isDestructive = (tool.scope === "lifecycle" && (tool.name === "capix_delete" || tool.name === "capix_cancel")) ||
44
- tool.name === "capix_destroy_task_resources" ||
43
+ const isDestructive = tool.name === "capix_delete" ||
44
+ tool.name === "capix_cancel" ||
45
45
  tool.name === "capix_website_destroy" ||
46
- tool.name === "capix_website_domain_remove";
46
+ tool.name === "capix_agent_destroy";
47
47
  return {
48
48
  readOnlyHint: !tool.billable && !tool.requiresApproval,
49
49
  destructiveHint: isDestructive,
@@ -52,8 +52,8 @@ function annotationsFor(tool) {
52
52
  };
53
53
  }
54
54
  /**
55
- * Build a fully-wired McpServer. All 64 tools, resources, and prompts are
56
- * registered before returning; the caller just attaches a transport.
55
+ * Build a fully-wired McpServer. All registered tools, resources, and prompts
56
+ * are wired before returning; the caller just attaches a transport.
57
57
  */
58
58
  export function createCapixMcpServer(client, opts) {
59
59
  const server = new McpServer({
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;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G,CAAC,GAAG,CACL,IAAI,CAAC,SAAS,CAAC;gBACb,EAAE,EAAE,IAAI;gBACR,OAAO,EAAE,WAAW;gBACpB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,OAAO;gBAChC,KAAK,EAAE,UAAU;gBACjB,aAAa,EAAE,MAAM,CAAC,eAAe,EAAE;aACxC,CAAC,CACH,CAAC;YACF,OAAO;QACT,CAAC;QAED,kEAAkE;QAClE,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED,8EAA8E;AAC9E,2DAA2D;AAC3D,8EAA8E;AAE9E,MAAM,UAAU,cAAc;IAM5B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,gBAAgB,EAAE,CAAC,CAAC,gBAAgB;KACrC,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
@@ -18,6 +18,12 @@ export declare function defineTool<S extends z.ZodRawShape>(opts: {
18
18
  scope: ToolDef["scope"];
19
19
  billable: boolean;
20
20
  requiresApproval: boolean;
21
+ /**
22
+ * Canonical `/api/v1/*` path the handler dispatches to. Required so the
23
+ * registry gate can verify every tool targets a real route family (see
24
+ * ToolDef.routePath).
25
+ */
26
+ routePath: string;
21
27
  inputShape: S;
22
28
  outputShape?: Record<string, z.ZodTypeAny>;
23
29
  handler: (args: {
@@ -1 +1 @@
1
- {"version":3,"file":"define-tool.d.ts","sourceRoot":"","sources":["../../src/tools/define-tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,CAAC,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAC3C,OAAO,EAAE,CACP,IAAI,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAE,EACxC,IAAI,EAAE,QAAQ,KACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC,GAAG,OAAO,CAaV"}
1
+ {"version":3,"file":"define-tool.d.ts","sourceRoot":"","sources":["../../src/tools/define-tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,CAAC,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAC3C,OAAO,EAAE,CACP,IAAI,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAE,EACxC,IAAI,EAAE,QAAQ,KACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC,GAAG,OAAO,CAcV"}
@@ -17,6 +17,7 @@ export function defineTool(opts) {
17
17
  scope: opts.scope,
18
18
  billable: opts.billable,
19
19
  requiresApproval: opts.requiresApproval,
20
+ routePath: opts.routePath,
20
21
  inputShape: opts.inputShape,
21
22
  outputShape: opts.outputShape,
22
23
  // Sound cast: the McpServer validates args against inputShape before
@@ -1 +1 @@
1
- {"version":3,"file":"define-tool.js","sourceRoot":"","sources":["../../src/tools/define-tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAA0B,IAYnD;IACC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,qEAAqE;QACrE,4EAA4E;QAC5E,OAAO,EAAE,IAAI,CAAC,OAA6B;KAC5C,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"define-tool.js","sourceRoot":"","sources":["../../src/tools/define-tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAA0B,IAkBnD;IACC,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,qEAAqE;QACrE,4EAA4E;QAC5E,OAAO,EAAE,IAAI,CAAC,OAA6B;KAC5C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Capix MCP Server — factory tools (14): durable jobs, training runs, and
3
+ * agent deploys. Added in the 2026-07 repair; every tool targets a route
4
+ * family that exists in the control plane (see ../route-families.ts):
5
+ *
6
+ * jobs (6) app/api/v1/jobs/*
7
+ * capix_job_submit POST /api/v1/jobs (billable, idempotent)
8
+ * capix_job_list GET /api/v1/jobs (read-only)
9
+ * capix_job_get GET /api/v1/jobs?id=<jobId> (read-only — there is
10
+ * NO /api/v1/jobs/[id] route; detail is a query param)
11
+ * capix_job_logs GET /api/v1/jobs/:id/logs (read-only, `after` seq cursor)
12
+ * capix_job_cancel POST /api/v1/jobs/:id/cancel (cooperative cancel flag)
13
+ * capix_job_rerun POST /api/v1/jobs/:id/rerun (billable, idempotent)
14
+ *
15
+ * training (4) app/api/v1/training/*
16
+ * capix_training_submit POST /api/v1/training (billable, idempotent)
17
+ * capix_training_list GET /api/v1/training (read-only)
18
+ * capix_training_get GET /api/v1/training/:id (read-only)
19
+ * capix_training_deploy POST /api/v1/training/:id/deploy (handoff deep-link,
20
+ * NOT a completed deployment — see the tool description)
21
+ *
22
+ * agent deploys (4) app/api/v1/agent-deploys/*
23
+ * capix_agent_deploy POST /api/v1/agent-deploys (billable, idempotent)
24
+ * capix_agent_list GET /api/v1/agent-deploys (read-only)
25
+ * capix_agent_get GET /api/v1/agent-deploys/:id (read-only)
26
+ * capix_agent_destroy DELETE /api/v1/agent-deploys/:id (destructive; refund settles)
27
+ *
28
+ * All fourteen are declared with `defineGeneratedTool` (./generate.ts), so the
29
+ * registration and the HTTP dispatch share one spec. Mutation specs inherit
30
+ * the generator's conventions: Idempotency-Key + bound approvalToken on
31
+ * billable/approval POSTs (all three submit routes REQUIRE the Idempotency-Key
32
+ * header upstream), and the client-derived key on DELETEs. The upstream error
33
+ * code style differs per family (jobs/training: CAPIX_*; agent-deploys:
34
+ * snake_case) — both pass through untouched as problem+json.
35
+ *
36
+ * This module shares `defineGeneratedTool` with the aggregate registry in
37
+ * ../tools.ts via ./generate.js (a leaf module), so there is no import cycle.
38
+ */
39
+ import type { ToolDef } from "../types.js";
40
+ export declare const factoryTools: ToolDef[];
41
+ export declare const FACTORY_TOOL_NAMES: string[];
42
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/tools/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA0V3C,eAAO,MAAM,YAAY,EAAE,OAAO,EAIjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAAoC,CAAC"}
@@ -0,0 +1,363 @@
1
+ /**
2
+ * Capix MCP Server — factory tools (14): durable jobs, training runs, and
3
+ * agent deploys. Added in the 2026-07 repair; every tool targets a route
4
+ * family that exists in the control plane (see ../route-families.ts):
5
+ *
6
+ * jobs (6) app/api/v1/jobs/*
7
+ * capix_job_submit POST /api/v1/jobs (billable, idempotent)
8
+ * capix_job_list GET /api/v1/jobs (read-only)
9
+ * capix_job_get GET /api/v1/jobs?id=<jobId> (read-only — there is
10
+ * NO /api/v1/jobs/[id] route; detail is a query param)
11
+ * capix_job_logs GET /api/v1/jobs/:id/logs (read-only, `after` seq cursor)
12
+ * capix_job_cancel POST /api/v1/jobs/:id/cancel (cooperative cancel flag)
13
+ * capix_job_rerun POST /api/v1/jobs/:id/rerun (billable, idempotent)
14
+ *
15
+ * training (4) app/api/v1/training/*
16
+ * capix_training_submit POST /api/v1/training (billable, idempotent)
17
+ * capix_training_list GET /api/v1/training (read-only)
18
+ * capix_training_get GET /api/v1/training/:id (read-only)
19
+ * capix_training_deploy POST /api/v1/training/:id/deploy (handoff deep-link,
20
+ * NOT a completed deployment — see the tool description)
21
+ *
22
+ * agent deploys (4) app/api/v1/agent-deploys/*
23
+ * capix_agent_deploy POST /api/v1/agent-deploys (billable, idempotent)
24
+ * capix_agent_list GET /api/v1/agent-deploys (read-only)
25
+ * capix_agent_get GET /api/v1/agent-deploys/:id (read-only)
26
+ * capix_agent_destroy DELETE /api/v1/agent-deploys/:id (destructive; refund settles)
27
+ *
28
+ * All fourteen are declared with `defineGeneratedTool` (./generate.ts), so the
29
+ * registration and the HTTP dispatch share one spec. Mutation specs inherit
30
+ * the generator's conventions: Idempotency-Key + bound approvalToken on
31
+ * billable/approval POSTs (all three submit routes REQUIRE the Idempotency-Key
32
+ * header upstream), and the client-derived key on DELETEs. The upstream error
33
+ * code style differs per family (jobs/training: CAPIX_*; agent-deploys:
34
+ * snake_case) — both pass through untouched as problem+json.
35
+ *
36
+ * This module shares `defineGeneratedTool` with the aggregate registry in
37
+ * ../tools.ts via ./generate.js (a leaf module), so there is no import cycle.
38
+ */
39
+ import { z } from "zod";
40
+ import { defineGeneratedTool } from "./generate.js";
41
+ import { APPROVAL_ONLY, BILLABLE, READ_ONLY } from "../types.js";
42
+ // ===========================================================================
43
+ // Local Zod fragments (mirror tools.ts — keep in sync)
44
+ // ===========================================================================
45
+ const jobIdShape = z.string().describe("Durable job id (job_…).");
46
+ const trainingIdShape = z.string().describe("Training run id.");
47
+ const agentDeployIdShape = z.string().describe("Agent deployment id.");
48
+ /** DurableJob envelope (CapIX-Backend/lib/serverless-queue.ts). */
49
+ const jobResultShape = {
50
+ job: z.record(z.unknown()).optional().describe("DurableJob: id, accountId, projectId, status (queued|leased|running|succeeded|failed|canceled|dead_letter), " +
51
+ "image, command, tierId, timeoutSeconds, attempt, result, error, createdAt, updatedAt."),
52
+ };
53
+ /** TrainingRunView envelope (CapIX-Backend/lib/training/index.ts). */
54
+ const trainingResultShape = {
55
+ training: z.record(z.unknown()).optional().describe("TrainingRunView: trainingId, status (queued|running|finalizing|artifact_ready|deploy_pending|failed|canceled), " +
56
+ "baseModel, outputName, lora, dataset, tier, estimate, progress, jobId, trainedModel, deployPath, createdAt, updatedAt."),
57
+ };
58
+ /** PublicAgentDeploy envelope (CapIX-Backend/lib/agentDeploys.ts). */
59
+ const agentDeployResultShape = {
60
+ deployment: z.record(z.unknown()).optional().describe("PublicAgentDeploy: id, name, runtime, image, model, tier, durationHours, " +
61
+ "status (queued|provisioning|configuring|ready|failed|destroying|destroyed), agentUrl, price, createdAt, readyAt."),
62
+ };
63
+ // ===========================================================================
64
+ // Jobs (6)
65
+ // ===========================================================================
66
+ const jobTools = [
67
+ defineGeneratedTool({
68
+ name: "capix_job_submit",
69
+ description: "Submit a durable batch job (container image + command) to the serverless queue. " +
70
+ "Idempotent — the control plane derives the job id from the Idempotency-Key, so " +
71
+ "replays return the same job. Billable; requires approval.",
72
+ scope: "lifecycle",
73
+ ...BILLABLE,
74
+ method: "POST",
75
+ path: "/api/v1/jobs",
76
+ input: {
77
+ image: z.string().min(1).describe("Container image to run (required by the route)."),
78
+ command: z.array(z.string()).min(1).describe("Command argv (required, non-empty)."),
79
+ tierId: z.string().optional().describe("Optional compute tier id."),
80
+ timeoutSeconds: z.number().int().positive().optional(),
81
+ projectId: z.string().optional().describe("Project id; must match the caller's membership."),
82
+ },
83
+ outputShape: jobResultShape,
84
+ }),
85
+ defineGeneratedTool({
86
+ name: "capix_job_list",
87
+ description: "List the account's durable jobs. Read-only.",
88
+ scope: "lifecycle",
89
+ ...READ_ONLY,
90
+ method: "GET",
91
+ path: "/api/v1/jobs",
92
+ input: {},
93
+ outputShape: {
94
+ jobs: z.array(z.record(z.unknown())).optional().describe("DurableJob array (unpaginated upstream)."),
95
+ },
96
+ }),
97
+ defineGeneratedTool({
98
+ name: "capix_job_get",
99
+ description: "Get a single durable job by id. Read-only. Dispatches to GET /api/v1/jobs?id=<jobId> — " +
100
+ "the control plane has no /api/v1/jobs/[id] route; detail is a query parameter.",
101
+ scope: "lifecycle",
102
+ ...READ_ONLY,
103
+ method: "GET",
104
+ path: "/api/v1/jobs",
105
+ input: {
106
+ id: jobIdShape,
107
+ },
108
+ outputShape: jobResultShape,
109
+ }),
110
+ defineGeneratedTool({
111
+ name: "capix_job_logs",
112
+ description: "Fetch job log chunks after a sequence cursor. Read-only. Re-poll with " +
113
+ "`after` set to the returned `nextAfter` to tail.",
114
+ scope: "lifecycle",
115
+ ...READ_ONLY,
116
+ method: "GET",
117
+ path: "/api/v1/jobs/:id/logs",
118
+ input: {
119
+ id: jobIdShape,
120
+ after: z.number().int().min(0).default(0).describe("Seq cursor — only chunks with seq > after are returned."),
121
+ limit: z.number().int().min(1).max(5000).default(1000).describe("Max chunks (upstream cap 5000)."),
122
+ },
123
+ outputShape: {
124
+ job: z.record(z.unknown()).optional().describe("Job subset: id, status, result, error."),
125
+ logs: z.array(z.record(z.unknown())).optional().describe("JobLogChunk: seq, stream (stdout|stderr|system), chunk, createdAt."),
126
+ nextAfter: z.number().int().optional().describe("Cursor for the next poll."),
127
+ },
128
+ }),
129
+ defineGeneratedTool({
130
+ name: "capix_job_cancel",
131
+ description: "Request cooperative cancellation of a queued/running job (sets the cancel flag; " +
132
+ "not immediate termination). 409 if the job is already terminal. Requires approval.",
133
+ scope: "lifecycle",
134
+ ...APPROVAL_ONLY,
135
+ method: "POST",
136
+ path: "/api/v1/jobs/:id/cancel",
137
+ input: {
138
+ id: jobIdShape,
139
+ },
140
+ outputShape: {
141
+ ok: z.boolean().optional(),
142
+ jobId: jobIdShape.optional(),
143
+ status: z.string().optional().describe("cancel_requested or the current status."),
144
+ },
145
+ }),
146
+ defineGeneratedTool({
147
+ name: "capix_job_rerun",
148
+ description: "Re-enqueue a terminal job with the same image/command/tier/timeout. The parent must " +
149
+ "be in a terminal state (409 otherwise). Idempotent. Billable; requires approval.",
150
+ scope: "lifecycle",
151
+ ...BILLABLE,
152
+ method: "POST",
153
+ path: "/api/v1/jobs/:id/rerun",
154
+ input: {
155
+ id: jobIdShape.describe("Terminal parent job id."),
156
+ },
157
+ outputShape: {
158
+ ...jobResultShape,
159
+ rerunOf: z.string().optional().describe("Parent job id."),
160
+ },
161
+ }),
162
+ ];
163
+ // ===========================================================================
164
+ // Training (4)
165
+ // ===========================================================================
166
+ /** Base models accepted by POST /api/v1/training (allowlist upstream). */
167
+ const TRAINING_BASE_MODELS = [
168
+ "llama-3.2-1b-instruct",
169
+ "llama-3.2-3b-instruct",
170
+ "qwen2.5-3b-instruct",
171
+ "qwen2.5-7b-instruct",
172
+ "mistral-7b-instruct-v0.3",
173
+ "llama-3.1-8b-instruct",
174
+ ];
175
+ const trainingTools = [
176
+ defineGeneratedTool({
177
+ name: "capix_training_submit",
178
+ description: "Submit a LoRA fine-tuning run against an allow-listed base model. Takes a ledger " +
179
+ "hold for the high cost estimate. Idempotent. Billable; requires approval.",
180
+ scope: "lifecycle",
181
+ ...BILLABLE,
182
+ method: "POST",
183
+ path: "/api/v1/training",
184
+ input: {
185
+ baseModel: z.enum(TRAINING_BASE_MODELS).describe("Allow-listed base model."),
186
+ outputName: z
187
+ .string()
188
+ .max(64)
189
+ .regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/, "outputName must start alphanumeric; letters, digits, . _ - only")
190
+ .describe("Name for the trained adapter (≤64 chars)."),
191
+ dataset: z
192
+ .union([
193
+ z.object({ url: z.string().regex(/^https:\/\/\S+$/i, "dataset.url must be an https URL") }),
194
+ z.object({
195
+ inlineJsonl: z
196
+ .string()
197
+ .max(5 * 1024 * 1024)
198
+ .describe("JSONL chat samples ({messages:[…]} per line; 50–10,000 valid samples, ≤5 MiB)."),
199
+ }),
200
+ ])
201
+ .describe("Exactly one of { url } or { inlineJsonl }."),
202
+ method: z.literal("lora").optional().describe("Only \"lora\" is accepted upstream."),
203
+ lora: z
204
+ .object({
205
+ rank: z.number().int().min(4).max(64).default(16),
206
+ alpha: z.number().int().min(8).max(128).default(32),
207
+ epochs: z.number().int().min(1).max(10).default(3),
208
+ learningRate: z.number().min(1e-6).max(1e-3).default(2e-4),
209
+ })
210
+ .optional()
211
+ .describe("LoRA hyperparameters (upstream defaults shown)."),
212
+ projectId: z.string().optional(),
213
+ },
214
+ outputShape: trainingResultShape,
215
+ }),
216
+ defineGeneratedTool({
217
+ name: "capix_training_list",
218
+ description: "List the account's training runs (lazily reconciled against jobs). Read-only.",
219
+ scope: "lifecycle",
220
+ ...READ_ONLY,
221
+ method: "GET",
222
+ path: "/api/v1/training",
223
+ input: {},
224
+ outputShape: {
225
+ trainings: z.array(z.record(z.unknown())).optional(),
226
+ },
227
+ }),
228
+ defineGeneratedTool({
229
+ name: "capix_training_get",
230
+ description: "Get a training run by id (the completion/polling path). Read-only.",
231
+ scope: "lifecycle",
232
+ ...READ_ONLY,
233
+ method: "GET",
234
+ path: "/api/v1/training/:id",
235
+ input: {
236
+ id: trainingIdShape,
237
+ },
238
+ outputShape: trainingResultShape,
239
+ }),
240
+ defineGeneratedTool({
241
+ name: "capix_training_deploy",
242
+ description: "Deploy a finished training run. IMPORTANT: the control plane returns a handoff " +
243
+ "deep-link ({ deploy: { status: \"handoff\", path } }) into the private-model deploy " +
244
+ "flow — it does NOT create a deployment by itself. Only runs in artifact_ready " +
245
+ "(409 otherwise); replaying while deploy_pending returns the same handoff. " +
246
+ "Idempotent; requires approval.",
247
+ scope: "lifecycle",
248
+ ...APPROVAL_ONLY,
249
+ method: "POST",
250
+ path: "/api/v1/training/:id/deploy",
251
+ input: {
252
+ id: trainingIdShape.describe("Training run id in artifact_ready status."),
253
+ },
254
+ outputShape: {
255
+ ...trainingResultShape,
256
+ deploy: z
257
+ .object({
258
+ status: z.string().optional().describe("\"handoff\" — follow `path` to complete the deploy."),
259
+ path: z.string().optional().describe("Deep-link into the private-model deploy flow."),
260
+ })
261
+ .optional(),
262
+ },
263
+ }),
264
+ ];
265
+ // ===========================================================================
266
+ // Agent deploys (4)
267
+ // ===========================================================================
268
+ const agentDeployTools = [
269
+ defineGeneratedTool({
270
+ name: "capix_agent_deploy",
271
+ description: "Deploy a hosted agent runtime (openclaw / hermes / custom image) on a dedicated tier " +
272
+ "for a prepaid duration. Mints a project API key (shown ONCE in mintedKey — idempotent " +
273
+ "replays return it redacted). Billable; requires approval.",
274
+ scope: "lifecycle",
275
+ ...BILLABLE,
276
+ method: "POST",
277
+ path: "/api/v1/agent-deploys",
278
+ input: {
279
+ runtime: z.enum(["openclaw", "hermes", "custom"]).describe("Agent runtime."),
280
+ customImage: z.string().optional().describe("Container image — required iff runtime is \"custom\"."),
281
+ model: z
282
+ .string()
283
+ .optional()
284
+ .describe("Model id from capix_model_list, \"auto\" (default), or private/<deploymentId> for an owned ready private endpoint."),
285
+ keyMode: z
286
+ .enum(["mint", "provided"])
287
+ .optional()
288
+ .describe("\"mint\" (default) creates a fresh key; \"provided\" requires providedKey."),
289
+ providedKey: z.string().optional().describe("Existing cpxk_ project key — required iff keyMode is \"provided\"."),
290
+ tier: z.enum(["nano", "micro", "standard", "pro"]).describe("Dedicated tier (enterprise excluded upstream)."),
291
+ name: z.string().min(1).max(48).describe("Deployment name (sanitized to [a-z0-9-] upstream)."),
292
+ durationHours: z
293
+ .number()
294
+ .positive()
295
+ .max(168)
296
+ .default(1)
297
+ .describe("Prepaid duration in hours (default 1, max 168 = 7 days)."),
298
+ projectId: z.string().optional(),
299
+ },
300
+ outputShape: {
301
+ ...agentDeployResultShape,
302
+ mintedKey: z
303
+ .record(z.unknown())
304
+ .nullable()
305
+ .optional()
306
+ .describe("{ apiKey, keyId, prefix } — shown once; null/redacted on idempotent replay."),
307
+ gatewayToken: z.string().optional().describe("Gateway token (redacted on replay)."),
308
+ keyWarning: z.string().optional(),
309
+ },
310
+ }),
311
+ defineGeneratedTool({
312
+ name: "capix_agent_list",
313
+ description: "List the account's agent deployments. Read-only.",
314
+ scope: "lifecycle",
315
+ ...READ_ONLY,
316
+ method: "GET",
317
+ path: "/api/v1/agent-deploys",
318
+ input: {
319
+ projectId: z.string().optional(),
320
+ },
321
+ outputShape: {
322
+ data: z.array(z.record(z.unknown())).optional().describe("PublicAgentDeploy array (upstream key is `data`)."),
323
+ },
324
+ }),
325
+ defineGeneratedTool({
326
+ name: "capix_agent_get",
327
+ description: "Get an agent deployment by id; lazily advances the provisioning state machine. Read-only.",
328
+ scope: "lifecycle",
329
+ ...READ_ONLY,
330
+ method: "GET",
331
+ path: "/api/v1/agent-deploys/:id",
332
+ input: {
333
+ id: agentDeployIdShape,
334
+ },
335
+ outputShape: {
336
+ ...agentDeployResultShape,
337
+ logsTail: z.unknown().nullable().optional().describe("Recent agent logs when available."),
338
+ },
339
+ }),
340
+ defineGeneratedTool({
341
+ name: "capix_agent_destroy",
342
+ description: "Destroy an agent deployment: tears down the VM, revokes the minted key, and releases " +
343
+ "the uncaptured ledger hold (refund settles money). Destructive; requires approval.",
344
+ scope: "lifecycle",
345
+ ...BILLABLE,
346
+ method: "DELETE",
347
+ path: "/api/v1/agent-deploys/:id",
348
+ input: {
349
+ id: agentDeployIdShape,
350
+ },
351
+ outputShape: agentDeployResultShape,
352
+ }),
353
+ ];
354
+ // ===========================================================================
355
+ // Aggregate export
356
+ // ===========================================================================
357
+ export const factoryTools = [
358
+ ...jobTools,
359
+ ...trainingTools,
360
+ ...agentDeployTools,
361
+ ];
362
+ export const FACTORY_TOOL_NAMES = factoryTools.map((t) => t.name);
363
+ //# sourceMappingURL=factory.js.map
@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;KACF,CAAC;IACF,mBAAmB,CAAC;QAClB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,2FAA2F;QAC7F,KAAK,EAAE,WAAW;QAClB,GAAG,SAAS;QACZ,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,2BAA2B;QACjC,KAAK,EAAE;YACL,EAAE,EAAE,kBAAkB;SACvB;QACD,WAAW,EAAE;YACX,GAAG,sBAAsB;YACzB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;SAC1F;KACF,CAAC;IACF,mBAAmB,CAAC;QAClB,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,uFAAuF;YACvF,oFAAoF;QACtF,KAAK,EAAE,WAAW;QAClB,GAAG,QAAQ;QACX,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,2BAA2B;QACjC,KAAK,EAAE;YACL,EAAE,EAAE,kBAAkB;SACvB;QACD,WAAW,EAAE,sBAAsB;KACpC,CAAC;CACH,CAAC;AAEF,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,GAAG,QAAQ;IACX,GAAG,aAAa;IAChB,GAAG,gBAAgB;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAa,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Capix MCP Server — declarative tool generator.
3
+ *
4
+ * The generation pattern adapted here — declare method + path + input schema
5
+ * ONCE in a tool spec, then derive both the MCP tool registration and the
6
+ * HTTP dispatch from that single declaration — follows the route-registry
7
+ * approach of OpenShip (https://github.com/oblien/openship),
8
+ * apps/api/src/modules/mcp/ (mcp-tools.ts / mcp-dispatch.ts).
9
+ * Copyright the OpenShip contributors, licensed under the Apache License 2.0.
10
+ * See the NOTICE file at the repository root. Only the pattern is adapted;
11
+ * this implementation is original and specific to the Capix control plane.
12
+ *
13
+ * Why this exists: hand-written tools drift when the control-plane API
14
+ * changes. A generated tool keeps the endpoint declaration (method, canonical
15
+ * `/api/v1/*` path, typed Zod input) co-located with the registration, so the
16
+ * MCP surface and the HTTP call can never disagree.
17
+ *
18
+ * The generator enforces the repo's existing control-plane conventions:
19
+ *
20
+ * - problem passthrough — the handler delegates to the shared CapixClient,
21
+ * which parses non-2xx responses as problem+json (RFC 9457, which
22
+ * obsoletes RFC 7807) and throws CapixApiError; the generator never
23
+ * catches or rewrites it, so problem details reach the server wrapper
24
+ * (server.ts errorResult) untouched.
25
+ * - idempotency — mutation specs (billable / requiresApproval POST or
26
+ * DELETE) route through the client's existing Idempotency-Key helper
27
+ * (client.post(..., { idempotent: true }) / client.delete), reusing the
28
+ * path+body-hash key derivation in client.ts rather than re-inventing it.
29
+ * - typed inputs — inputs are declared as a Zod raw shape, validated
30
+ * by the McpServer before dispatch, exactly like defineTool.
31
+ * - approval gate — billable / requiresApproval specs throw the same
32
+ * `approval_required` (402) error shape as callBillable in tools.ts when
33
+ * no approvalToken is bound.
34
+ * - payload truncation — an optional `transform` post-processes successful
35
+ * responses so oversized inline artifacts (SVG, base64) are reduced to a
36
+ * pointer (share URL / id) before they reach the agent's context.
37
+ */
38
+ import { z } from "zod";
39
+ import type { ToolDef, ToolScope } from "../types.js";
40
+ /** HTTP methods the generator knows how to dispatch. */
41
+ export type GeneratedMethod = "GET" | "POST" | "DELETE";
42
+ /**
43
+ * Declarative specification for a generated tool. One spec produces both the
44
+ * MCP registration (name/description/inputShape/flags) and the HTTP call.
45
+ */
46
+ export interface GeneratedToolSpec<S extends z.ZodRawShape> {
47
+ name: string;
48
+ description: string;
49
+ scope: ToolScope;
50
+ /** Whether the tool performs a stateful mutation that may move money. */
51
+ billable: boolean;
52
+ /** Whether the caller MUST supply an approvalToken before dispatch. */
53
+ requiresApproval: boolean;
54
+ /** HTTP method of the canonical control-plane route. */
55
+ method: GeneratedMethod;
56
+ /**
57
+ * Canonical `/api/v1/*` path. May contain `:param` segments; each param
58
+ * MUST be declared in `input` and is URL-encoded into the path at call
59
+ * time. Missing-param declarations are rejected when the spec is defined,
60
+ * not when the tool is called.
61
+ */
62
+ path: string;
63
+ /**
64
+ * Zod raw shape for the whole tool input: path params, query params, and
65
+ * body fields together. The generator splits validated args by role.
66
+ */
67
+ input: S;
68
+ /**
69
+ * Args sent as query-string params. Default for GET: every non-path arg.
70
+ * Values that are undefined are passed through and dropped by the client's
71
+ * URL builder, matching the hand-written handlers.
72
+ */
73
+ query?: readonly (keyof S & string)[];
74
+ /**
75
+ * Args sent as the JSON request body. Default for POST: every non-path
76
+ * arg. Undefined fields are dropped (JSON.stringify would drop them on the
77
+ * wire anyway), and when no field has a value the request is sent WITHOUT
78
+ * a body — matching the hand-written `client.post(path, args)` and
79
+ * `args.reason ? { reason } : undefined` conventions.
80
+ */
81
+ body?: readonly (keyof S & string)[];
82
+ /**
83
+ * Whether mutations send the client's deterministic Idempotency-Key.
84
+ * Default: true for non-GET specs that are billable or require approval
85
+ * (i.e. real mutations), false for read-only POSTs such as quotes/plans.
86
+ */
87
+ idempotent?: boolean;
88
+ /** Optional Zod raw shape describing the structured output envelope. */
89
+ outputShape?: Record<string, z.ZodTypeAny>;
90
+ /**
91
+ * Optional post-processor for the upstream response, applied before it
92
+ * becomes structured content. Use it to truncate oversized inline payloads
93
+ * (SVG markup, base64 rasters) down to a pointer (share URL / id) so the
94
+ * artifact itself never floods the agent's context; the full payload stays
95
+ * retrievable via the canonical GET route. Runs only on success — problem
96
+ * passthrough is unaffected.
97
+ */
98
+ transform?: (result: Record<string, unknown>) => Record<string, unknown>;
99
+ }
100
+ /** Extract `:param` names from a canonical path, in order. */
101
+ export declare function pathParamsOf(path: string): string[];
102
+ /**
103
+ * Generate a ToolDef from a declarative spec. The returned definition is a
104
+ * plain ToolDef — indistinguishable from a defineTool declaration to the
105
+ * server, the registry, and the annotations layer.
106
+ */
107
+ export declare function defineGeneratedTool<S extends z.ZodRawShape>(spec: GeneratedToolSpec<S>): ToolDef;
108
+ //# sourceMappingURL=generate.d.ts.map