@statelyai/mcp 0.4.0 → 0.5.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/LICENSE +6 -0
- package/README.md +25 -97
- package/dist/index.cjs +62 -156
- package/dist/index.d.cts +2 -16
- package/dist/index.d.mts +2 -16
- package/dist/index.mjs +62 -156
- package/package.json +10 -5
package/LICENSE
CHANGED
|
@@ -19,3 +19,9 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Exception: the state-machine graph interface embedded in the MCP App resource
|
|
24
|
+
`ui://stately/visualize-machine.html` is proprietary to Stately Software, Inc.
|
|
25
|
+
No rights are granted to use, copy, modify, distribute, host, sublicense, or
|
|
26
|
+
create derivative works from that interface except under a separate written
|
|
27
|
+
agreement with Stately Software, Inc.
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Stately MCP
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Validate, execute, explore, compare, convert, and visualize state machines from
|
|
4
|
+
an MCP-compatible agent.
|
|
4
5
|
|
|
5
6
|
## Connect
|
|
6
7
|
|
|
@@ -78,36 +79,14 @@ Most tools accept a machine config object or a source document. Conversion
|
|
|
78
79
|
supports XState, SCXML, XGraph, and D2. Validation also supports JSON, YAML, and
|
|
79
80
|
Mermaid.
|
|
80
81
|
|
|
81
|
-
## `create_state_machine`
|
|
82
|
-
|
|
83
|
-
<!-- create_state_machine registration from src/server.ts and convert/visualize response contracts -->
|
|
84
|
-
|
|
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.
|
|
91
|
-
|
|
92
|
-
<details>
|
|
93
|
-
<summary>Summary: create and visualize a machine</summary>
|
|
94
|
-
|
|
95
|
-
```text
|
|
96
|
-
Make a state machine representing an order checkout flow.
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
The agent calls Stately with complete XState v5 source. Omit `visualization` to
|
|
100
|
-
render PNG diagrams, customize it with `direction` or `parentNodeIds`, or set it
|
|
101
|
-
to `false` to return only the normalized XState source.
|
|
102
|
-
|
|
103
|
-
</details>
|
|
104
|
-
|
|
105
82
|
## `validate_machine`
|
|
106
83
|
|
|
107
84
|
<!-- validate_machine registration from src/server.ts and validate response contract -->
|
|
108
85
|
|
|
109
|
-
Checks
|
|
110
|
-
|
|
86
|
+
Checks machine syntax and graph structure deterministically. It does not
|
|
87
|
+
typecheck or execute XState source; use `simulate_machine` and
|
|
88
|
+
`generate_graph_paths` to verify runtime behavior. A successful response
|
|
89
|
+
contains `ok` and an `issues` array.
|
|
111
90
|
|
|
112
91
|
<details>
|
|
113
92
|
<summary>Summary: validate a machine</summary>
|
|
@@ -279,8 +258,10 @@ createMachine({
|
|
|
279
258
|
<!-- generate_graph_paths registration from src/server.ts and graph-paths response contract -->
|
|
280
259
|
|
|
281
260
|
Generates shortest or simple paths through a machine. The response includes
|
|
282
|
-
the event steps
|
|
283
|
-
returns at most five paths per call.
|
|
261
|
+
the event steps, state and transition coverage, total path count, truncation,
|
|
262
|
+
and execution metadata. Stately MCP returns at most five paths per call.
|
|
263
|
+
XState source uses native traversal in an isolated sandbox; other formats are
|
|
264
|
+
converted to structural XGraph first.
|
|
284
265
|
|
|
285
266
|
<details>
|
|
286
267
|
<summary>Summary: generate shortest paths</summary>
|
|
@@ -306,8 +287,9 @@ createMachine({
|
|
|
306
287
|
<!-- simulate_machine registration from src/server.ts and simulate response contract -->
|
|
307
288
|
|
|
308
289
|
Runs up to 100 events through a machine and returns a step-by-step trace of
|
|
309
|
-
states, context,
|
|
310
|
-
|
|
290
|
+
states, context, selected action names, and execution metadata. XState source
|
|
291
|
+
runs native transition logic in an isolated sandbox. Structural inputs report
|
|
292
|
+
normalization explicitly.
|
|
311
293
|
|
|
312
294
|
<details>
|
|
313
295
|
<summary>Summary: simulate events</summary>
|
|
@@ -332,11 +314,12 @@ createMachine({
|
|
|
332
314
|
|
|
333
315
|
<!-- visualize_machine registration from src/server.ts and visualize response contract -->
|
|
334
316
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
317
|
+
MCP Apps hosts render an interactive, read-only graph with hierarchy drill-in,
|
|
318
|
+
breadcrumbs, selection utilities, pan/zoom, and viewport keyboard shortcuts.
|
|
319
|
+
Other image-capable clients receive one PNG fallback per parent node. Structured
|
|
320
|
+
content includes the raw XGraph plus hierarchy metadata without duplicating
|
|
321
|
+
image data. Use `parentNodeIds` to limit PNG fallback levels; omit it to render
|
|
322
|
+
every parent with direct child states.
|
|
340
323
|
|
|
341
324
|
Each returned image uses the MCP `ImageContent` shape:
|
|
342
325
|
|
|
@@ -363,61 +346,6 @@ createMachine({
|
|
|
363
346
|
|
|
364
347
|
</details>
|
|
365
348
|
|
|
366
|
-
## `analyze_machine`
|
|
367
|
-
|
|
368
|
-
<!-- analyze_machine registration from src/server.ts and analyze response contract -->
|
|
369
|
-
|
|
370
|
-
Combines deterministic checks with AI review. Provide optional intent to assess
|
|
371
|
-
the machine against its expected behavior. The response contains issues and may
|
|
372
|
-
include suggested fixes. Use `validate_machine` when only deterministic checks
|
|
373
|
-
are needed.
|
|
374
|
-
|
|
375
|
-
<details>
|
|
376
|
-
<summary>Summary: analyze intended behavior</summary>
|
|
377
|
-
|
|
378
|
-
```text
|
|
379
|
-
Use Stately to check that STOP reaches a final state and playback cannot restart:
|
|
380
|
-
|
|
381
|
-
createMachine({
|
|
382
|
-
id: 'player',
|
|
383
|
-
initial: 'paused',
|
|
384
|
-
states: {
|
|
385
|
-
paused: { on: { PLAY: 'playing' } },
|
|
386
|
-
playing: { on: { STOP: 'stopped' } },
|
|
387
|
-
stopped: { type: 'final' }
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
</details>
|
|
393
|
-
|
|
394
|
-
## `generate_test_code`
|
|
395
|
-
|
|
396
|
-
<!-- generate_test_code registration and generateTestCode implementation from src/server.ts -->
|
|
397
|
-
|
|
398
|
-
Generates a runnable Vitest file with one test per generated path. Each test
|
|
399
|
-
sends the path's events and asserts its final state. Guards and actions are
|
|
400
|
-
stubbed.
|
|
401
|
-
|
|
402
|
-
<details>
|
|
403
|
-
<summary>Summary: generate Vitest tests</summary>
|
|
404
|
-
|
|
405
|
-
```text
|
|
406
|
-
Use Stately to generate Vitest tests for the shortest paths through this machine:
|
|
407
|
-
|
|
408
|
-
createMachine({
|
|
409
|
-
id: 'player',
|
|
410
|
-
initial: 'paused',
|
|
411
|
-
states: {
|
|
412
|
-
paused: { on: { PLAY: 'playing' } },
|
|
413
|
-
playing: { on: { STOP: 'stopped' } },
|
|
414
|
-
stopped: { type: 'final' }
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
</details>
|
|
420
|
-
|
|
421
349
|
## `extract_machines_from_code`
|
|
422
350
|
|
|
423
351
|
<!-- 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 -->
|
|
@@ -455,12 +383,12 @@ These tools read hosted Stately projects and machines through the server-owned
|
|
|
455
383
|
`/api/v1` resource contract. They are separate from the workspace tools
|
|
456
384
|
(`list_machines`, `get_machine`), which read local files.
|
|
457
385
|
|
|
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.
|
|
386
|
+
| Tool | Reads |
|
|
387
|
+
| ------------------------------- | ----------------------------------------------------------------- |
|
|
388
|
+
| `list_stately_projects` | The hosted projects the caller can access. |
|
|
389
|
+
| `get_stately_project` | One project, with its current project version id and machine ids. |
|
|
390
|
+
| `list_stately_project_machines` | The machines in a project. |
|
|
391
|
+
| `get_stately_machine` | One machine, with its definition. |
|
|
464
392
|
|
|
465
393
|
Inputs take a `projectId` or `machineId`, never a project version id.
|
|
466
394
|
|