@sanity/workflow-mcp 0.25.0 → 0.27.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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { ActionParam } from "@sanity/workflow-engine";
2
2
  import type { AutonomyVerdict } from "@sanity/workflow-engine";
3
+ import { DeclaredExecutionContext } from "@sanity/workflow-engine";
3
4
  import type { Diagnosis } from "@sanity/workflow-engine";
4
- import type { Engine } from "@sanity/workflow-engine";
5
+ import { Engine } from "@sanity/workflow-engine";
5
6
  import type { ExecutorClassification } from "@sanity/workflow-engine";
6
7
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
8
  import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
@@ -12,10 +13,24 @@ import type { StuckCause } from "@sanity/workflow-engine";
12
13
  import type { SuggestedRemediation } from "@sanity/workflow-engine";
13
14
  import type { TelemetryLogger } from "@sanity/telemetry";
14
15
  import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
16
+ import { WorkflowClient } from "@sanity/workflow-engine";
15
17
  import type { WorkflowDefinition } from "@sanity/workflow-engine";
16
18
  import { WorkflowResource } from "@sanity/workflow-engine";
19
+ import { WorkflowTelemetryLogger } from "@sanity/workflow-engine";
17
20
  import { ZodRawShape } from "zod/v3";
18
21
 
22
+ /**
23
+ * An engine bound to one workflow environment. `executionContext` is the host's
24
+ * declaration of the advisory "via what" stamped on history entries; identity is
25
+ * whatever token backs the supplied client.
26
+ */
27
+ export declare function createWorkflowEngine(args: {
28
+ address: WorkflowEnvironmentAddress;
29
+ client: WorkflowClient;
30
+ executionContext?: DeclaredExecutionContext;
31
+ telemetry?: WorkflowTelemetryLogger;
32
+ }): Engine;
33
+
19
34
  export declare const deployWorkflowDefinitionTool: WorkflowToolDef;
20
35
 
21
36
  export declare const diagnoseWorkflowTool: WorkflowToolDef;
@@ -56,7 +71,7 @@ export declare const LIST_WORKFLOW_TAGS_DESCRIPTION: string;
56
71
  * registration site because the address vocabulary refers to it in prose a model
57
72
  * reads — a rename must not leave that prose naming a tool nobody registers.
58
73
  */
59
- export declare const LIST_WORKFLOW_TAGS_TOOL_NAME = "list_workflow_tags";
74
+ export declare const LIST_WORKFLOW_TAGS_TOOL_NAME = "workflows_list_tags";
60
75
 
61
76
  export declare const listWorkflowDefinitionsTool: WorkflowToolDef;
62
77
 
@@ -70,7 +85,7 @@ export declare const listWorkflowInstancesTool: WorkflowToolDef;
70
85
  * {@link ProjectedAutomation} instead — the engine fires it, no caller can.
71
86
  */
72
87
  export declare interface ProjectedActionVerdict {
73
- /** Action name — what to pass to `fire_workflow_action` as `action`. */
88
+ /** Action name — what to pass to `workflows_fire_action` as `action`. */
74
89
  action: string;
75
90
  /** Human label for the action, if the definition provides one. */
76
91
  title?: string;
@@ -78,14 +93,14 @@ export declare interface ProjectedActionVerdict {
78
93
  allowed: boolean;
79
94
  /** When `allowed` is false, a short reason describing why. */
80
95
  disabledReason?: string;
81
- /** The action's declared params — what `fire_workflow_action`'s `params` object must
96
+ /** The action's declared params — what `workflows_fire_action`'s `params` object must
82
97
  * satisfy (each entry names the param and whether it is required). Absent
83
98
  * when the action declares none. */
84
99
  params?: ActionParam[];
85
100
  }
86
101
 
87
102
  export declare interface ProjectedActivity {
88
- /** Activity name — what to pass to `fire_workflow_action` as `activity`. */
103
+ /** Activity name — what to pass to `workflows_fire_action` as `activity`. */
89
104
  activity: string;
90
105
  /** Human label, if provided. */
91
106
  title?: string;
@@ -126,10 +141,10 @@ export declare interface ProjectedActivity {
126
141
  /**
127
142
  * One cascade-fired (`when`) action, narrated as automation: the engine fires
128
143
  * it on its own the moment the trigger holds — it is never invocable via
129
- * `fire_workflow_action`, so it must not read as a button.
144
+ * `workflows_fire_action`, so it must not read as a button.
130
145
  */
131
146
  export declare interface ProjectedAutomation {
132
- /** The cascade-fired action's name. Not accepted by `fire_workflow_action`. */
147
+ /** The cascade-fired action's name. Not accepted by `workflows_fire_action`. */
133
148
  action: string;
134
149
  /** Human label, if provided. */
135
150
  title?: string;
@@ -142,12 +157,12 @@ export declare interface ProjectedAutomation {
142
157
  }
143
158
 
144
159
  /**
145
- * Result of `get_workflow_definition` — one deployed version's content.
160
+ * Result of `workflows_get_definition` — one deployed version's content.
146
161
  * `definition` is the stored (desugared) form with the document envelope
147
162
  * stripped — valid input for the validate/deploy tools as-is (their parse
148
163
  * accepts stored form; parts of it, e.g. resolved guard `idRefs`, are NOT
149
164
  * valid authoring shape): modify it and redeploy via
150
- * `deploy_workflow_definition` to mint the next version.
165
+ * `workflows_deploy_definition` to mint the next version.
151
166
  */
152
167
  export declare interface ProjectedDefinition {
153
168
  /** Definition `name`. */
@@ -160,12 +175,12 @@ export declare interface ProjectedDefinition {
160
175
 
161
176
  /**
162
177
  * One deployed workflow definition, latest version only — what
163
- * `list_workflow_definitions` returns per name. Deploys are create-only
178
+ * `workflows_list_definitions` returns per name. Deploys are create-only
164
179
  * (every deploy mints a new version), but the LLM only ever needs the
165
180
  * head: it's the version `startInstance` picks by default.
166
181
  */
167
182
  export declare interface ProjectedDefinitionSummary {
168
- /** Definition `name` — the value `list_workflow_instances` filters on. */
183
+ /** Definition `name` — the value `workflows_list_instances` filters on. */
169
184
  name: string;
170
185
  /** Human-readable workflow title. */
171
186
  title: string;
@@ -189,7 +204,7 @@ export declare interface ProjectedDefinitionSummary {
189
204
  * LLM-friendly, so `remediations` passes through verbatim rather than
190
205
  * being re-projected. The verbose `WorkflowEvaluation` the engine returns
191
206
  * alongside the diagnosis is dropped — per-activity action detail belongs to
192
- * {@link ProjectedInstanceState} (get_workflow_state), not here.
207
+ * {@link ProjectedInstanceState} (workflows_get_state), not here.
193
208
  */
194
209
  export declare interface ProjectedDiagnosis {
195
210
  /** Sanity document id of the diagnosed workflow.instance. */
@@ -344,7 +359,7 @@ export declare type ValidateDefinitionResult =
344
359
  };
345
360
 
346
361
  /**
347
- * Result of `validate_workflow_definition`. `results` pairs positionally with
362
+ * Result of `workflows_validate_definition`. `results` pairs positionally with
348
363
  * the input `definitions`; `valid` is true only when every definition passed.
349
364
  */
350
365
  export declare interface ValidateDefinitionsResult {
@@ -354,6 +369,14 @@ export declare interface ValidateDefinitionsResult {
354
369
 
355
370
  export declare const validateWorkflowDefinitionTool: WorkflowToolDef;
356
371
 
372
+ /**
373
+ * What the model is told about the `tag` parameter itself. Lives here beside the
374
+ * tool name it cites because every host declares this parameter in its own
375
+ * vocabulary — a host that paraphrases weakens a caveat that was tuned
376
+ * deliberately, and nothing warns you it has drifted.
377
+ */
378
+ export declare const WORKFLOW_TAG_DESCRIPTION: string;
379
+
357
380
  export declare const WORKFLOW_TOOLS: readonly WorkflowToolDef[];
358
381
 
359
382
  /**
@@ -366,12 +389,64 @@ export declare function workflowAddressFromInput(
366
389
  input: unknown,
367
390
  ): WorkflowEnvironmentAddress;
368
391
 
392
+ /**
393
+ * The client configuration engine traffic requires, layered over whatever base
394
+ * config the host supplies — its requester, its headers, its `apiHost`. Engine
395
+ * policy deliberately wins over that base: a host's own defaults are tuned for
396
+ * content reads, not for the engine's documents.
397
+ *
398
+ * The base is generic rather than `@sanity/client`'s `ClientConfig` so that a
399
+ * host resolving a different copy of that package still type-checks — the same
400
+ * reason the engine states its client structurally. The host's own config type
401
+ * flows through to the result, which stays assignable to it.
402
+ */
403
+ export declare function workflowClientConfig<Base extends object>(args: {
404
+ resource: WorkflowResource;
405
+ token?: string;
406
+ /** The host's own client config. Pass `{}` if it has no opinions to preserve. */
407
+ base: Base;
408
+ }): Base & WorkflowClientPolicy & WorkflowResourceAddressing;
409
+
410
+ /**
411
+ * The client settings engine traffic pins, whatever base a host layers them over.
412
+ * Literal types so the result stays assignable to a host's own client config.
413
+ */
414
+ declare interface WorkflowClientPolicy {
415
+ apiVersion: string;
416
+ useCdn: false;
417
+ requestTagPrefix: string;
418
+ perspective: "published";
419
+ }
420
+
369
421
  /** Where one tool call reads/writes workflow data: resource + tag. */
370
422
  export declare interface WorkflowEnvironmentAddress {
371
423
  workflowResource: WorkflowResource;
372
424
  tag: string;
373
425
  }
374
426
 
427
+ /**
428
+ * One rendering of a failed tool call, shared by every host. A structured
429
+ * error's stable `kind` leads the text so the model can branch on the failure
430
+ * without parsing the human-readable message — a host that re-derives this
431
+ * prefix drifts from the wording the descriptions and evals were tuned against.
432
+ */
433
+ export declare function workflowErrorText(error: unknown): string;
434
+
435
+ /**
436
+ * How the resulting config names the environment. Exactly one branch is
437
+ * populated — a dataset target carries the classic pair, anything else carries
438
+ * the resource — but both are stated optional so the result assigns to a host's
439
+ * client config without narrowing the union first. The unused branch is removed
440
+ * from the result so a leftover from the host's base cannot survive the merge:
441
+ * `@sanity/client` prefers `resource` over `projectId`/`dataset` whenever both
442
+ * are present, which would otherwise silently address the wrong environment.
443
+ */
444
+ declare interface WorkflowResourceAddressing {
445
+ projectId?: string;
446
+ dataset?: string;
447
+ resource?: WorkflowResource;
448
+ }
449
+
375
450
  /**
376
451
  * Everything a tool call needs from its host: the engine to operate on.
377
452
  * Identity is the token behind the engine's client (`/users/me`) — a host
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { LIST_WORKFLOW_TAGS_DESCRIPTION, LIST_WORKFLOW_TAGS_TOOL_NAME, WORKFLOW_TOOLS, deployWorkflowDefinitionTool, diagnoseWorkflowTool, fireActionTool, getWorkflowAuthoringGuideTool, getWorkflowDefinitionTool, getWorkflowStateTool, listWorkflowDefinitionsTool, listWorkflowInstancesTool, registerWorkflowTools, startWorkflowTool, toolInputJsonSchema, validateWorkflowDefinitionTool, workflowAddressFromInput } from "./_chunks-es/index.js";
1
+ import { LIST_WORKFLOW_TAGS_DESCRIPTION, LIST_WORKFLOW_TAGS_TOOL_NAME, WORKFLOW_TAG_DESCRIPTION, WORKFLOW_TOOLS, createWorkflowEngine, deployWorkflowDefinitionTool, diagnoseWorkflowTool, fireActionTool, getWorkflowAuthoringGuideTool, getWorkflowDefinitionTool, getWorkflowStateTool, listWorkflowDefinitionsTool, listWorkflowInstancesTool, registerWorkflowTools, startWorkflowTool, toolInputJsonSchema, validateWorkflowDefinitionTool, workflowAddressFromInput, workflowClientConfig, workflowErrorText } from "./_chunks-es/index.js";
2
2
 
3
- export { LIST_WORKFLOW_TAGS_DESCRIPTION, LIST_WORKFLOW_TAGS_TOOL_NAME, WORKFLOW_TOOLS, deployWorkflowDefinitionTool, diagnoseWorkflowTool, fireActionTool, getWorkflowAuthoringGuideTool, getWorkflowDefinitionTool, getWorkflowStateTool, listWorkflowDefinitionsTool, listWorkflowInstancesTool, registerWorkflowTools, startWorkflowTool, toolInputJsonSchema, validateWorkflowDefinitionTool, workflowAddressFromInput };
3
+ export { LIST_WORKFLOW_TAGS_DESCRIPTION, LIST_WORKFLOW_TAGS_TOOL_NAME, WORKFLOW_TAG_DESCRIPTION, WORKFLOW_TOOLS, createWorkflowEngine, deployWorkflowDefinitionTool, diagnoseWorkflowTool, fireActionTool, getWorkflowAuthoringGuideTool, getWorkflowDefinitionTool, getWorkflowStateTool, listWorkflowDefinitionsTool, listWorkflowInstancesTool, registerWorkflowTools, startWorkflowTool, toolInputJsonSchema, validateWorkflowDefinitionTool, workflowAddressFromInput, workflowClientConfig, workflowErrorText };
package/dist/stdio.js CHANGED
@@ -2,52 +2,14 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
 
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
 
5
- import { ENGINE_API_VERSION, clientConfigFromResource, resourceGdr, createEngine, deployedTagsGroq, parseResourceGdr, datasetResourceParts, EXECUTION_KINDS } from "@sanity/workflow-engine";
5
+ import { deployedTagsGroq, parseResourceGdr, datasetResourceParts, EXECUTION_KINDS } from "@sanity/workflow-engine";
6
6
 
7
- import { LIST_WORKFLOW_TAGS_TOOL_NAME, workflowAddressFields, LIST_WORKFLOW_TAGS_DESCRIPTION, withToolTelemetry, registerWorkflowTools, workflowAddressFromInput, createMcpTelemetry } from "./_chunks-es/index.js";
7
+ import { LIST_WORKFLOW_TAGS_TOOL_NAME, workflowAddressFields, LIST_WORKFLOW_TAGS_DESCRIPTION, withToolTelemetry, clientForResource, registerWorkflowTools, workflowAddressFromInput, createMcpTelemetry, createEngineCache } from "./_chunks-es/index.js";
8
8
 
9
- import { createClient } from "@sanity/client";
10
-
11
- var version = "0.25.0", packageJson = {
9
+ var version = "0.27.0", packageJson = {
12
10
  version: version
13
11
  };
14
12
 
15
- function clientForResource(args) {
16
- const {resource: resource, token: token, apiHost: apiHost} = args;
17
- return createClient({
18
- token: token,
19
- apiHost: apiHost,
20
- apiVersion: ENGINE_API_VERSION,
21
- useCdn: !1,
22
- requestTagPrefix: "sanity.workflows-mcp",
23
- ...clientConfigFromResource(resource)
24
- });
25
- }
26
-
27
- function createEngineCache({token: token, apiHost: apiHost, executionContext: executionContext, telemetry: telemetry}) {
28
- const engines = /* @__PURE__ */ new Map;
29
- return ({workflowResource: workflowResource, tag: tag}) => {
30
- const key = `${resourceGdr(workflowResource)} ${tag}`, existing = engines.get(key);
31
- if (existing !== void 0) return existing;
32
- const engine = createEngine({
33
- client: clientForResource({
34
- resource: workflowResource,
35
- token: token,
36
- apiHost: apiHost
37
- }),
38
- workflowResource: workflowResource,
39
- tag: tag,
40
- ...executionContext !== void 0 ? {
41
- executionContext: executionContext
42
- } : {},
43
- ...telemetry !== void 0 ? {
44
- telemetry: telemetry
45
- } : {}
46
- });
47
- return engines.set(key, engine), engine;
48
- };
49
- }
50
-
51
13
  function requireEnv(env, name) {
52
14
  const value = env[name];
53
15
  if (typeof value != "string" || value === "") throw new Error(`Missing required environment variable: ${name}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/workflow-mcp",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "MCP server exposing Sanity workflow tools to agents — operate running workflow instances and author new definitions.",
5
5
  "keywords": [
6
6
  "agent",
@@ -62,14 +62,14 @@
62
62
  "@types/node": "^24.12.4",
63
63
  "vitest": "^4.1.8",
64
64
  "zod": "^4.4.3",
65
- "@sanity/workflow-engine": "0.25.0",
66
- "@sanity/workflow-engine-test": "0.25.0",
67
- "@sanity/workflow-examples": "0.10.4"
65
+ "@sanity/workflow-engine": "0.27.0",
66
+ "@sanity/workflow-engine-test": "0.27.0",
67
+ "@sanity/workflow-examples": "0.10.6"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@modelcontextprotocol/sdk": "^1.29.0",
71
71
  "zod": "^3.25.28 || ^4",
72
- "@sanity/workflow-engine": "0.25.0"
72
+ "@sanity/workflow-engine": "0.27.0"
73
73
  },
74
74
  "engines": {
75
75
  "node": ">=20"