capix-mcp 2.1.0 → 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 (49) hide show
  1. package/README.md +51 -72
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +18 -8
  4. package/dist/client.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +130 -6
  8. package/dist/index.js.map +1 -1
  9. package/dist/prompts.d.ts +6 -1
  10. package/dist/prompts.d.ts.map +1 -1
  11. package/dist/prompts.js +41 -75
  12. package/dist/prompts.js.map +1 -1
  13. package/dist/route-families.d.ts +47 -0
  14. package/dist/route-families.d.ts.map +1 -0
  15. package/dist/route-families.js +96 -0
  16. package/dist/route-families.js.map +1 -0
  17. package/dist/server.d.ts +36 -6
  18. package/dist/server.d.ts.map +1 -1
  19. package/dist/server.js +67 -11
  20. package/dist/server.js.map +1 -1
  21. package/dist/tools/define-tool.d.ts +33 -0
  22. package/dist/tools/define-tool.d.ts.map +1 -0
  23. package/dist/tools/define-tool.js +28 -0
  24. package/dist/tools/define-tool.js.map +1 -0
  25. package/dist/tools/factory.d.ts +42 -0
  26. package/dist/tools/factory.d.ts.map +1 -0
  27. package/dist/tools/factory.js +363 -0
  28. package/dist/tools/factory.js.map +1 -0
  29. package/dist/tools/generate.d.ts +108 -0
  30. package/dist/tools/generate.d.ts.map +1 -0
  31. package/dist/tools/generate.js +149 -0
  32. package/dist/tools/generate.js.map +1 -0
  33. package/dist/tools/infra-context.d.ts +28 -0
  34. package/dist/tools/infra-context.d.ts.map +1 -0
  35. package/dist/tools/infra-context.js +90 -0
  36. package/dist/tools/infra-context.js.map +1 -0
  37. package/dist/tools/memes.d.ts +31 -0
  38. package/dist/tools/memes.d.ts.map +1 -0
  39. package/dist/tools/memes.js +175 -0
  40. package/dist/tools/memes.js.map +1 -0
  41. package/dist/tools.d.ts +48 -7
  42. package/dist/tools.d.ts.map +1 -1
  43. package/dist/tools.js +346 -911
  44. package/dist/tools.js.map +1 -1
  45. package/dist/types.d.ts +17 -2
  46. package/dist/types.d.ts.map +1 -1
  47. package/dist/types.js +1 -2
  48. package/dist/types.js.map +1 -1
  49. package/package.json +4 -3
@@ -0,0 +1,149 @@
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
+ // ===========================================================================
39
+ // Generator
40
+ // ===========================================================================
41
+ /** Extract `:param` names from a canonical path, in order. */
42
+ export function pathParamsOf(path) {
43
+ return path
44
+ .split("/")
45
+ .filter((s) => s.startsWith(":"))
46
+ .map((s) => s.slice(1));
47
+ }
48
+ /** Throw the repo-standard approval error (same shape as callBillable). */
49
+ function approvalRequiredError() {
50
+ const err = new Error("approvalToken is required for this billable tool (§5)");
51
+ err.capixCode = "approval_required";
52
+ err.status = 402;
53
+ return err;
54
+ }
55
+ /** Throw the repo-standard invalid-argument error (same shape as asStr). */
56
+ function invalidArgumentError(field) {
57
+ const err = new Error(`${field} is required`);
58
+ err.capixCode = "invalid_argument";
59
+ err.status = 400;
60
+ return err;
61
+ }
62
+ /**
63
+ * Generate a ToolDef from a declarative spec. The returned definition is a
64
+ * plain ToolDef — indistinguishable from a defineTool declaration to the
65
+ * server, the registry, and the annotations layer.
66
+ */
67
+ export function defineGeneratedTool(spec) {
68
+ const pathParams = pathParamsOf(spec.path);
69
+ // Declaration-time enforcement: every path param must be a declared input,
70
+ // so a spec can never reference a path segment the caller cannot supply.
71
+ for (const param of pathParams) {
72
+ if (!(param in spec.input)) {
73
+ throw new Error(`defineGeneratedTool(${spec.name}): path param :${param} is not declared in the input shape`);
74
+ }
75
+ }
76
+ if (spec.method === "GET" && spec.body) {
77
+ throw new Error(`defineGeneratedTool(${spec.name}): GET tools cannot declare a request body`);
78
+ }
79
+ const pathParamSet = new Set(pathParams);
80
+ const nonPathKeys = Object.keys(spec.input).filter((k) => !pathParamSet.has(k));
81
+ const queryKeys = spec.query ?? (spec.method === "GET" ? nonPathKeys : []);
82
+ const bodyKeys = spec.body ?? (spec.method === "POST" ? nonPathKeys : []);
83
+ const idempotent = spec.idempotent ?? (spec.method !== "GET" && (spec.billable || spec.requiresApproval));
84
+ const needsApproval = spec.billable || spec.requiresApproval;
85
+ const handler = async (rawArgs, { client, ctx }) => {
86
+ // Approval gate — mirrors callBillable in tools.ts. The server wrapper
87
+ // also gates before dispatch; this keeps the invariant when a handler is
88
+ // invoked directly (tests, future transports).
89
+ if (needsApproval && !ctx.approvalToken)
90
+ throw approvalRequiredError();
91
+ // Fill path params (URL-encoded), failing closed on empty values.
92
+ let path = spec.path;
93
+ for (const param of pathParams) {
94
+ const value = rawArgs[param];
95
+ if (value === undefined || value === null || `${value}` === "") {
96
+ throw invalidArgumentError(param);
97
+ }
98
+ path = path.replace(`:${param}`, encodeURIComponent(String(value)));
99
+ }
100
+ // Success-path post-processing (e.g. payload truncation); problem
101
+ // passthrough is untouched because this never wraps a throw.
102
+ const finish = (result) => spec.transform ? spec.transform(result) : result;
103
+ if (spec.method === "GET") {
104
+ const params = {};
105
+ for (const key of queryKeys)
106
+ params[key] = rawArgs[key];
107
+ return finish(await client.get(path, queryKeys.length > 0 ? params : undefined));
108
+ }
109
+ if (spec.method === "DELETE") {
110
+ // client.delete always derives an Idempotency-Key from the path.
111
+ return finish(await client.delete(path));
112
+ }
113
+ // POST: assemble the body from the declared body keys, dropping undefined
114
+ // fields. When nothing has a value, send no body at all (hand-written
115
+ // convention).
116
+ let body;
117
+ if (bodyKeys.length > 0) {
118
+ const assembled = {};
119
+ for (const key of bodyKeys) {
120
+ if (rawArgs[key] !== undefined)
121
+ assembled[key] = rawArgs[key];
122
+ }
123
+ body = Object.keys(assembled).length > 0 ? assembled : undefined;
124
+ }
125
+ if (!idempotent && !needsApproval) {
126
+ // Read-only POST (quote/plan/validate): no idempotency key, no approval
127
+ // header — identical to the hand-written `client.post(path, args)`.
128
+ return finish(await client.post(path, body));
129
+ }
130
+ return finish(await client.post(path, body, {
131
+ ...(idempotent ? { idempotent: true } : {}),
132
+ ...(needsApproval ? { approvalToken: ctx.approvalToken } : {}),
133
+ }));
134
+ };
135
+ return {
136
+ name: spec.name,
137
+ description: spec.description,
138
+ scope: spec.scope,
139
+ billable: spec.billable,
140
+ requiresApproval: spec.requiresApproval,
141
+ routePath: spec.path,
142
+ inputShape: spec.input,
143
+ outputShape: spec.outputShape,
144
+ // Sound cast: same guarantee as defineTool — the McpServer validates args
145
+ // against inputShape before the handler runs.
146
+ handler: handler,
147
+ };
148
+ }
149
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/tools/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAuEH,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,8DAA8D;AAC9D,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,2EAA2E;AAC3E,SAAS,qBAAqB;IAC5B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,uDAAuD,CAG5E,CAAC;IACF,GAAG,CAAC,SAAS,GAAG,mBAAmB,CAAC;IACpC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;IACjB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,4EAA4E;AAC5E,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,cAAc,CAAkD,CAAC;IAC/F,GAAG,CAAC,SAAS,GAAG,kBAAkB,CAAC;IACnC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;IACjB,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAA0B,IAA0B;IACrF,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC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AAW;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,SAAS,EAAE,IAAI,CAAC,IAAI;QACpB,UAAU,EAAE,IAAI,CAAC,KAAK;QACtB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,0EAA0E;QAC1E,8CAA8C;QAC9C,OAAO,EAAE,OAA6B;KACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Capix MCP Server — infra-context tools (2).
3
+ *
4
+ * Read-only live views over the customer's Capix infrastructure footprint.
5
+ * Every tool is read-only — safe to auto-run after authentication — and
6
+ * delegates to a canonical `/api/v1/*` route that EXISTS in the control
7
+ * plane (verified 2026-07; see ../route-families.ts):
8
+ *
9
+ * capix_marketplace_browse GET /api/v1/marketplace/offers live GPU offers (public)
10
+ * capix_model_list GET /api/v1/models deployable model catalog
11
+ *
12
+ * Removed in the 2026-07 repair (no backing route in the control plane):
13
+ * capix_node_status — there is no /api/v1/nodes/status (only
14
+ * nodes/[id]/earnings and nodes/[id]/conformance)
15
+ * capix_earnings_check — there is no /api/v1/earnings aggregate route
16
+ * capix_deployment_list — duplicated capix_deployments once both were
17
+ * aligned to the real GET /api/v1/deployments
18
+ * contract (status/cursor/limit, no phase/include)
19
+ *
20
+ * This module shares `defineTool` with the aggregate registry in ../tools.ts
21
+ * via ./define-tool.js (a leaf module), so there is no import cycle. The
22
+ * small Zod shapes below are re-declared locally to keep the module
23
+ * self-contained.
24
+ */
25
+ import type { ToolDef } from "../types.js";
26
+ export declare const infraContextTools: ToolDef[];
27
+ export declare const INFRA_CONTEXT_TOOL_NAMES: string[];
28
+ //# sourceMappingURL=infra-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infra-context.d.ts","sourceRoot":"","sources":["../../src/tools/infra-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAkB3C,eAAO,MAAM,iBAAiB,EAAE,OAAO,EAkDtC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,MAAM,EAAyC,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Capix MCP Server — infra-context tools (2).
3
+ *
4
+ * Read-only live views over the customer's Capix infrastructure footprint.
5
+ * Every tool is read-only — safe to auto-run after authentication — and
6
+ * delegates to a canonical `/api/v1/*` route that EXISTS in the control
7
+ * plane (verified 2026-07; see ../route-families.ts):
8
+ *
9
+ * capix_marketplace_browse GET /api/v1/marketplace/offers live GPU offers (public)
10
+ * capix_model_list GET /api/v1/models deployable model catalog
11
+ *
12
+ * Removed in the 2026-07 repair (no backing route in the control plane):
13
+ * capix_node_status — there is no /api/v1/nodes/status (only
14
+ * nodes/[id]/earnings and nodes/[id]/conformance)
15
+ * capix_earnings_check — there is no /api/v1/earnings aggregate route
16
+ * capix_deployment_list — duplicated capix_deployments once both were
17
+ * aligned to the real GET /api/v1/deployments
18
+ * contract (status/cursor/limit, no phase/include)
19
+ *
20
+ * This module shares `defineTool` with the aggregate registry in ../tools.ts
21
+ * via ./define-tool.js (a leaf module), so there is no import cycle. The
22
+ * small Zod shapes below are re-declared locally to keep the module
23
+ * self-contained.
24
+ */
25
+ import { z } from "zod";
26
+ import { defineTool } from "./define-tool.js";
27
+ import { defineGeneratedTool } from "./generate.js";
28
+ import { READ_ONLY } from "../types.js";
29
+ // ===========================================================================
30
+ // Local Zod fragments (mirror tools.ts — keep in sync)
31
+ // ===========================================================================
32
+ const iso8601 = z.string().datetime().or(z.string());
33
+ const listResultShape = {
34
+ entries: z.array(z.record(z.unknown())).optional().describe("Paginated item array."),
35
+ nextCursor: z.string().optional().describe("Opaque cursor for the next page; absent when exhausted."),
36
+ fetchedAt: iso8601.optional().describe("ISO8601 fetch timestamp."),
37
+ };
38
+ // ===========================================================================
39
+ // Infra-context tools (2) — read-only infra visibility for agents.
40
+ // ===========================================================================
41
+ export const infraContextTools = [
42
+ defineTool({
43
+ name: "capix_marketplace_browse",
44
+ description: "Browse live GPU marketplace offers (provider-anonymized: region, trust tier, capability, price/hr, health score). Read-only.",
45
+ scope: "infra-context",
46
+ ...READ_ONLY,
47
+ routePath: "/api/v1/marketplace/offers",
48
+ inputShape: {
49
+ gpuModel: z.string().optional().describe("Optional GPU model filter (e.g. A100, H100)."),
50
+ region: z.string().optional().describe("Optional region filter."),
51
+ trustTier: z
52
+ .enum(["community", "verified", "sovereign"])
53
+ .optional()
54
+ .describe("Optional trust tier filter."),
55
+ capability: z
56
+ .enum(["cpu", "gpu", "gpu_high_mem", "secure_enclave", "quantum_sim"])
57
+ .optional()
58
+ .describe("Optional capability filter."),
59
+ limit: z.number().int().min(1).max(200).default(50).describe("Max offers to return (upstream bounds)."),
60
+ cursor: z.string().optional().describe("Opaque pagination cursor from a previous page."),
61
+ },
62
+ outputShape: listResultShape,
63
+ handler: async (args, { client }) => client.get("/api/v1/marketplace/offers", {
64
+ gpuModel: args.gpuModel,
65
+ region: args.region,
66
+ trustTier: args.trustTier,
67
+ capability: args.capability,
68
+ limit: args.limit,
69
+ cursor: args.cursor,
70
+ }),
71
+ }),
72
+ defineGeneratedTool({
73
+ name: "capix_model_list",
74
+ description: "List deployable models: the public Capix catalog plus the caller's ready private " +
75
+ "endpoints (id, label, category, context window, pricing, availability). Read-only.",
76
+ scope: "infra-context",
77
+ ...READ_ONLY,
78
+ method: "GET",
79
+ path: "/api/v1/models",
80
+ input: {
81
+ projectId: z.string().optional().describe("Optional project id (the only query param the route accepts)."),
82
+ },
83
+ outputShape: {
84
+ models: z.array(z.record(z.unknown())).optional(),
85
+ projectId: z.string().optional(),
86
+ },
87
+ }),
88
+ ];
89
+ export const INFRA_CONTEXT_TOOL_NAMES = infraContextTools.map((t) => t.name);
90
+ //# sourceMappingURL=infra-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3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E,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;SAC3G;QACD,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;YACjD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACjC;KACF,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAa,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Capix MCP Server — meme + image generation tools (3).
3
+ *
4
+ * Thin wrappers over the control-plane content routes (see
5
+ * app/api/v1/memes/route.ts and app/api/v1/images/route.ts in the protocol
6
+ * repo):
7
+ *
8
+ * capix_meme POST /api/v1/memes generate a meme (billable)
9
+ * capix_image_gen POST /api/v1/images text-to-image (billable)
10
+ * capix_meme_templates GET /api/v1/memes template/vibe catalog (read-only)
11
+ *
12
+ * All three are declared with `defineGeneratedTool` (./generate.ts), so the
13
+ * registration and the HTTP dispatch share one spec. The two POSTs are real
14
+ * money-moving mutations — they inherit the generator's defaults for billable
15
+ * specs: an Idempotency-Key derived from path+body and the bound
16
+ * approvalToken header, matching the routes' `Idempotency-Key` requirement.
17
+ *
18
+ * Payload truncation: both POST responses carry large inline artifacts
19
+ * (`svg` markup for memes, `base64` rasters for images). The `transform`
20
+ * hook replaces each artifact with a short omission pointer (share URL /
21
+ * id + the canonical GET /api/v1/memes/:id retrieval route) so the payload
22
+ * itself never floods the agent's context. Captions, prompt, and the
23
+ * `charge` object pass through untouched.
24
+ *
25
+ * This module shares `defineGeneratedTool` with the aggregate registry in
26
+ * ../tools.ts via ./generate.js (a leaf module), so there is no import cycle.
27
+ */
28
+ import type { ToolDef } from "../types.js";
29
+ export declare const memeImageTools: ToolDef[];
30
+ export declare const MEME_IMAGE_TOOL_NAMES: string[];
31
+ //# sourceMappingURL=memes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memes.d.ts","sourceRoot":"","sources":["../../src/tools/memes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAmE3C,eAAO,MAAM,cAAc,EAAE,OAAO,EAwFnC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,EAAsC,CAAC"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Capix MCP Server — meme + image generation tools (3).
3
+ *
4
+ * Thin wrappers over the control-plane content routes (see
5
+ * app/api/v1/memes/route.ts and app/api/v1/images/route.ts in the protocol
6
+ * repo):
7
+ *
8
+ * capix_meme POST /api/v1/memes generate a meme (billable)
9
+ * capix_image_gen POST /api/v1/images text-to-image (billable)
10
+ * capix_meme_templates GET /api/v1/memes template/vibe catalog (read-only)
11
+ *
12
+ * All three are declared with `defineGeneratedTool` (./generate.ts), so the
13
+ * registration and the HTTP dispatch share one spec. The two POSTs are real
14
+ * money-moving mutations — they inherit the generator's defaults for billable
15
+ * specs: an Idempotency-Key derived from path+body and the bound
16
+ * approvalToken header, matching the routes' `Idempotency-Key` requirement.
17
+ *
18
+ * Payload truncation: both POST responses carry large inline artifacts
19
+ * (`svg` markup for memes, `base64` rasters for images). The `transform`
20
+ * hook replaces each artifact with a short omission pointer (share URL /
21
+ * id + the canonical GET /api/v1/memes/:id retrieval route) so the payload
22
+ * itself never floods the agent's context. Captions, prompt, and the
23
+ * `charge` object pass through untouched.
24
+ *
25
+ * This module shares `defineGeneratedTool` with the aggregate registry in
26
+ * ../tools.ts via ./generate.js (a leaf module), so there is no import cycle.
27
+ */
28
+ import { z } from "zod";
29
+ import { defineGeneratedTool } from "./generate.js";
30
+ import { BILLABLE, READ_ONLY } from "../types.js";
31
+ // ===========================================================================
32
+ // Local Zod fragments (mirror tools.ts — keep in sync)
33
+ // ===========================================================================
34
+ /**
35
+ * Charge envelope returned by the meme/image routes: either a settled
36
+ * balance charge (integer minor units as a string) or a free-tier grant.
37
+ */
38
+ const chargeShape = z
39
+ .object({
40
+ kind: z.enum(["free", "balance"]).optional(),
41
+ amountMinor: z
42
+ .string()
43
+ .optional()
44
+ .describe("Integer minor units charged, serialized as a string."),
45
+ asset: z.string().optional(),
46
+ scale: z.number().int().optional(),
47
+ freeUsedToday: z.number().int().optional(),
48
+ freePerDay: z.number().int().optional(),
49
+ })
50
+ .describe("Settled charge for the generation (balance debit or free-tier grant).");
51
+ /** Caption voices accepted by POST /api/v1/memes (MEME_VIBES upstream). */
52
+ const MEME_VIBE_VALUES = ["degen", "pump", "bagholder", "unhinged", "dev", "spicy"];
53
+ // ===========================================================================
54
+ // Payload truncation (transform hooks)
55
+ // ===========================================================================
56
+ /** Replace an oversized inline payload with a short omission pointer. */
57
+ function omitPayload(payload, pointer) {
58
+ return `[omitted ${payload.length} chars — ${pointer}]`;
59
+ }
60
+ /**
61
+ * Swap the inline meme SVG for a pointer to the share page / canonical
62
+ * retrieval route. Everything else (captions, charge, ids) passes through.
63
+ */
64
+ function truncateMemeResponse(res) {
65
+ if (typeof res.svg !== "string")
66
+ return res;
67
+ const memeId = typeof res.memeId === "string" ? res.memeId : "unknown";
68
+ const shareUrl = typeof res.shareUrl === "string" ? res.shareUrl : undefined;
69
+ const pointer = shareUrl
70
+ ? `view at ${shareUrl} or fetch via GET /api/v1/memes/${memeId}`
71
+ : `fetch via GET /api/v1/memes/${memeId}`;
72
+ return { ...res, svg: omitPayload(res.svg, pointer) };
73
+ }
74
+ /**
75
+ * Swap the inline base64 raster for a pointer to the image id. The image is
76
+ * persisted server-side and retrievable via GET /api/v1/memes/:id.
77
+ */
78
+ function truncateImageResponse(res) {
79
+ if (typeof res.base64 !== "string")
80
+ return res;
81
+ const imageId = typeof res.imageId === "string" ? res.imageId : "unknown";
82
+ return {
83
+ ...res,
84
+ base64: omitPayload(res.base64, `imageId ${imageId} — fetch via GET /api/v1/memes/${imageId}`),
85
+ };
86
+ }
87
+ // ===========================================================================
88
+ // Meme + image tools (3)
89
+ // ===========================================================================
90
+ export const memeImageTools = [
91
+ defineGeneratedTool({
92
+ name: "capix_meme",
93
+ description: "Generate a meme from a topic: template captions, or a fully AI-generated canvas image. " +
94
+ "The account gets a small free daily allowance, then a fixed balance charge; omitting " +
95
+ "templateId (or passing \"ai-canvas\") generates the image with AI at 2x the template " +
96
+ "price. Returns the meme id, captions, shareUrl, and the settled charge; the inline SVG " +
97
+ "is replaced with a pointer to the share URL. Billable; requires approval.",
98
+ scope: "lifecycle",
99
+ ...BILLABLE,
100
+ method: "POST",
101
+ path: "/api/v1/memes",
102
+ input: {
103
+ topic: z.string().min(1).describe("What the meme is about."),
104
+ vibe: z
105
+ .enum(MEME_VIBE_VALUES)
106
+ .optional()
107
+ .describe("Caption voice (see capix_meme_templates for the live catalog)."),
108
+ templateId: z
109
+ .string()
110
+ .optional()
111
+ .describe("Template id from capix_meme_templates. Omit (or pass \"ai-canvas\") for a fully " +
112
+ "AI-generated image at 2x the template price."),
113
+ },
114
+ outputShape: {
115
+ memeId: z.string().optional(),
116
+ svg: z
117
+ .string()
118
+ .optional()
119
+ .describe("Omission pointer — the full SVG is at shareUrl / GET /api/v1/memes/:id."),
120
+ caption: z.string().optional(),
121
+ captions: z.record(z.string()).optional(),
122
+ templateId: z.string().optional(),
123
+ vibe: z.string().optional(),
124
+ mode: z.string().optional(),
125
+ shareUrl: z.string().optional(),
126
+ charge: chargeShape.optional(),
127
+ },
128
+ transform: truncateMemeResponse,
129
+ }),
130
+ defineGeneratedTool({
131
+ name: "capix_image_gen",
132
+ description: "Generate an image from a text prompt (fixed per-image balance charge, no free tier). " +
133
+ "Returns the image id, content type, and the settled charge; the base64 payload is " +
134
+ "replaced with a pointer to the retrievable image id. Billable; requires approval.",
135
+ scope: "lifecycle",
136
+ ...BILLABLE,
137
+ method: "POST",
138
+ path: "/api/v1/images",
139
+ input: {
140
+ prompt: z
141
+ .string()
142
+ .min(2)
143
+ .max(1000)
144
+ .describe("Image prompt (2–1000 characters, per the control-plane limit)."),
145
+ },
146
+ outputShape: {
147
+ imageId: z.string().optional(),
148
+ base64: z
149
+ .string()
150
+ .optional()
151
+ .describe("Omission pointer — the full image is retrievable via GET /api/v1/memes/:id."),
152
+ contentType: z.string().optional(),
153
+ prompt: z.string().optional(),
154
+ charge: chargeShape.optional(),
155
+ },
156
+ transform: truncateImageResponse,
157
+ }),
158
+ defineGeneratedTool({
159
+ name: "capix_meme_templates",
160
+ description: "List the meme catalog: available templates (ids, slots, hints), caption vibes, and " +
161
+ "whether AI-canvas image generation is currently available. Free; read-only.",
162
+ scope: "discovery",
163
+ ...READ_ONLY,
164
+ method: "GET",
165
+ path: "/api/v1/memes",
166
+ input: {},
167
+ outputShape: {
168
+ templates: z.array(z.record(z.unknown())).optional(),
169
+ vibes: z.array(z.string()).optional(),
170
+ aiCanvasAvailable: z.boolean().optional(),
171
+ },
172
+ }),
173
+ ];
174
+ export const MEME_IMAGE_TOOL_NAMES = memeImageTools.map((t) => t.name);
175
+ //# sourceMappingURL=memes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memes.js","sourceRoot":"","sources":["../../src/tools/memes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGlD,8EAA8E;AAC9E,uDAAuD;AACvD,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,M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AM,EAAE,CAAC,QAAQ,EAAE;YAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC7B,MAAM,EAAE,WAAW,CAAC,QAAQ,EAAE;SAC/B;QACD,SAAS,EAAE,qBAAqB;KACjC,CAAC;IACF,mBAAmB,CAAC;QAClB,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EACT,qFAAqF;YACrF,6EAA6E;QAC/E,KAAK,EAAE,WAAW;QAClB,GAAG,SAAS;QACZ,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,EAAE;QACT,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;YACpD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;YACrC,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;SAC1C;KACF,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAa,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC"}
package/dist/tools.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  /**
2
- * Capix MCP Server — all 59 tool definitions.
2
+ * Capix MCP Server — all 37 tool definitions.
3
+ *
4
+ * 2026-07 repair: every tool below targets a route family that EXISTS in the
5
+ * control plane (app/api/v1/* in the protocol repo), verified route-by-route
6
+ * against the live source. Each tool declares its canonical path (`routePath`)
7
+ * and the registry gate (tools/registry.test.ts) asserts it against the
8
+ * allowlist in route-families.ts — no phantom routes can be re-introduced.
3
9
  *
4
10
  * Each tool is declared with:
5
11
  * - inputShape : a Zod raw shape (validated by the McpServer before dispatch)
@@ -11,16 +17,51 @@
11
17
  * structured content. The CapixApiError (problem+json) thrown by the client is
12
18
  * caught by the server wrapper and surfaced as an MCP error result.
13
19
  *
14
- * Tools are grouped by scope (mirrors services/capix-mcp/tools/*.ts):
15
- * discovery (9) · planning (6) · lifecycle (7) · networking (8) ·
16
- * testing (6) · verification (6) · website (17)
20
+ * CRUD-shaped tools are declared with `defineGeneratedTool` (tools/generate.ts)
21
+ * a declarative spec (method, path, input) from which the registration AND
22
+ * the HTTP call are generated instead of a hand-written handler. Everything
23
+ * else uses `defineTool` (tools/define-tool.ts) with an explicit handler.
24
+ *
25
+ * Tools are grouped by scope:
26
+ * discovery (7) · planning (2) · lifecycle (19) · verification (1) ·
27
+ * website (6) · infra-context (2)
28
+ * (The factory tools — jobs/training/agent-deploys — live in
29
+ * tools/factory.ts and join lifecycle; the meme/image tools live in
30
+ * tools/memes.ts: the meme catalog joins discovery, the two billable
31
+ * generators join lifecycle.)
32
+ *
33
+ * Removed in the repair (no backing route in the control plane — hidden, not
34
+ * deleted from git history):
35
+ * - networking scope (8 tools): /api/v1/networking/* and /api/v1/vpc do not
36
+ * exist. Returns with the networking roadmap (N1–N5).
37
+ * - testing scope (6 tools): /api/v1/testing/* does not exist (disposable
38
+ * test envs are not built).
39
+ * - attestation/zkVM/measurement tools (5): /api/v1/verification/* and
40
+ * /api/v1/attestations do not exist. Secured Cloud (TEE/zkVM) is deferred.
41
+ * - planning stubs (capix_compute_plan, capix_model_plan, capix_stack_*):
42
+ * /api/v1/planning/* does not exist; quoting lives at /api/v1/quotes.
43
+ * - lifecycle stubs (capix_start/stop/restart/extend): start/stop exist
44
+ * upstream ONLY as PATCH /api/v1/deployments/[id] { desiredState } with a
45
+ * mandatory If-Match etag — unreachable through the current client
46
+ * surface (no PATCH, no etag access). Restart/extend have no backend.
47
+ * - discovery stubs: capix_projects (no /api/v1/projects),
48
+ * capix_model_catalog (real catalog is /api/v1/models, covered by
49
+ * capix_model_list), capix_attestations (Secured Cloud deferred).
50
+ * - website stubs (12 tools): singular /api/v1/website/* never existed and
51
+ * detect/plan/quote/deploy/preview/deployments/logs/metrics/domains have
52
+ * no routes under the real /api/v1/websites family (build logs surface as
53
+ * `logTail` inside capix_website_get; previews are implicit per release).
54
+ * - infra-context stubs: capix_node_status, capix_earnings_check (no
55
+ * /api/v1/nodes/status or /api/v1/earnings), capix_deployment_list
56
+ * (duplicate of capix_deployments).
17
57
  */
18
58
  import type { ToolDef } from "./types.js";
59
+ import { factoryTools } from "./tools/factory.js";
60
+ import { infraContextTools } from "./tools/infra-context.js";
61
+ import { memeImageTools } from "./tools/memes.js";
19
62
  declare const discoveryTools: ToolDef[];
20
63
  declare const planningTools: ToolDef[];
21
64
  declare const lifecycleTools: ToolDef[];
22
- declare const networkingTools: ToolDef[];
23
- declare const testingTools: ToolDef[];
24
65
  declare const verificationTools: ToolDef[];
25
66
  declare const websiteTools: ToolDef[];
26
67
  export declare const TOOLS: ToolDef[];
@@ -28,5 +69,5 @@ export declare const TOOL_NAMES: string[];
28
69
  export declare const TOOL_COUNT: number;
29
70
  /** Map of tool name → definition, used by the server for O(1) lookup. */
30
71
  export declare const TOOL_MAP: Map<string, ToolDef>;
31
- export { discoveryTools, planningTools, lifecycleTools, networkingTools, testingTools, verificationTools, websiteTools };
72
+ export { discoveryTools, planningTools, lifecycleTools, verificationTools, websiteTools, factoryTools, infraContextTools, memeImageTools };
32
73
  //# sourceMappingURL=tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAEV,OAAO,EAGR,MAAM,YAAY,CAAC;AAyIpB,QAAA,MAAM,cAAc,EAAE,OAAO,EAmK5B,CAAC;AAqCF,QAAA,MAAM,aAAa,EAAE,OAAO,EA8F3B,CAAC;AAMF,QAAA,MAAM,cAAc,EAAE,OAAO,EA0I5B,CAAC;AAMF,QAAA,MAAM,eAAe,EAAE,OAAO,EA8H7B,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