@axonity-ai/mcp 0.1.0 → 0.3.2

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 (44) hide show
  1. package/README.md +172 -24
  2. package/dist/client.d.ts +11 -2
  3. package/dist/client.js +28 -10
  4. package/dist/client.js.map +1 -1
  5. package/dist/errors.d.ts +53 -10
  6. package/dist/errors.js +163 -19
  7. package/dist/errors.js.map +1 -1
  8. package/dist/index.d.ts +21 -0
  9. package/dist/index.js +135 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/tools/company.d.ts +16 -0
  12. package/dist/tools/company.js +81 -0
  13. package/dist/tools/company.js.map +1 -0
  14. package/dist/tools/conventions.d.ts +10 -4
  15. package/dist/tools/conventions.js +389 -23
  16. package/dist/tools/conventions.js.map +1 -1
  17. package/dist/tools/credentials.d.ts +34 -0
  18. package/dist/tools/credentials.js +106 -0
  19. package/dist/tools/credentials.js.map +1 -0
  20. package/dist/tools/extras.d.ts +14 -5
  21. package/dist/tools/extras.js +85 -40
  22. package/dist/tools/extras.js.map +1 -1
  23. package/dist/tools/promptPlacement.d.ts +15 -0
  24. package/dist/tools/promptPlacement.js +99 -0
  25. package/dist/tools/promptPlacement.js.map +1 -0
  26. package/dist/tools/register.d.ts +67 -10
  27. package/dist/tools/register.js +77 -22
  28. package/dist/tools/register.js.map +1 -1
  29. package/dist/tools/runs.d.ts +14 -0
  30. package/dist/tools/runs.js +103 -0
  31. package/dist/tools/runs.js.map +1 -0
  32. package/dist/tools/triggers.d.ts +13 -0
  33. package/dist/tools/triggers.js +128 -0
  34. package/dist/tools/triggers.js.map +1 -0
  35. package/dist/tools/validation.d.ts +13 -0
  36. package/dist/tools/validation.js +116 -0
  37. package/dist/tools/validation.js.map +1 -0
  38. package/dist/tools/versions.d.ts +37 -0
  39. package/dist/tools/versions.js +104 -0
  40. package/dist/tools/versions.js.map +1 -0
  41. package/dist/tools/workflowMutations.d.ts +22 -0
  42. package/dist/tools/workflowMutations.js +118 -23
  43. package/dist/tools/workflowMutations.js.map +1 -1
  44. package/package.json +2 -2
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Run observability — how an agent evaluates what it built.
3
+ *
4
+ * There is no "findings" endpoint and no evaluator entity. Evaluation means
5
+ * reading runs: the run detail carries `validatorVerdicts` and
6
+ * `agentInvocations`, and the trace carries the step-by-step tool calls. Those
7
+ * are the evidence an agent reasons over.
8
+ *
9
+ * Runs are also the only thing in the product with a real archive state —
10
+ * entities have soft-delete, runs have archive/unarchive.
11
+ */
12
+ import { z } from "zod";
13
+ import { guard, jsonResult } from "./result.js";
14
+ const CONFIRM = z
15
+ .literal(true)
16
+ .describe("Must be true. Destructive and irreversible — ask your human first.");
17
+ export function registerRunTools(server, client) {
18
+ server.tool("start_workflow_run", "Start a real run of a workflow — the way to TEST a workflow you just " +
19
+ "authored. This EXECUTES: it runs the PUBLISHED workflow against live " +
20
+ "infrastructure (models, connectors), so it can incur cost and cause real " +
21
+ "side effects. It does not run your unpublished draft. After starting, " +
22
+ "follow it with read_run / read_run_trace / read_run_cost. Optionally pass " +
23
+ "triggerInput to feed the workflow's trigger.", {
24
+ workflowId: z.string().describe("The workflow's id."),
25
+ triggerInput: z
26
+ .record(z.unknown())
27
+ .optional()
28
+ .describe("Input payload for the workflow's trigger. Omit for none."),
29
+ manualPhases: z
30
+ .boolean()
31
+ .optional()
32
+ .describe("Run with manual phase gating. Defaults to false."),
33
+ }, async ({ workflowId, triggerInput, manualPhases }) => guard(async () => jsonResult(await client.post(`/api/v1/workflows/${workflowId}/runs`, {
34
+ ...(triggerInput ? { triggerInput } : {}),
35
+ ...(manualPhases === undefined ? {} : { manualPhases }),
36
+ }))));
37
+ server.tool("cancel_run", "Cancel an in-flight run. Stops further steps; already-completed steps and " +
38
+ "their side effects are not undone.", { runId: z.string().describe("The run's id.") }, async ({ runId }) => guard(async () => jsonResult(await client.post(`/api/v1/runs/${runId}/cancel`))));
39
+ server.tool("delete_run", "Delete ONE run. IRREVERSIBLE — the run and its trace and cost history go " +
40
+ "with it. Prefer archive_run unless a human has asked for deletion. For " +
41
+ "many at once use bulk_delete_runs.", {
42
+ runId: z.string().describe("The run's id."),
43
+ confirm: CONFIRM,
44
+ }, async ({ runId }) => guard(async () => {
45
+ await client.del(`/api/v1/runs/${runId}`);
46
+ return jsonResult({ deleted: true, runId });
47
+ }));
48
+ server.tool("list_runs", "List workflow runs across the tenant, newest first. Archived runs are " +
49
+ "excluded unless includeArchived is true. To list runs of ONE workflow, " +
50
+ "use list_workflow_runs instead — this route has no workflow filter.", {
51
+ status: z
52
+ .string()
53
+ .optional()
54
+ .describe('Comma-separated statuses, e.g. "running,failed". Omit for all.'),
55
+ createdAfter: z.string().optional().describe("ISO date lower bound."),
56
+ createdBefore: z.string().optional().describe("ISO date upper bound."),
57
+ includeArchived: z.boolean().optional().describe("Defaults to false."),
58
+ limit: z.number().int().optional().describe("Default 50, capped at 200."),
59
+ offset: z.number().int().optional().describe("Default 0."),
60
+ }, async ({ status, createdAfter, createdBefore, includeArchived, limit, offset }) => guard(async () => jsonResult(await client.get("/api/v1/runs", {
61
+ status,
62
+ created_after: createdAfter,
63
+ created_before: createdBefore,
64
+ include_archived: includeArchived,
65
+ limit,
66
+ offset,
67
+ }))));
68
+ server.tool("list_workflow_runs", "List the runs of one workflow. Note this route takes archivedOnly (show " +
69
+ "ONLY archived runs), which is not the same as list_runs' includeArchived.", {
70
+ workflowId: z.string().describe("The workflow's id."),
71
+ archivedOnly: z
72
+ .boolean()
73
+ .optional()
74
+ .describe("True to list only archived runs. Defaults to false."),
75
+ }, async ({ workflowId, archivedOnly }) => guard(async () => jsonResult(await client.get(`/api/v1/workflows/${workflowId}/runs`, {
76
+ archived_only: archivedOnly,
77
+ }))));
78
+ server.tool("read_run", "Read one run in full: status, per-step state, the workflow snapshot it " +
79
+ "ran against, trigger input, agent invocations, and validator verdicts. " +
80
+ "The verdicts are the closest thing to evaluator findings — there is no " +
81
+ "separate findings endpoint.", { runId: z.string().describe("The run's id.") }, async ({ runId }) => guard(async () => jsonResult(await client.get(`/api/v1/runs/${runId}`))));
82
+ server.tool("read_run_trace", "Read a run's chronological tool-call trace — each entry has the step, the " +
83
+ "tool, its arguments, its output, and any error. This is what you read to " +
84
+ "work out WHY a run behaved as it did.", { runId: z.string().describe("The run's id.") }, async ({ runId }) => guard(async () => jsonResult(await client.get(`/api/v1/runs/${runId}/trace`))));
85
+ server.tool("read_run_cost", "Read a run's token and cost breakdown, per agent and model.", { runId: z.string().describe("The run's id.") }, async ({ runId }) => guard(async () => jsonResult(await client.get(`/api/v1/runs/${runId}/cost`))));
86
+ server.tool("read_runs_summary", "Counts of runs by state across the tenant (running, waiting, completed, " +
87
+ "failed, expired, total).", {}, async () => guard(async () => jsonResult(await client.get("/api/v1/runs/summary"))));
88
+ server.tool("archive_run", "Archive a run — hides it from the default run list without deleting it. " +
89
+ "Reversible with unarchive_run.", { runId: z.string().describe("The run's id.") }, async ({ runId }) => guard(async () => jsonResult(await client.post(`/api/v1/runs/${runId}/archive`))));
90
+ server.tool("unarchive_run", "Restore an archived run to the default run list.", { runId: z.string().describe("The run's id.") }, async ({ runId }) => guard(async () => jsonResult(await client.post(`/api/v1/runs/${runId}/unarchive`))));
91
+ server.tool("bulk_archive_runs", "Archive up to 500 runs at once. Reversible — archived runs can be " +
92
+ "unarchived individually. Returns counts of succeeded and failed.", {
93
+ runIds: z.array(z.string()).min(1).max(500).describe("The run ids to archive."),
94
+ }, async ({ runIds }) => guard(async () => jsonResult(await client.post("/api/v1/runs/bulk/archive", { runIds }))));
95
+ server.tool("bulk_delete_runs", "Delete up to 500 runs at once. IRREVERSIBLE — unlike archiving, deleted " +
96
+ "runs do not come back, and their traces and cost history go with them. " +
97
+ "Prefer bulk_archive_runs unless a human has explicitly asked for deletion. " +
98
+ "Returns counts of succeeded and failed; a partial failure is possible.", {
99
+ runIds: z.array(z.string()).min(1).max(500).describe("The run ids to delete."),
100
+ confirm: CONFIRM,
101
+ }, async ({ runIds }) => guard(async () => jsonResult(await client.post("/api/v1/runs/bulk/delete", { runIds }))));
102
+ }
103
+ //# sourceMappingURL=runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/tools/runs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,OAAO,GAAG,CAAC;KACd,OAAO,CAAC,IAAI,CAAC;KACb,QAAQ,CAAC,oEAAoE,CAAC,CAAC;AAElF,MAAM,UAAU,gBAAgB,CAAC,MAAiB,EAAE,MAAqB;IACvE,MAAM,CAAC,IAAI,CACT,oBAAoB,EACpB,uEAAuE;QACrE,uEAAuE;QACvE,2EAA2E;QAC3E,wEAAwE;QACxE,4EAA4E;QAC5E,8CAA8C,EAChD;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QACrD,YAAY,EAAE,CAAC;aACZ,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aACnB,QAAQ,EAAE;aACV,QAAQ,CAAC,0DAA0D,CAAC;QACvE,YAAY,EAAE,CAAC;aACZ,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CAAC,kDAAkD,CAAC;KAChE,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,EAAE,CACnD,KAAK,CAAC,KAAK,IAAI,EAAE,CACf,UAAU,CACR,MAAM,MAAM,CAAC,IAAI,CAAC,qBAAqB,UAAU,OAAO,EAAE;QACxD,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,C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G,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QAC9E,OAAO,EAAE,OAAO;KACjB,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CACnB,KAAK,CAAC,KAAK,IAAI,EAAE,CACf,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CACtE,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Trigger management — what makes a published workflow actually run.
3
+ *
4
+ * Three trigger kinds, all member-accessible despite living in `*_admin.py` on
5
+ * the backend. Note the asymmetry the routes impose: creating and listing are
6
+ * workflow-scoped, while rotate/update/delete address the trigger directly.
7
+ *
8
+ * Trigger deletes are HARD deletes — the row is removed, not soft-deleted, and
9
+ * there is no restore. Hence the `confirm` guard on each.
10
+ */
11
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
12
+ import type { AxonityClient } from "../client.js";
13
+ export declare function registerTriggerTools(server: McpServer, client: AxonityClient): void;
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Trigger management — what makes a published workflow actually run.
3
+ *
4
+ * Three trigger kinds, all member-accessible despite living in `*_admin.py` on
5
+ * the backend. Note the asymmetry the routes impose: creating and listing are
6
+ * workflow-scoped, while rotate/update/delete address the trigger directly.
7
+ *
8
+ * Trigger deletes are HARD deletes — the row is removed, not soft-deleted, and
9
+ * there is no restore. Hence the `confirm` guard on each.
10
+ */
11
+ import { z } from "zod";
12
+ import { guard, jsonResult } from "./result.js";
13
+ /** A required literal — an agent cannot satisfy it by filling in a default. */
14
+ const CONFIRM = z
15
+ .literal(true)
16
+ .describe("Must be true. Destructive and irreversible — ask your human first.");
17
+ export function registerTriggerTools(server, client) {
18
+ // ---- Webhook triggers -------------------------------------------------
19
+ server.tool("list_webhook_triggers", "List a workflow's webhook triggers. Secrets are never returned — a " +
20
+ "trigger's token is shown only once, when it is created or rotated.", { workflowId: z.string().describe("The workflow's id.") }, async ({ workflowId }) => guard(async () => jsonResult(await client.get(`/api/v1/workflows/${workflowId}/webhook-triggers`))));
21
+ server.tool("create_webhook_trigger", "Create a webhook trigger on a workflow. Returns the trigger AND its " +
22
+ "plaintext token — shown ONCE and never retrievable again. Hand the token " +
23
+ "to your human immediately; do not store it in an entity field.", {
24
+ workflowId: z.string().describe("The workflow's id."),
25
+ triggerId: z
26
+ .string()
27
+ .describe("The id of the trigger node in the workflow document."),
28
+ expectedInputSchema: z
29
+ .record(z.unknown())
30
+ .optional()
31
+ .describe("JSON schema the incoming payload must match. Defaults to {}."),
32
+ }, async ({ workflowId, triggerId, expectedInputSchema }) => guard(async () => jsonResult(await client.post(`/api/v1/workflows/${workflowId}/webhook-triggers`, {
33
+ triggerId,
34
+ ...(expectedInputSchema ? { expectedInputSchema } : {}),
35
+ }))));
36
+ server.tool("rotate_webhook_trigger", "Rotate a webhook trigger's token. Returns the new plaintext token ONCE. " +
37
+ "The old token keeps working for a short grace period so callers can be " +
38
+ "migrated.", {
39
+ webhookId: z.string().describe("The webhook trigger's id."),
40
+ confirm: CONFIRM,
41
+ }, async ({ webhookId }) => guard(async () => jsonResult(await client.post(`/api/v1/webhook-triggers/${webhookId}/rotate`))));
42
+ server.tool("delete_webhook_trigger", "Delete a webhook trigger. HARD delete — the row is removed and cannot be " +
43
+ "restored, and any caller using its token starts failing immediately.", {
44
+ webhookId: z.string().describe("The webhook trigger's id."),
45
+ confirm: CONFIRM,
46
+ }, async ({ webhookId }) => guard(async () => {
47
+ await client.del(`/api/v1/webhook-triggers/${webhookId}`);
48
+ return jsonResult({ deleted: true, webhookId });
49
+ }));
50
+ // ---- Cron schedules ---------------------------------------------------
51
+ server.tool("list_cron_schedules", "List a workflow's cron schedules, with their next and last fire times.", { workflowId: z.string().describe("The workflow's id.") }, async ({ workflowId }) => guard(async () => jsonResult(await client.get(`/api/v1/workflows/${workflowId}/cron-schedules`))));
52
+ server.tool("create_cron_schedule", "Schedule a workflow to run on a cron expression.", {
53
+ workflowId: z.string().describe("The workflow's id."),
54
+ triggerId: z
55
+ .string()
56
+ .describe("The id of the trigger node in the workflow document."),
57
+ cronExpr: z
58
+ .string()
59
+ .describe('The cron expression, e.g. "0 9 * * 1-5" for weekdays at 09:00.'),
60
+ timezone: z
61
+ .string()
62
+ .optional()
63
+ .describe('IANA timezone, e.g. "Europe/Brussels". Defaults to UTC.'),
64
+ enabled: z.boolean().optional().describe("Defaults to true."),
65
+ }, async ({ workflowId, triggerId, cronExpr, timezone, enabled }) => guard(async () => jsonResult(await client.post(`/api/v1/workflows/${workflowId}/cron-schedules`, {
66
+ triggerId,
67
+ cronExpr,
68
+ ...(timezone ? { timezone } : {}),
69
+ ...(enabled === undefined ? {} : { enabled }),
70
+ }))));
71
+ server.tool("delete_cron_schedule", "Delete a cron schedule. HARD delete — the row is removed and cannot be " +
72
+ "restored. The workflow stops running on this schedule immediately.", {
73
+ scheduleId: z.string().describe("The cron schedule's id."),
74
+ confirm: CONFIRM,
75
+ }, async ({ scheduleId }) => guard(async () => {
76
+ await client.del(`/api/v1/cron-schedules/${scheduleId}`);
77
+ return jsonResult({ deleted: true, scheduleId });
78
+ }));
79
+ // ---- Conditional triggers ---------------------------------------------
80
+ server.tool("list_conditional_triggers", "List a workflow's conditional triggers — an agent evaluates a condition " +
81
+ "on an interval and starts the workflow when it holds.", { workflowId: z.string().describe("The workflow's id.") }, async ({ workflowId }) => guard(async () => jsonResult(await client.get(`/api/v1/workflows/${workflowId}/conditional-triggers`))));
82
+ server.tool("create_conditional_trigger", "Create a conditional trigger on a workflow: an agent checks `conditionText` " +
83
+ "every `repeatIntervalMinutes` and fires the workflow when it is met.", {
84
+ workflowId: z.string().describe("The workflow's id."),
85
+ triggerId: z
86
+ .string()
87
+ .describe("The id of the trigger node in the workflow document."),
88
+ agentId: z.string().describe("The agent that evaluates the condition."),
89
+ conditionText: z
90
+ .string()
91
+ .min(1)
92
+ .max(2000)
93
+ .describe("The condition, in plain language."),
94
+ repeatIntervalMinutes: z
95
+ .number()
96
+ .int()
97
+ .min(5)
98
+ .max(10080)
99
+ .describe("How often to re-check, in minutes (5 to 10080)."),
100
+ enabled: z.boolean().optional().describe("Defaults to true."),
101
+ }, async ({ workflowId, triggerId, agentId, conditionText, repeatIntervalMinutes, enabled }) => guard(async () => jsonResult(await client.post(`/api/v1/workflows/${workflowId}/conditional-triggers`, {
102
+ triggerId,
103
+ agentId,
104
+ conditionText,
105
+ repeatIntervalMinutes,
106
+ ...(enabled === undefined ? {} : { enabled }),
107
+ }))));
108
+ server.tool("update_conditional_trigger", "Change a conditional trigger's condition, interval, agent, or enabled flag. " +
109
+ "Send only what you are changing.", {
110
+ triggerId: z.string().describe("The conditional trigger's id."),
111
+ conditionText: z.string().min(1).max(2000).optional(),
112
+ repeatIntervalMinutes: z.number().int().min(5).max(10080).optional(),
113
+ agentId: z.string().optional(),
114
+ enabled: z.boolean().optional(),
115
+ }, async ({ triggerId, ...fields }) => guard(async () => {
116
+ const body = Object.fromEntries(Object.entries(fields).filter(([, v]) => v !== undefined));
117
+ return jsonResult(await client.patch(`/api/v1/conditional-triggers/${triggerId}`, body));
118
+ }));
119
+ server.tool("delete_conditional_trigger", "Delete a conditional trigger. HARD delete — the row is removed and cannot " +
120
+ "be restored.", {
121
+ triggerId: z.string().describe("The conditional trigger's id."),
122
+ confirm: CONFIRM,
123
+ }, async ({ triggerId }) => guard(async () => {
124
+ await client.del(`/api/v1/conditional-triggers/${triggerId}`);
125
+ return jsonResult({ deleted: true, triggerId });
126
+ }));
127
+ }
128
+ //# sourceMappingURL=triggers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triggers.js","sourceRoot":"","sources":["../../src/tools/triggers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,+EAA+E;AAC/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AC5B,4EAA4E;QAC1E,cAAc,EAChB;QACE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;QAC/D,OAAO,EAAE,OAAO;KACjB,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CACtB,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,MAAM,MAAM,CAAC,GAAG,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;QAC9D,OAAO,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Validation and inspection verbs — check work before requesting publish.
3
+ *
4
+ * All four routes are stateless: they take a document or a code fragment and
5
+ * return a verdict without touching stored state. That makes them safe to call
6
+ * as often as the agent likes, and they are the cheapest way to close the
7
+ * authoring loop (draft → validate → fix → request_publish).
8
+ */
9
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
+ import type { AxonityClient } from "../client.js";
11
+ export declare function registerValidationTools(server: McpServer, client: AxonityClient): void;
12
+ export declare function registerApprovalTools(server: McpServer, client: AxonityClient): void;
13
+ export declare function registerExecutionTools(server: McpServer, client: AxonityClient): void;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Validation and inspection verbs — check work before requesting publish.
3
+ *
4
+ * All four routes are stateless: they take a document or a code fragment and
5
+ * return a verdict without touching stored state. That makes them safe to call
6
+ * as often as the agent likes, and they are the cheapest way to close the
7
+ * authoring loop (draft → validate → fix → request_publish).
8
+ */
9
+ import { z } from "zod";
10
+ import { guard, jsonResult } from "./result.js";
11
+ export function registerValidationTools(server, client) {
12
+ server.tool("validate_workflow", "Check a workflow document for structural and schema problems. Returns " +
13
+ "`launchable` plus an `issues` list (each with code, message, severity, " +
14
+ "stepIds, edgeIds). STATELESS: it validates the document you pass, does " +
15
+ "not read or write the stored workflow, so read-only service tokens can call it. " +
16
+ "It does NOT verify that referenced agents or tools exist. Call it after " +
17
+ "apply_workflow_mutations " +
18
+ "and before request_publish_workflow.", {
19
+ document: z
20
+ .record(z.unknown())
21
+ .describe("The workflow document to validate (as returned by read_workflow)."),
22
+ }, async ({ document }) => guard(async () => jsonResult(await client.post("/api/v1/workflows/validate", { document }))));
23
+ server.tool("analyze_workflow_reachable_outputs", "List the outputs a given step can read — i.e. what upstream steps make " +
24
+ "available to it. Use it to bind a step's inputs to real upstream outputs " +
25
+ "instead of guessing field names. Stateless, and safe for read-only service tokens.", {
26
+ document: z.record(z.unknown()).describe("The workflow document."),
27
+ stepId: z.string().describe("The step whose reachable inputs you want."),
28
+ }, async ({ document, stepId }) => guard(async () => jsonResult(await client.post("/api/v1/workflows/reachable-outputs", { document, stepId }))));
29
+ server.tool("validate_tool_code", "Check Python tool code for syntax errors and banned patterns before " +
30
+ "saving it on a tool. Returns `valid` plus `errors` (line, column, " +
31
+ "message, severity, functionName). Stateless and safe for read-only service " +
32
+ "tokens.", {
33
+ imports: z
34
+ .string()
35
+ .optional()
36
+ .describe("The import block, as one string. Defaults to empty."),
37
+ functions: z
38
+ .array(z.object({
39
+ name: z.string().describe("Function name."),
40
+ code: z.string().describe("Full function source."),
41
+ }))
42
+ .describe("The functions to check (max 20)."),
43
+ classes: z
44
+ .array(z.object({
45
+ name: z.string().describe("Class name."),
46
+ code: z.string().describe("Full class source."),
47
+ }))
48
+ .optional()
49
+ .describe("Optional classes to check (max 20)."),
50
+ }, async ({ imports, functions, classes }) => guard(async () => jsonResult(await client.post("/api/v1/tools/validate-code", {
51
+ imports: imports ?? "",
52
+ functions,
53
+ ...(classes ? { classes } : {}),
54
+ }))));
55
+ server.tool("format_tool_code", "Format Python tool code with Black and return the formatted source. " +
56
+ "Stateless and safe for read-only service tokens — it does not save anything.", { code: z.string().describe("The Python source to format.") }, async ({ code }) => guard(async () => jsonResult(await client.post("/api/v1/tools/format-code", { code }))));
57
+ }
58
+ export function registerApprovalTools(server, client) {
59
+ server.tool("list_publish_approvals", "List this tenant's publish approvals and their status — how you find out " +
60
+ "whether a request_publish_* was approved or rejected. Optionally filter " +
61
+ "by status, and page through with limit/offset. Approving and rejecting " +
62
+ "are human-only actions in Axonity; no tool can do them.", {
63
+ status: z
64
+ .enum(["pending", "approved", "rejected"])
65
+ .optional()
66
+ .describe("Filter by status. Omit for all."),
67
+ limit: z.number().int().min(1).max(200).optional().describe("Default 50."),
68
+ offset: z.number().int().min(0).optional().describe("Default 0."),
69
+ }, async ({ status, limit, offset }) => guard(async () => jsonResult(await client.get("/api/v1/publish-approvals", { status, limit, offset }))));
70
+ server.tool("get_publish_approval", "Read one publish approval by id — lets you poll a specific request rather " +
71
+ "than re-fetching the whole list.", { approvalId: z.string().describe("The approval's id, from request_publish_* or list_publish_approvals.") }, async ({ approvalId }) => guard(async () => jsonResult(await client.get(`/api/v1/publish-approvals/${approvalId}`))));
72
+ }
73
+ export function registerExecutionTools(server, client) {
74
+ server.tool("execute_tool", "Run tool code directly, without saving it — the way to test a tool you're " +
75
+ "authoring before create_tool/update_tool. Returns stdout/stderr, the " +
76
+ "result, and a typed errorType (timeout/memory/import/runtime/validation) " +
77
+ "on failure. Pass toolId to run against an already-saved tool's context.", {
78
+ imports: z.string().optional().describe("The import block. Defaults to empty."),
79
+ functions: z
80
+ .array(z.object({ name: z.string(), code: z.string() }))
81
+ .describe("The functions to run (max 20)."),
82
+ classes: z
83
+ .array(z.object({ name: z.string(), code: z.string() }))
84
+ .optional()
85
+ .describe("Optional classes (max 20)."),
86
+ inputParams: z
87
+ .record(z.unknown())
88
+ .optional()
89
+ .describe("Parameters passed into the entry-point function."),
90
+ timeout: z.number().int().min(1).max(120).optional().describe("Seconds. Default 30."),
91
+ toolId: z.string().optional().describe("An existing tool id to run in context of."),
92
+ }, async ({ imports, functions, classes, inputParams, timeout, toolId }) => guard(async () => jsonResult(await client.post("/api/v1/tools/execute", {
93
+ imports: imports ?? "",
94
+ functions,
95
+ ...(classes ? { classes } : {}),
96
+ ...(inputParams ? { inputParams } : {}),
97
+ ...(timeout ? { timeout } : {}),
98
+ ...(toolId ? { toolId } : {}),
99
+ }))));
100
+ server.tool("execute_stored_connector", "Test-run an ALREADY-SAVED connector by its tool id — the backend loads its " +
101
+ "stored authConfig and decrypts the real secret server-side; nothing " +
102
+ "credential-shaped ever passes through this tool or through you. Takes " +
103
+ "only input parameters, nothing else — there is no way to point this at a " +
104
+ "URL or auth config of your choosing (that admin-only, body-supplied form " +
105
+ "exists on the backend precisely so a client like this one can never reach " +
106
+ "it, since it would otherwise let a caller exfiltrate a decrypted secret).", {
107
+ toolId: z.string().describe("The connector's tool id — must already be saved."),
108
+ inputParams: z
109
+ .record(z.unknown())
110
+ .optional()
111
+ .describe("Parameters for the connector call."),
112
+ }, async ({ toolId, inputParams }) => guard(async () => jsonResult(await client.post(`/api/v1/tools/${toolId}/execute-connector`, {
113
+ ...(inputParams ? { inputParams } : {}),
114
+ }))));
115
+ }
116
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/tools/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,UAAU,uBAAuB,CACrC,MAAiB,EACjB,MAAqB;IAErB,MAAM,CAAC,IAAI,CACT,mBAAmB,EACnB,wEAAwE;QACtE,yEAAyE;QACzE,yEAAyE;QACzE,kFAAkF;QAClF,0EAA0E;QAC1E,2BAA2B;QAC3B,sCAAsC,EACxC;QACE,QAAQ,EAAE,CAAC;aACR,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aACnB,QAAQ,CAAC,mEAAmE,CAAC;KACjF,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CACrB,KAAK,CAAC,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,CAAC,CAAC,EAAE,CAAC;KAC9B,CAAC,CACH,CACF,CACJ,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,6EAA6E;QAC3E,sEAAsE;QACtE,wEAAwE;QACxE,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5E,2EAA2E,EAC7E;QACE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;QAC/E,WAAW,EAAE,CAAC;aACX,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;aACnB,QAAQ,EAAE;aACV,QAAQ,CAAC,oCAAoC,CAAC;KAClD,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,CAChC,KAAK,CAAC,KAAK,IAAI,EAAE,CACf,UAAU,CACR,MAAM,MAAM,CAAC,IAAI,CAAC,iBAAiB,MAAM,oBAAoB,EAAE;QAC7D,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxC,CAAC,CACH,CACF,CACJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Version history, rollback, and version-level delete/restore.
3
+ *
4
+ * Two different identifiers appear in these routes and confusing them silently
5
+ * 404s:
6
+ * - `version` — an INTEGER checkpoint number (1, 2, 3 …), used to read one.
7
+ * - `versionId` — the UUID of the version row, used to restore/delete it.
8
+ *
9
+ * There are also two unrelated things both called "restore" here:
10
+ * - `restore_<entity>_version` — roll the DRAFT back to an old,
11
+ * still-live version. Takes `expectedVersion` in the body.
12
+ * - `restore_deleted_<entity>_version` — undo a DELETED version row coming
13
+ * back into history. No body — a restore must never lose to a stale-version
14
+ * guard.
15
+ *
16
+ * The published snapshot also lives in two places depending on the entity
17
+ * family: `/{id}/published` for workflow/agent/tool/flow, `/{id}/versions/published`
18
+ * for the memory entities (including output_schema and prompt_snippet, which
19
+ * gained full versioning alongside them). `publishedPath` selects the right one.
20
+ *
21
+ * Only entities that actually expose `/versions*` get these verbs.
22
+ */
23
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
24
+ import type { AxonityClient } from "../client.js";
25
+ export interface VersionedEntity {
26
+ /** Tool noun, e.g. "workflow". */
27
+ singular: string;
28
+ /** REST collection path, e.g. "/api/v1/workflows". */
29
+ basePath: string;
30
+ /**
31
+ * Where the published snapshot lives.
32
+ * `"entity"` → `/{id}/published` (workflow, agent, tool)
33
+ * `"versions"` → `/{id}/versions/published` (skill, policy, reference_doc, persona)
34
+ */
35
+ publishedPath: "entity" | "versions";
36
+ }
37
+ export declare function registerVersionTools(server: McpServer, client: AxonityClient, { singular, basePath, publishedPath }: VersionedEntity): void;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Version history, rollback, and version-level delete/restore.
3
+ *
4
+ * Two different identifiers appear in these routes and confusing them silently
5
+ * 404s:
6
+ * - `version` — an INTEGER checkpoint number (1, 2, 3 …), used to read one.
7
+ * - `versionId` — the UUID of the version row, used to restore/delete it.
8
+ *
9
+ * There are also two unrelated things both called "restore" here:
10
+ * - `restore_<entity>_version` — roll the DRAFT back to an old,
11
+ * still-live version. Takes `expectedVersion` in the body.
12
+ * - `restore_deleted_<entity>_version` — undo a DELETED version row coming
13
+ * back into history. No body — a restore must never lose to a stale-version
14
+ * guard.
15
+ *
16
+ * The published snapshot also lives in two places depending on the entity
17
+ * family: `/{id}/published` for workflow/agent/tool/flow, `/{id}/versions/published`
18
+ * for the memory entities (including output_schema and prompt_snippet, which
19
+ * gained full versioning alongside them). `publishedPath` selects the right one.
20
+ *
21
+ * Only entities that actually expose `/versions*` get these verbs.
22
+ */
23
+ import { z } from "zod";
24
+ import { guard, jsonResult } from "./result.js";
25
+ /** A required literal — an agent cannot satisfy it by filling in a default. */
26
+ const CONFIRM = z
27
+ .literal(true)
28
+ .describe("Must be true. Acknowledges you understand this is destructive.");
29
+ export function registerVersionTools(server, client, { singular, basePath, publishedPath }) {
30
+ server.tool(`list_${singular}_versions`, `List a ${singular}'s version history — checkpoints (every save) and major ` +
31
+ `versions (named releases). Use this to find the versionId you need for ` +
32
+ `restore_${singular}_version.`, {
33
+ id: z.string().describe(`The ${singular}'s id.`),
34
+ type: z
35
+ .enum(["checkpoint", "major", "all"])
36
+ .optional()
37
+ .describe("Which kind to list. Defaults to all."),
38
+ limit: z.number().int().min(1).max(200).optional().describe("Default 50."),
39
+ offset: z.number().int().min(0).optional().describe("Default 0."),
40
+ }, async ({ id, type, limit, offset }) => guard(async () => jsonResult(await client.get(`${basePath}/${id}/versions`, { type, limit, offset }))));
41
+ server.tool(`read_${singular}_version`, `Read one historical version of a ${singular} by its CHECKPOINT NUMBER (an ` +
42
+ `integer like 3, from the \`version\` field in list_${singular}_versions) — ` +
43
+ `not by its versionId. Use it to diff two versions before rolling back.`, {
44
+ id: z.string().describe(`The ${singular}'s id.`),
45
+ version: z
46
+ .number()
47
+ .int()
48
+ .describe("The integer checkpoint number, e.g. 3."),
49
+ }, async ({ id, version }) => guard(async () => jsonResult(await client.get(`${basePath}/${id}/versions/${version}`))));
50
+ server.tool(`restore_${singular}_version`, `Roll a ${singular}'s DRAFT back to an earlier version. Takes the versionId ` +
51
+ `(a UUID from list_${singular}_versions), NOT the checkpoint number. The ` +
52
+ `current draft is snapshotted first, so this is itself undoable. It ` +
53
+ `changes only the draft — what is live stays live until a human approves a ` +
54
+ `new publish.`, {
55
+ id: z.string().describe(`The ${singular}'s id.`),
56
+ versionId: z.string().describe("The version row's UUID."),
57
+ expectedVersion: z
58
+ .number()
59
+ .int()
60
+ .describe("The draft version you last read — 409 if stale."),
61
+ }, async ({ id, versionId, expectedVersion }) => guard(async () => jsonResult(await client.post(`${basePath}/${id}/versions/${versionId}/restore`, {
62
+ expectedVersion,
63
+ }))));
64
+ server.tool(`delete_${singular}_version`, `Permanently remove one entry from a ${singular}'s version history. The ` +
65
+ `working draft and the currently published version are protected and ` +
66
+ `cannot be targeted this way. Recoverable with ` +
67
+ `restore_deleted_${singular}_version until it is purged for good.`, {
68
+ id: z.string().describe(`The ${singular}'s id.`),
69
+ versionId: z.string().describe("The version row's UUID (not the checkpoint number)."),
70
+ confirm: CONFIRM,
71
+ }, async ({ id, versionId }) => guard(async () => {
72
+ await client.del(`${basePath}/${id}/versions/${versionId}`);
73
+ return jsonResult({ deleted: true, id, versionId });
74
+ }));
75
+ server.tool(`list_deleted_${singular}_versions`, `List a ${singular}'s deleted version rows — restore candidates for ` +
76
+ `restore_deleted_${singular}_version. Deleted version numbers stay ` +
77
+ `reserved (not reused), so gaps in the numbering are expected, not corruption.`, { id: z.string().describe(`The ${singular}'s id.`) }, async ({ id }) => guard(async () => jsonResult(await client.get(`${basePath}/${id}/versions/deleted`))));
78
+ server.tool(`restore_deleted_${singular}_version`, `Undo delete_${singular}_version — bring a removed version row back into ` +
79
+ `history. This does NOT change the current draft (unlike ` +
80
+ `restore_${singular}_version); it only makes the row visible/restorable ` +
81
+ `again. Takes no version check.`, {
82
+ id: z.string().describe(`The ${singular}'s id.`),
83
+ versionId: z
84
+ .string()
85
+ .describe(`The version row's UUID, from list_deleted_${singular}_versions.`),
86
+ }, async ({ id, versionId }) => guard(async () => jsonResult(await client.post(`${basePath}/${id}/versions/${versionId}/restore-deleted`))));
87
+ server.tool(`name_${singular}_major_version`, `Give a ${singular}'s major version a name — label a release so it is easy to ` +
88
+ `find in history. Targets a MAJOR version by its integer number (from ` +
89
+ `list_${singular}_versions), not a checkpoint or a versionId. This only ` +
90
+ `renames; it does not create, publish, or roll anything back.`, {
91
+ id: z.string().describe(`The ${singular}'s id.`),
92
+ majorVersion: z
93
+ .number()
94
+ .int()
95
+ .describe("The major version's integer number, e.g. 2."),
96
+ name: z.string().min(1).max(255).describe("The new name for that major version."),
97
+ }, async ({ id, majorVersion, name }) => guard(async () => jsonResult(await client.patch(`${basePath}/${id}/versions/major/${majorVersion}`, { name }))));
98
+ server.tool(`read_${singular}_published`, `Read the LIVE published version of a ${singular} — what the runtime ` +
99
+ `actually uses, as opposed to the draft that read_${singular} returns. ` +
100
+ `Diff the two to see what a pending publish would change.`, { id: z.string().describe(`The ${singular}'s id.`) }, async ({ id }) => guard(async () => jsonResult(await client.get(publishedPath === "entity"
101
+ ? `${basePath}/${id}/published`
102
+ : `${basePath}/${id}/versions/published`))));
103
+ }
104
+ //# sourceMappingURL=versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.js","sourceRoot":"","sources":["../../src/tools/versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,OAAO,GAAG,CAAC;KACd,OAAO,CAAC,IAAI,CAAC;KACb,QAAQ,CAAC,gEAAgE,CAAC,CAAC;AAe9E,MAAM,UAAU,oBAAoB,CAClC,MAAiB,EACjB,MAAqB,EACrB,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAmB;IAEtD,MAAM,CAAC,IAAI,CACT,QAAQ,QAAQ,WAAW,EAC3B,UAAU,QAAQ,0DAA0D;QAC1E,yEAAyE;QACzE,WAAW,QAAQ,WAAW,EAChC;QACE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,QAAQ,QAAQ,CAAC;QAChD,IAAI,EAAE,CAAC;aACJ,IAAI,CAAC,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;aACpC,QAAQ,EAAE;aACV,QAAQ,CAAC,sCAAsC,CAAC;QACnD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC;QAC1E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EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,CACnC,KAAK,CAAC,KAAK,IAAI,EAAE,CACf,UAAU,CACR,MAAM,MAAM,CAAC,KAAK,CAChB,GAAG,QAAQ,IAAI,EAAE,mBAAmB,YAAY,EAAE,EAClD,EAAE,IAAI,EAAE,CACT,CACF,CACF,CACJ,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,QAAQ,QAAQ,YAAY,EAC5B,wCAAwC,QAAQ,sBAAsB;QACpE,oDAAoD,QAAQ,YAAY;QACxE,0DAA0D,EAC5D,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,QAAQ,QAAQ,CAAC,EAAE,EACpD,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CACf,KAAK,CAAC,KAAK,IAAI,EAAE,CACf,UAAU,CACR,MAAM,MAAM,CAAC,GAAG,CACd,aAAa,KAAK,QAAQ;QACxB,CAAC,CAAC,GAAG,QAAQ,IAAI,EAAE,YAAY;QAC/B,CAAC,CAAC,GAAG,QAAQ,IAAI,EAAE,qBAAqB,CAC3C,CACF,CACF,CACJ,CAAC;AACJ,CAAC"}
@@ -5,7 +5,29 @@
5
5
  * backend-authoritative model the Studio uses), never by replacing the whole
6
6
  * document. The backend applies and validates the commands and returns the new
7
7
  * authoritative document + version.
8
+ *
9
+ * The backend route applies exactly ONE mutation per call — `POST
10
+ * /workflows/{id}/mutations` takes `{ type, payload, expectedVersion }` and there
11
+ * is no batch route. This tool keeps a batch-shaped signature (an agent thinks in
12
+ * whole edits, not round-trips) and sequences the calls itself, threading the
13
+ * version returned by call N into call N+1.
14
+ *
15
+ * Because the sequence is not a transaction, a failure at index k leaves the
16
+ * mutations before it applied. The error says how many landed and which one
17
+ * failed so the caller can re-read and resume rather than blindly retry — a
18
+ * retry from the top would re-apply the successful prefix.
8
19
  */
9
20
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
21
  import type { AxonityClient } from "../client.js";
22
+ /**
23
+ * Split one command into the `{ type, payload }` pair the backend expects.
24
+ *
25
+ * Accepts both the explicit form (`{ type, payload: {...} }`) and the flat form
26
+ * (`{ type, ...args }`), because an agent writing these by hand produces either
27
+ * and the difference is not meaningful to it.
28
+ */
29
+ export declare function toMutationBody(mutation: Record<string, unknown>, index: number): {
30
+ type: string;
31
+ payload: Record<string, unknown>;
32
+ };
11
33
  export declare function registerWorkflowMutations(server: McpServer, client: AxonityClient): void;