@statelyai/mcp 0.3.2 → 0.4.1

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/README.md CHANGED
@@ -83,11 +83,11 @@ Mermaid.
83
83
  <!-- create_state_machine registration from src/server.ts and convert/visualize response contracts -->
84
84
 
85
85
  Creates a new XState v5 machine from a natural-language request. The connected
86
- agent authors the XState source, then Stately normalizes it and returns the
87
- source. Visualization defaults on and returns native PNG image blocks because a
88
- diagram usually makes generated behavior easier to verify. Set `visualization`
89
- to `false` only for code-only requests, clients that cannot display images, or
90
- machines where a diagram adds no useful information.
86
+ agent authors the XState source, then Stately validates and returns that source
87
+ without rewriting it. Visualization defaults on and returns native PNG image
88
+ blocks because a diagram usually makes generated behavior easier to verify. Set
89
+ `visualization` to `false` only for code-only requests, clients that cannot
90
+ display images, or machines where a diagram adds no useful information.
91
91
 
92
92
  <details>
93
93
  <summary>Summary: create and visualize a machine</summary>
@@ -98,7 +98,7 @@ Make a state machine representing an order checkout flow.
98
98
 
99
99
  The agent calls Stately with complete XState v5 source. Omit `visualization` to
100
100
  render PNG diagrams, customize it with `direction` or `parentNodeIds`, or set it
101
- to `false` to return only the normalized XState source.
101
+ to `false` to return only the validated, authored XState source.
102
102
 
103
103
  </details>
104
104
 
@@ -420,10 +420,11 @@ createMachine({
420
420
 
421
421
  ## `extract_machines_from_code`
422
422
 
423
- <!-- extract_machines_from_code registration from src/server.ts -->
423
+ <!-- extract_machines_from_code registration from src/server.ts, API route from packages/editor/src/app/api/v1/code/extract-machines/route.ts, and parser from packages/graph-tools/src/xstateSource.ts -->
424
424
 
425
- Parses XState source code and returns the extracted machine as an XGraph
426
- document.
425
+ Statically extracts every XState machine config from JavaScript or TypeScript.
426
+ The parser infers XState v5 or v6 structurally; pass `xstateVersion` only to
427
+ override inference. It does not execute source or require a resource provider.
427
428
 
428
429
  <details>
429
430
  <summary>Summary: extract a machine from TypeScript</summary>
@@ -446,8 +447,63 @@ export const player = createMachine({
446
447
 
447
448
  </details>
448
449
 
449
- All Stately MCP tools are registered as read-only, non-destructive, idempotent,
450
- and closed-world.
450
+ ## Hosted resource tools
451
+
452
+ <!-- resource tool registrations from src/resourceTools.ts -->
453
+
454
+ These tools read hosted Stately projects and machines through the server-owned
455
+ `/api/v1` resource contract. They are separate from the workspace tools
456
+ (`list_machines`, `get_machine`), which read local files.
457
+
458
+ | Tool | Reads |
459
+ | ------------------------------- | ----------------------------------------------------------------- |
460
+ | `list_stately_projects` | The hosted projects the caller can access. |
461
+ | `get_stately_project` | One project, with its current project version id and machine ids. |
462
+ | `list_stately_project_machines` | The machines in a project. |
463
+ | `get_stately_machine` | One machine, with its definition. |
464
+
465
+ Inputs take a `projectId` or `machineId`, never a project version id.
466
+
467
+ Every call needs a credential: the MCP host supplies it and the bearer token is
468
+ forwarded to the resource provider. Calls without one fail with
469
+ `unauthenticated`, and deployments with no resource provider fail with
470
+ `capability_disabled`. Errors use the canonical resource envelope,
471
+ `{ error: { code, message, issues?, retryable? } }`.
472
+
473
+ These tools are read-only by policy. Create, update, and delete resource tools
474
+ are deliberately absent.
475
+
476
+ <details>
477
+ <summary>Summary: list the machines in a hosted project</summary>
478
+
479
+ ```text
480
+ Use Stately to list the machines in project project-id.
481
+ ```
482
+
483
+ ```json
484
+ { "machines": [{ "machineId": "machine-id", "name": "checkout" }] }
485
+ ```
486
+
487
+ </details>
488
+
489
+ All Stately MCP tools are registered as read-only, non-destructive, and
490
+ idempotent. Machine tools are closed-world; the hosted resource tools are
491
+ open-world.
492
+
493
+ ## Tool-call observation
494
+
495
+ <!-- onToolCall option and event types from src/server.ts and src/toolCallObserver.ts -->
496
+
497
+ Hosts can pass `onToolCall` to `registerStatelyMcpTools` or
498
+ `createStatelyMcpServer`. It receives a content-free completion event with the
499
+ tool name, outcome, duration, and stable error code when available. Arguments,
500
+ machine source, and results are never included. Input and output validation
501
+ failures are reported as errors. Configure the observer before registering any
502
+ other tools on the same `McpServer`.
503
+
504
+ The observer is absent by default. Its failures do not affect tool results, and
505
+ its promises are not awaited; serverless hosts should schedule delivery with
506
+ their platform lifecycle primitive.
451
507
 
452
508
  ## Self-hosting
453
509