@xstate/webmcp 0.1.0-beta.0 → 0.1.0-beta.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 +16 -3
- package/dist/declarations/src/webmcp.d.ts +3 -3
- package/dist/xstate-webmcp.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4,9 +4,7 @@ Expose XState actors and `@xstate/store` stores as [WebMCP](https://webmachinele
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npm install @xstate/webmcp
|
|
9
|
-
```
|
|
7
|
+
`@xstate/webmcp` is available in the XState source repository. It has no npm release yet. To try it from source, follow the [TodoMVC workspace example](https://github.com/statelyai/xstate/blob/next/examples/todomvc-webmcp-react/README.md#run-it).
|
|
10
8
|
|
|
11
9
|
The package has no runtime dependencies. It works with any `xstate` actor or `@xstate/store` store.
|
|
12
10
|
|
|
@@ -84,6 +82,21 @@ createWebMCP(todoStore, {
|
|
|
84
82
|
// Tools: send_todo_add, send_todo_remove, get_state
|
|
85
83
|
```
|
|
86
84
|
|
|
85
|
+
`toolName` receives the event schema as its second argument, so a name can depend on the schema:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { createWebMCP, toToolName } from '@xstate/webmcp';
|
|
89
|
+
|
|
90
|
+
createWebMCP(todoStore, {
|
|
91
|
+
events: ['todo.*'],
|
|
92
|
+
toolName: (eventType, schema) =>
|
|
93
|
+
schema === todoStore.schemas?.events?.['todo.add']
|
|
94
|
+
? 'add_todo'
|
|
95
|
+
: toToolName(eventType)
|
|
96
|
+
});
|
|
97
|
+
// Tools: add_todo, todo_remove, get_state
|
|
98
|
+
```
|
|
99
|
+
|
|
87
100
|
`createWebMCP` throws if two tools end up with the same name, for example when both `todo.add` and `todo_add` are exposed.
|
|
88
101
|
|
|
89
102
|
### Overrides
|
|
@@ -107,10 +107,10 @@ export interface WebMCPOptions<TTarget extends WebMCPTarget> {
|
|
|
107
107
|
*/
|
|
108
108
|
events: EventDescriptor<WebMCPEventType<TTarget>> | readonly EventDescriptor<WebMCPEventType<TTarget>>[];
|
|
109
109
|
/**
|
|
110
|
-
* Maps an event type
|
|
111
|
-
* turns `'checkout.confirm'` into `'checkout_confirm'`.
|
|
110
|
+
* Maps an event type and its event schema to the tool name. Defaults to
|
|
111
|
+
* `toToolName`, which turns `'checkout.confirm'` into `'checkout_confirm'`.
|
|
112
112
|
*/
|
|
113
|
-
toolName?: (eventType: WebMCPEventType<TTarget
|
|
113
|
+
toolName?: (eventType: WebMCPEventType<TTarget>, schema: StandardSchemaV1) => string;
|
|
114
114
|
/** Prepended to every tool name as `${prefix}_${name}`. */
|
|
115
115
|
prefix?: string;
|
|
116
116
|
/** Per-event tool names, descriptions and annotations. */
|
package/dist/xstate-webmcp.js
CHANGED
|
@@ -310,7 +310,7 @@ function createWebMCP(target, options) {
|
|
|
310
310
|
if (!description) {
|
|
311
311
|
throw new Error(`Event "${eventType}" needs a description to become a tool. Describe its schema (for example \`z.object({...}).describe('...')\`) or set \`overrides["${eventType}"].description\`.`);
|
|
312
312
|
}
|
|
313
|
-
const name = toolName(override.name ?? mapToolName(eventType), `event "${eventType}"`);
|
|
313
|
+
const name = toolName(override.name ?? mapToolName(eventType, schema), `event "${eventType}"`);
|
|
314
314
|
const title = override.title ?? (typeof inputSchema.title === 'string' ? inputSchema.title : undefined);
|
|
315
315
|
entries.push({
|
|
316
316
|
eventType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xstate/webmcp",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
4
|
"description": "Expose XState actors and @xstate/store stores as WebMCP tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xstate",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"tools"
|
|
13
13
|
],
|
|
14
14
|
"author": "David Khourshid <davidkpiano@gmail.com>",
|
|
15
|
-
"homepage": "https://github.com/statelyai/xstate/tree/
|
|
15
|
+
"homepage": "https://github.com/statelyai/xstate/tree/next/packages/xstate-webmcp#readme",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"zod": "^4.4.3",
|
|
37
|
-
"xstate": "^
|
|
38
|
-
"
|
|
37
|
+
"@xstate/store": "^5.0.0-alpha.8",
|
|
38
|
+
"xstate": "^6.0.0-beta.8"
|
|
39
39
|
}
|
|
40
40
|
}
|