@craft-ts/mcp 0.8.5 → 0.8.6
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/content/docs-index.json +5 -0
- package/package.json +2 -2
package/content/docs-index.json
CHANGED
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"title": "Live page MCP",
|
|
45
45
|
"body": "# Live page MCP\n\nThe running development tab publishes its named controls. A coding agent fills,\nclicks, and inspects **that** page — no second browser, no DOM reverse-engineering.\n\n**Use it when** a Cursor agent must drive or inspect the `ng serve` tab you\nalready have open.\n**Not when** you are writing Craft away from a running app — use\n[`@craft-ts/mcp`](/resources/ai-agents) for docs and skills. **Not when** you\nwant to mutate a primitive without the UI — use the `registry.*` tools on the\nsame local MCP.\n\n## Connect the local MCP\n\nThe tool lives on `@craft-ts/function-registry-mcp`, not on the published\n`@craft-ts/mcp` docs server. From the craft-ts repo:\n\n```sh\nnpm run registry:mcp\n```\n\nPoint Cursor at that stdio server. It already listens on `ws://127.0.0.1:3333`\nfor the demo tab. Each tab keeps a stable `clientId` in `sessionStorage`.\n\n## One ready tab\n\nEach tab has a `clientId` in `sessionStorage`. Duplicating a tab copies it; the\nbroker assigns a new id (`hello/ok`) so the two tabs do not fight.\n\nOmit `clientId` when **exactly one tab is `ready`**. A ghost `reloading` card\n(HMR, F5) does not count. Two `ready` tabs → pass `clientId` from\n`registry.clients` (id, status, url). Never pick “latest”. The error is\n`Multiple ready page clients; clientId is required. Available clients: <id> ready <url>, <id> ready <url>`.\nZero ready with several ghosts is\n`No ready page client. Reloading: <id> (last url <url>), <id> (last url <url>)`.\nZero cards is `page client is not connected`.\n\nClosing the tab sends `page/goodbye`; the card is dropped. Opening a new tab is\na new id. If `page client \"<id>\" is not connected`, call `registry.clients` and\nretry without id when a single ready remains.\n\nClosing without goodbye (crash) looks like reload for up to 20s.\n\n## One tool: `page`\n\nOmit `act` to read the current surface. The broker **always asks the live tab**\n— a Craft `value:` that changed without a DOM mutation is still current. Pass\n`act` to run a batch, then receive the **new** state in the same round-trip.\n\nDefault `detail` is `\"controls\"`: the named interactive surface (id, role,\naccessible name, value, enabled, index, and `track` when the node is inside\n`forNode`). Pass `detail: \"dom-styles\"` only to debug layout or CSS — it is large\nand opt-in.\n\n`id` is the literal local name from the helper:\n\n\n\nThat name is unique in the app graph\n(`assertInteractiveElementNamed`). The renderer writes `data-craft-name=\"save\"`.\nDo not prefix it with the component name. When `forNode` repeats the same id, pass\n`match.index` or `match.track`.\n\n## Fill, click, goto, ready\n\n`act: [{ \"goto\": \"/login-form\" }]` navigates in the tab (Craft router).\nThe WebSocket stays up. Prefer `goto` over clicking `navLink` — every nav item\nshares that id. Paths like `/login-form` and full URLs both work.\n\nA `fill` sets the control and dispatches one `input` or `change` (then blur), so\n`CraftFieldDirective` validation and touched state run. A click is `act` with\nonly `id`. The batch runs in order and stops on the first error.\n\nWhile `ng serve` rebuilds, the socket drops but the broker **keeps** the client\ncard. `page` waits until the tab is `ready` again (up to `timeoutMs`, default\n20s). You do not poll.\n\n## See also\n\n- [Coding agents](/resources/ai-agents) — which MCP to use for docs vs the live tab\n- [Architecture rules](/guide/testing/architecture) — unique interactive names\n- [Observability](/guide/advanced/observability) — primitive traces, not DOM\n"
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
"path": "/guide/ai/send-context-webhook",
|
|
49
|
+
"title": "Send context to an AI webhook",
|
|
50
|
+
"body": "# Send context to an AI webhook\n\n`provideSendContextToAi` is copy-only by default. Configure an endpoint to make\nthe default chat send its generated context directly from the browser:\n\n\n\nThe primary action is then `Send`. The request is a JSON `POST` with this\nversioned shape:\n\n```json\n{\n \"version\": 1,\n \"prompt\": \"# Instruction\\nInvestigate this screen\",\n \"instruction\": \"Investigate this screen\",\n \"selectedElements\": [],\n \"events\": [],\n \"snapshot\": [],\n \"captures\": {},\n \"component\": {\n \"hostName\": \"OrdersPage\",\n \"tagList\": [\"component:OrdersPage#1\"],\n \"coords\": { \"x\": 120, \"y\": 80 },\n \"outerHTML\": \"<section>…</section>\"\n }\n}\n```\n\n`prompt` is the Markdown generated from the other fields and the selected\noptions. `component` is omitted when the chat was opened from the launcher\nwithout a captured component. `captures.component` and `captures.page` are\npresent only when their corresponding DOM/CSS options were selected. Timeline\nevents generated by the webhook itself are excluded from later payloads.\n\n## Success and failure\n\nAny `2xx` response is successful, including `200`, `202`, and `204`. Network\nfailures, timeouts, and non-`2xx` responses show an error in the chat. The\nfailed request is never copied automatically. `Retry` sends the exact same\npayload again, while `Copy payload` copies that same JSON only after the user\nasks for it. `Copy JSON` remains the separate timeline export action.\n\nWithout `endpoint`, the primary action remains `Copy prompt` and no webhook\nrequest is made.\n\n## Browser and security constraints\n\nThe endpoint must allow the browser application's origin through CORS, and it\nmust accept a JSON `POST`. The URL is application configuration shipped to the\nbrowser: it is not a secret. This first version has no configurable headers or\nsecret storage, so use a protected intermediary when the receiving agent needs\nauthentication.\n\n## Complete integration example\n\nThe frontend can point at a same-origin proxy or an explicitly CORS-enabled\nagent gateway:\n\n```ts\n// app.config.ts\nimport { provideSendContextToAi } from '@craft-ts/component';\n\nexport const providers = [\n provideSendContextToAi({\n endpoint: 'https://agent.example.com/hooks/context',\n }),\n];\n```\n\nThe gateway validates the version, forwards the Markdown prompt and structured\ncontext to the agent, and acknowledges the webhook with any `2xx` status:\n\n```ts\n// agent-gateway.ts (illustrative Express endpoint)\napp.post('/hooks/context', express.json(), async (request, response) => {\n const payload = request.body as {\n version: number;\n prompt: string;\n instruction: string;\n selectedElements: unknown[];\n events: unknown[];\n snapshot: unknown[];\n captures: Record<string, unknown>;\n };\n\n if (payload.version !== 1 || typeof payload.prompt !== 'string') {\n response.status(400).json({ error: 'Unsupported context payload' });\n return;\n }\n\n await agent.run({\n prompt: payload.prompt,\n context: {\n instruction: payload.instruction,\n selectedElements: payload.selectedElements,\n events: payload.events,\n snapshot: payload.snapshot,\n captures: payload.captures,\n },\n });\n response.sendStatus(202);\n});\n```\n"
|
|
51
|
+
},
|
|
47
52
|
{
|
|
48
53
|
"path": "/guide/app/abstract-services",
|
|
49
54
|
"title": "Abstract services",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@craft-ts/mcp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "MCP server, Agent Skills, and LLM files for coding agents using @craft-ts/core",
|
|
5
5
|
"author": "Romain Geffrault",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "vitest run --config vitest.config.mts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@craft-ts/dev-tools": "^0.8.
|
|
38
|
+
"@craft-ts/dev-tools": "^0.8.6",
|
|
39
39
|
"@modelcontextprotocol/sdk": "1.26.0",
|
|
40
40
|
"zod": "4.3.6"
|
|
41
41
|
},
|