mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
fix: Remove MCP workflow friction (#5974)
## Summary - Make MCP discoverable from the CLI README and expose direct MCP tool calls as restart-free CLI subcommands. - Preserve required discriminator fields in compact MCP SDK schemas and surface the `set-text-content` contract. - Return instance props by default from `inspect-instance` and improve the `list-instances` input hint. - Add a Builder context-menu **Move** submenu as an accessible alternative to drag-and-drop sibling reordering. Companion generated documentation: https://github.com/webstudio-is/webstudio-community/pull/274 ## Technical choices and compatibility - Compact SDK schemas retain required fields only inside root composition branches, avoiding broad schema expansion. - `inspect-instance` now defaults to `props` only; larger styles, bindings, sources, children, and ancestors remain opt-in. - Existing move commands and shortcuts back the new menu, so command behavior stays centralized. - No migrations, fixture inputs, generated fixture bundles, or generated API contracts are affected. ## Todo - [x] Add direct CLI MCP discovery and restart guidance. - [x] Preserve discriminated-union requirements for SDK clients. - [x] Improve instance inspection and input diagnostics. - [x] Add accessible menu-based instance movement. - [x] Add regression coverage and verify fail/pass behavior. - [x] Run targeted tests, typechecks, lint, package-boundary, and generated-doc checks. - [ ] Deferred: run `pnpm evaluations` after separate explicit approval, as required by repository policy. ## Verification - `@webstudio-is/project-build`: 172 targeted tests passed. - `@webstudio-is/protocol`: 8 targeted tests passed; typecheck passed. - `@webstudio-is/builder`: 8 targeted tests passed; typecheck passed. - CLI and project-build typechecks passed. - Root lint, package-boundary check, generated-doc check, and diff checks passed. - New and modified regression tests were demonstrated failing before their fixes and passing afterward. ## Known limitations Synthetic drag-and-drop behavior is unchanged. The new menu and existing keyboard shortcuts provide the automatable and accessible reordering path. Agent evaluations were not run because explicit approval was not provided.
This commit is contained in:
1 parent
aefe532a73
commit
92084aeea3
29 files changed
+561
-231
No files matched your search
@@ -53,15 +53,15 @@ Commands:
|
||||
- webstudio man llm --json
|
||||
- MCP tool: meta.index {}
|
||||
- MCP tool: meta.guide {"brief":"Create a pricing page"}
|
||||
- MCP tool: meta.get_more_tools {"brief":"update-styles"}
|
||||
- MCP tool: meta.get-more-tools {"brief":"update-styles"}
|
||||
- webstudio mcp list-resources
|
||||
- webstudio mcp read-resource webstudio://project/guide
|
||||
- webstudio mcp read-resource webstudio://project/expressions
|
||||
|
||||
Notes:
|
||||
|
||||
- Use `webstudio schema mcp` for a compact machine-readable MCP tool overview. Add `--verbose` or use focused `meta.get_more_tools` calls only when exact input schemas are needed.
|
||||
- Use focused MCP tools for discovery first: `meta.index`, `meta.guide`, `meta.get_more_tools`, `components.list`, `components.summary`, `components.search`, `components.get`, `templates.list`, and `templates.get`. Protocol clients can use `resources/list` and `resources/read`; shell agents can use `webstudio mcp list-resources` and `webstudio mcp read-resource <uri>`. Read longer resources such as `webstudio://project/tools` and `webstudio://project/components` only when focused tools are insufficient.
|
||||
- Use `webstudio schema mcp` for a compact machine-readable MCP tool overview. Add `--verbose` or use focused `meta.get-more-tools` calls only when exact input schemas are needed.
|
||||
- Use focused MCP tools for discovery first: `meta.index`, `meta.guide`, `meta.get-more-tools`, `components.list`, `components.summary`, `components.search`, `components.get`, `templates.list`, and `templates.get`. Protocol clients can use `resources/list` and `resources/read`; shell agents can use `webstudio mcp list-resources` and `webstudio mcp read-resource <uri>`. Read longer resources such as `webstudio://project/tools` and `webstudio://project/components` only when focused tools are insufficient.
|
||||
- `components.summary` returns counts by default; request `{"detail":"components","limit":20}` for paginated entries. Registry list tools return compact metadata, while `components.get` and `templates.get` return focused full details.
|
||||
- Read `webstudio://project/expressions` before authoring unfamiliar computed text, prop bindings, resource expressions, actions, or Collection item bindings.
|
||||
- From a shell, call one MCP tool with the shortcut form `webstudio <tool> '<json>'`, for example `webstudio components.summary`. The explicit equivalent is `webstudio mcp single-op-call <tool> '<json>'`. Use `--input-file` for large payloads.
|
||||
@@ -408,7 +408,7 @@ Commands:
|
||||
|
||||
Commands:
|
||||
|
||||
- MCP tool: insert-fragment {"parentInstanceId":"<instanceId>","fragment":"<ws.element ws:tag=\"section\" ws:style={css`padding: 32px;`}><ws.element ws:tag=\"h2\">Product OS</ws.element><radix.Switch><radix.SwitchThumb /></radix.Switch></ws.element>"}
|
||||
- MCP tool: insert-fragment {"parentInstanceId":"<instanceId>","fragment":"<ws.element ws:tag='section' ws:style={css`padding: 32px;`}><ws.element ws:tag='h2'>Product OS</ws.element><radix.Switch><radix.SwitchThumb /></radix.Switch></ws.element>"}
|
||||
- MCP tool: insert-component {"parentInstanceId":"<instanceId>","component":"@webstudio-is/sdk-components-react-radix:Switch"}
|
||||
- MCP tool: insert-component {"parentInstanceId":"<instanceId>","component":"Form"}
|
||||
|
||||
@@ -419,7 +419,7 @@ Notes:
|
||||
- The `ws:` namespace contains specific Webstudio core components; it is not HTML-tag shorthand. Use `<ws.element ws:tag="div">` for a native `div` and `<ws.element ws:tag="form">` for a native form, never `<ws.div>` or `<ws.form>`.
|
||||
- For Webstudio's complete form structure, discover the Form component and insert its automatic template with `insert-component` using component `"Form"`.
|
||||
- MCP receives JSX as a JSON string because MCP arguments are JSON. The CLI converts it locally before the runtime mutation, so the project session receives structured Webstudio data, not JSX source.
|
||||
- In `insert-fragment` JSX, use `ws:style={css\`...\`}`for Webstudio-native CSS, or use React-style object syntax such as`style={{ padding: 24 }}` when that is simpler. Both forms create editable Webstudio style data.
|
||||
- In `insert-fragment` JSX, use ``ws:style={css`...`}`` for Webstudio-native CSS, or use React-style object syntax such as `style={{ padding: 24 }}` when that is simpler. Both forms create editable Webstudio style data.
|
||||
- Do not access host globals or dynamic code APIs in JSX fragments, including `process`, `globalThis`, `eval`, `Function`, or `constructor`.
|
||||
- Use Webstudio prop names such as `class` and `for`; do not use React aliases `className` or `htmlFor`.
|
||||
- Use Webstudio actions for event/action props, for example `onClick={new ActionValue(["event"], expression\`console.log(event)\`)}`. Do not pass JavaScript functions such as `onClick={() => ...}`.
|
||||
@@ -705,9 +705,9 @@ Commands:
|
||||
Commands:
|
||||
|
||||
- MCP tool: create-resource {"resource":{"name":"Posts","method":"get","url":"https://api.example.com/posts","headers":[]}}
|
||||
- MCP tool: create-resource {"resource":{"name":"Posts","method":"get","url":"\"https://api.example.com/posts?tag=\" + filters.tag","headers":[]},"scopeInstanceId":"<instanceId>","dataSourceName":"posts"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Filtered Posts","method":"get","url":"https://api.example.com/posts","searchParams":[{"name":"tag","value":"filters.tag"},{"name":"source","value":{"type":"literal","value":"website"}}],"headers":[{"name":"Authorization","value":"\"Bearer \" + auth.token"}]},"scopeInstanceId":"<instanceId>","dataSourceName":"posts"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Post GraphQL","control":"graphql","method":"post","url":"https://api.example.com/graphql","headers":[{"name":"Content-Type","value":{"type":"literal","value":"application/json"}}],"body":"{ query: \"query Post($slug: String!) { post(slug: $slug) { title } }\", variables: { slug: system.params.slug } }"},"scopeInstanceId":"<instanceId>","dataSourceName":"post"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Posts","method":"get","url":"'https://api.example.com/posts?tag=' + filters.tag","headers":[]},"scopeInstanceId":"<instanceId>","dataSourceName":"posts"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Filtered Posts","method":"get","url":"https://api.example.com/posts","searchParams":[{"name":"tag","value":"filters.tag"},{"name":"source","value":{"type":"literal","value":"website"}}],"headers":[{"name":"Authorization","value":"'Bearer ' + auth.token"}]},"scopeInstanceId":"<instanceId>","dataSourceName":"posts"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Post GraphQL","control":"graphql","method":"post","url":"https://api.example.com/graphql","headers":[{"name":"Content-Type","value":{"type":"literal","value":"application/json"}}],"body":"{ query: 'query Post($slug: String!) { post(slug: $slug) { title } }', variables: { slug: system.params.slug } }"},"scopeInstanceId":"<instanceId>","dataSourceName":"post"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Current Date","control":"system","method":"get","url":"/$resources/current-date","headers":[]},"scopeInstanceId":"<instanceId>","dataSourceName":"currentDate"}
|
||||
|
||||
Notes:
|
||||
@@ -1128,7 +1128,7 @@ Commands:
|
||||
- MCP tool: create-variable {"scopeInstanceId":"<instanceId>","name":"tags","value":{"type":"json","value":["news","product"]}}
|
||||
- MCP tool: create-variable {"scopeInstanceId":"<instanceId>","name":"filters","value":{"type":"json","value":{"tag":"news"}}}
|
||||
- MCP tool: create-resource {"resource":{"name":"Posts","method":"get","url":"https://api.example.com/posts","searchParams":[{"name":"tag","value":"filters.tag"},{"name":"source","value":{"type":"literal","value":"website"}}],"headers":[]},"scopeInstanceId":"<instanceId>","dataSourceName":"posts"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Post GraphQL","control":"graphql","method":"post","url":"https://api.example.com/graphql","headers":[{"name":"Content-Type","value":{"type":"literal","value":"application/json"}}],"body":"{ query: \"query Post($slug: String!) { post(slug: $slug) { title } }\", variables: { slug: system.params.slug } }"},"scopeInstanceId":"<instanceId>","dataSourceName":"post"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Post GraphQL","control":"graphql","method":"post","url":"https://api.example.com/graphql","headers":[{"name":"Content-Type","value":{"type":"literal","value":"application/json"}}],"body":"{ query: 'query Post($slug: String!) { post(slug: $slug) { title } }', variables: { slug: system.params.slug } }"},"scopeInstanceId":"<instanceId>","dataSourceName":"post"}
|
||||
- MCP tool: create-resource {"resource":{"name":"Current Date","control":"system","method":"get","url":"/$resources/current-date","headers":[]},"scopeInstanceId":"<instanceId>","dataSourceName":"currentDate"}
|
||||
- MCP tool: update-resource {"resourceId":"<resourceId>","values":{"url":"https://api.example.com/posts"}}
|
||||
- MCP tool: bind-props {"bindings":"bindings.json contents"}
|
||||
@@ -1145,7 +1145,7 @@ Notes:
|
||||
|
||||
Commands:
|
||||
|
||||
- MCP tool: insert-collection {"parentInstanceId":"<instanceId>","data":{"type":"expression","value":"posts.data.items"},"itemFragment":"<ws.element ws:tag=\"article\"><ws.element ws:tag=\"h2\">{expression`collectionItem.title`}</ws.element></ws.element>"}
|
||||
- MCP tool: insert-collection {"parentInstanceId":"<instanceId>","data":{"type":"expression","value":"posts.data.items"},"itemFragment":"<ws.element ws:tag='article'><ws.element ws:tag='h2'>{expression`collectionItem.title`}</ws.element></ws.element>"}
|
||||
- MCP tool: inspect-instance {"instanceId":"<collectionId>","include":["props","bindings","children"]}
|
||||
|
||||
Notes:
|
||||
@@ -1210,7 +1210,7 @@ Commands:
|
||||
- MCP tool: create-design-token {"tokens":"tokens.json contents"}
|
||||
- MCP tool: define-css-variable {"vars":"vars.json contents"}
|
||||
- MCP tool: list-breakpoints {}
|
||||
- MCP tool: insert-fragment {"parentInstanceId":"<instanceId>","fragment":"<ws.element ws:tag=\"section\"><ws.element ws:tag=\"p\">Section copy</ws.element></ws.element>"}
|
||||
- MCP tool: insert-fragment {"parentInstanceId":"<instanceId>","fragment":"<ws.element ws:tag='section'><ws.element ws:tag='p'>Section copy</ws.element></ws.element>"}
|
||||
- MCP tool: update-styles {"updates":[{"instanceId":"<instanceId>","breakpointId":"<breakpointId-from-list-breakpoints>","property":"padding-left","value":{"type":"unit","unit":"px","value":24}}]}
|
||||
- MCP tool: preview.start {"host":"127.0.0.1","port":5173}
|
||||
- MCP tool: screenshot {"path":"/landing","output":"landing-desktop.png","viewport":{"width":1440,"height":900},"waitUntil":"load","waitForTimeout":250}
|
||||
|
||||
@@ -50,12 +50,12 @@ changing configuration or requiring project access.
|
||||
1. webstudio permissions --json
|
||||
2. For bounded shell workflows, call MCP tools directly through the CLI shortcut, for example `webstudio meta.index` or `webstudio insert-fragment '<json>' --dry-run`. The explicit form `webstudio mcp single-op-call <tool> '<json>'` is equivalent and useful when you need to make the MCP boundary obvious. Use `webstudio mcp run '[{"tool":"components.find","input":{"brief":"button"}}]'` for multiple calls in one shared CLI session. Use a normal JSON file path for large batches. Use long-running `webstudio mcp` only when your environment is a real MCP client. Do not manually send raw JSON-RPC to `webstudio mcp` from a shell or PTY.
|
||||
3. Read MCP `meta.index`, for example `webstudio meta.index`.
|
||||
4. Use focused MCP calls with concrete JSON: `webstudio meta.guide '{"brief":"Create a design system page using every component"}'`, `webstudio meta.get_more_tools '{"tools":["insert-fragment"]}'`, `webstudio components.list '{"source":"all"}'`, `webstudio components.coverage-plan`, `webstudio components.search '{"brief":"radix select"}'`, `webstudio components.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`, `webstudio templates.list`, and `webstudio templates.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`.
|
||||
4. Use focused MCP calls with concrete JSON: `webstudio meta.guide '{"brief":"Create a design system page using every component"}'`, `webstudio meta.get-more-tools '{"tools":["insert-fragment"]}'`, `webstudio components.list '{"source":"all"}'`, `webstudio components.coverage-plan`, `webstudio components.search '{"brief":"radix select"}'`, `webstudio components.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`, `webstudio templates.list`, and `webstudio templates.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`.
|
||||
5. Read overview resources `webstudio://project/tools-overview` or `webstudio://project/components-overview` when useful. Read full resources `webstudio://project/tools` or `webstudio://project/components` only when focused tools are insufficient.
|
||||
6. Pick focused MCP read tool.
|
||||
7. Pick semantic MCP write tool.
|
||||
|
||||
Use `webstudio schema mcp` for a compact MCP tool overview. Add `--verbose` only when exact input schemas for all tools are truly needed; otherwise prefer focused `meta.get_more_tools` and `components.*` calls.
|
||||
Use `webstudio schema mcp` for a compact MCP tool overview. Add `--verbose` only when exact input schemas for all tools are truly needed; otherwise prefer focused `meta.get-more-tools` and `components.*` calls.
|
||||
|
||||
Run these commands from the linked project root. Use the MCP startup status line's absolute root for local files; write temporary scripts and artifacts under `<project root>/.temp`, not under a parent workspace.
|
||||
|
||||
@@ -63,16 +63,25 @@ Monorepo quick path for a simple styled section:
|
||||
|
||||
```sh
|
||||
node packages/cli/local.js mcp single-op-call meta.index
|
||||
node packages/cli/local.js mcp single-op-call meta.get_more_tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js mcp single-op-call insert-fragment '{"parentInstanceId":"parent-id","fragment":"<ws.element ws:tag=\"section\" ws:style={css`padding: 32px; display: grid; gap: 12px;`}><ws.element ws:tag="h2">Launch Kit</ws.element><ws.element ws:tag="p">A focused section created with Webstudio JSX.</ws.element><ws.element ws:tag="button">Get started</ws.element></ws.element>"}' --dry-run
|
||||
node packages/cli/local.js mcp single-op-call meta.get-more-tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js mcp single-op-call insert-fragment --input-file .temp/insert-fragment.json --dry-run
|
||||
```
|
||||
|
||||
The same local shortcut form is shorter and preferred for simple shell steps:
|
||||
Save the readable payload in `.temp/insert-fragment.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"parentInstanceId": "parent-id",
|
||||
"fragment": "<ws.element ws:tag='section' ws:style={css`padding: 32px; display: grid; gap: 12px;`}><ws.element ws:tag='h2'>Launch Kit</ws.element><ws.element ws:tag='p'>A focused section created with Webstudio JSX.</ws.element><ws.element ws:tag='button'>Get started</ws.element></ws.element>"
|
||||
}
|
||||
```
|
||||
|
||||
Single quotes inside the JSX keep the JSON valid without backslash-escaped attributes. The same local shortcut form is shorter and preferred for simple shell steps:
|
||||
|
||||
```sh
|
||||
node packages/cli/local.js meta.index
|
||||
node packages/cli/local.js meta.get_more_tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js insert-fragment '{"parentInstanceId":"parent-id","fragment":"<ws.element ws:tag=\"section\" ws:style={css`padding: 32px; display: grid; gap: 12px;`}><ws.element ws:tag="h2">Launch Kit</ws.element><ws.element ws:tag="p">A focused section created with Webstudio JSX.</ws.element><ws.element ws:tag="button">Get started</ws.element></ws.element>"}' --dry-run
|
||||
node packages/cli/local.js meta.get-more-tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js insert-fragment --input-file .temp/insert-fragment.json --dry-run
|
||||
```
|
||||
|
||||
For this simple path, do not grep source files, dump full MCP resources, or write parser scripts first. Use `list-pages`, `get-page-by-path`, or `list-instances` only to get the target `parentInstanceId`.
|
||||
@@ -400,7 +409,7 @@ For Video Animation, use the registered template via `insert-component` when pos
|
||||
|
||||
Use this process for user requests that change Webstudio content, layout, styles, assets, pages, redirects, resources, or publishing state:
|
||||
|
||||
1. Discover capabilities with `webstudio man --json`, `webstudio schema api`, `webstudio schema mcp`, MCP `meta.index`, `meta.guide`, `meta.get_more_tools`, `components.list`, `components.summary`, `components.coverage-plan`, `components.search`, `components.get`, `templates.list`, and `templates.get`. From a shell, prefer shortcut calls such as `webstudio meta.index` and `webstudio components.search '{"brief":"button"}'` for these focused tool calls; use `webstudio mcp single-op-call` when you need the explicit MCP form. Read full resources such as `webstudio://project/tools` and `webstudio://project/components` only when needed. Do not write scripts to parse full MCP discovery JSON for normal lookup.
|
||||
1. Discover capabilities with `webstudio man --json`, `webstudio schema api`, `webstudio schema mcp`, MCP `meta.index`, `meta.guide`, `meta.get-more-tools`, `components.list`, `components.summary`, `components.coverage-plan`, `components.search`, `components.get`, `templates.list`, and `templates.get`. From a shell, prefer shortcut calls such as `webstudio meta.index` and `webstudio components.search '{"brief":"button"}'` for these focused tool calls; use `webstudio mcp single-op-call` when you need the explicit MCP form. Read full resources such as `webstudio://project/tools` and `webstudio://project/components` only when needed. Do not write scripts to parse full MCP discovery JSON for normal lookup.
|
||||
2. Inspect current project state with semantic reads such as `get-project-settings`, `list-pages`, `get-page-by-path`, `list-instances`, `inspect-instance`, `get-styles`, `list-assets`, `list-breakpoints`, and `snapshot` only when needed. Before changing a project, read `get-project-settings` and follow any non-empty `meta.agentInstructions`. These are shared project instructions, not a place for secrets.
|
||||
3. Mutate the Webstudio project with semantic MCP write tools first. Prefer MCP `insert-fragment` for authored/styled sections, use `insert-component` only for one automatic component template, then `update-text`, `update-props`, `update-styles`, `upload-asset`, `create-page`, and page/project settings tools over raw patches.
|
||||
4. Use `apply-patch` only when no semantic tool covers the required change, and only after reading the latest snapshot/version.
|
||||
@@ -474,7 +483,7 @@ Before authoring unfamiliar expressions, read `webstudio://project/expressions`
|
||||
- Use scoped resources for read data. A GET resource created with `scopeInstanceId`/`dataSourceName` defaults to `exposeAsDataSource:true`, becomes a scoped resource data variable, is generated into the page resource `data` map, and may be loaded while rendering the page. Read the loaded resource result from its wrapper, usually `.data`.
|
||||
- Use prop-bound resources for actions. A resource created without `scopeInstanceId` and bound to a component prop such as Form `action` with `bind-props` and `binding.type: "resource"` becomes an action resource in the page resource `action` map. Use this for POST, PUT, DELETE, webhooks, GraphQL submissions, and anything that should run only from an explicit form/action flow.
|
||||
- POST, PUT, and DELETE resources default to `exposeAsDataSource:false`, even with a scope. Set `exposeAsDataSource:true` only for an intentional render-time read such as a GraphQL POST query; provide `scopeInstanceId` and inspect the returned warning. Set it to `false` during `update-resource` to detach existing render-time exposure.
|
||||
- For dynamic resource query parameters prefer `searchParams`, for example `{"name":"tag","value":"filters.tag"}`. Use `{"type":"literal","value":"website"}` for fixed request text. Header values can be expressions such as `"\"Bearer \" + auth.token"`. Body can be an object expression, including GraphQL payloads such as `{ query: "...", variables: { slug: system.params.slug } }`.
|
||||
- For dynamic resource query parameters prefer `searchParams`, for example `{"name":"tag","value":"filters.tag"}`. Use `{"type":"literal","value":"website"}` for fixed request text. Header values can use an expression such as `"Bearer " + auth.token`. Body can be an object expression, including GraphQL payloads such as `{ query: "...", variables: { slug: system.params.slug } }`.
|
||||
- Resource methods are `get`, `post`, `put`, and `delete`. Optional resource controls are `graphql` and `system`. Use `control:"graphql"` for GraphQL POST resources with query bodies. Use `control:"system"` for built-in local resource URLs such as `"/$resources/current-date"` and for resources reading the built-in `system` parameter. The built-in system fields are `system.origin`, `system.pathname`, `system.params`, and `system.search`; do not use `system.path`.
|
||||
- Whenever an array or object from a resource or data variable should render repeated UI, call `insert-collection` with the complete iterable and one repeated-item JSX root. The command creates the Collection, private item parameters, iterable binding, and descendant item bindings atomically. Use `collectionItem` and `collectionItemKey` expressions in the item JSX. Wrap multiple repeated siblings in one Element, and give repeated Radix items stable unique `value` bindings.
|
||||
- Expressions are single JavaScript expressions, not statements or functions. Functions, arrow functions, classes, `new`, `this`, `await`, imports, arbitrary calls, increment/decrement, and assignment outside actions are unsupported. Prefer optional chaining, nullish coalescing, ternaries, property/index access, operators, and the documented string/array methods.
|
||||
|
||||
@@ -42,7 +42,7 @@ Examples:
|
||||
```sh
|
||||
webstudio mcp single-op-call meta.index
|
||||
webstudio mcp single-op-call meta.guide '{"brief":"Create a design system page using every component"}'
|
||||
webstudio mcp single-op-call meta.get_more_tools '{"tools":["insert-fragment"]}'
|
||||
webstudio mcp single-op-call meta.get-more-tools '{"tools":["insert-fragment"]}'
|
||||
webstudio mcp single-op-call components.list '{"source":"all"}'
|
||||
webstudio mcp single-op-call components.coverage-plan
|
||||
webstudio mcp single-op-call components.search '{"brief":"radix select"}'
|
||||
@@ -57,7 +57,7 @@ Shortcut equivalents:
|
||||
```sh
|
||||
webstudio meta.index
|
||||
webstudio meta.guide '{"brief":"Create a design system page using every component"}'
|
||||
webstudio meta.get_more_tools '{"tools":["insert-fragment"]}'
|
||||
webstudio meta.get-more-tools '{"tools":["insert-fragment"]}'
|
||||
webstudio components.list '{"source":"all"}'
|
||||
webstudio components.coverage-plan
|
||||
webstudio components.search '{"brief":"radix select"}'
|
||||
@@ -67,20 +67,60 @@ webstudio templates.get '{"component":"@webstudio-is/sdk-components-react-radix:
|
||||
webstudio insert-fragment --input-file .temp/insert-fragment.json
|
||||
```
|
||||
|
||||
### Tool name convention
|
||||
|
||||
MCP tool names are opaque strings, not JavaScript property access. A dot separates a namespace from its tool name, and every segment uses lowercase kebab-case. For example, `components.coverage-insert-next` is the `coverage-insert-next` tool in the `components` namespace. Pass the complete name as one CLI argument: `webstudio components.coverage-insert-next`.
|
||||
|
||||
### Readable fragment inputs
|
||||
|
||||
Prefer `--input-file` for JSX so JSON and shell quoting do not obscure the fragment. For example, save this as `.temp/insert-fragment.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"parentInstanceId": "root-id",
|
||||
"fragment": "<ws.element ws:tag='section' ws:style={css`padding: 32px; display: grid; gap: 16px;`}><ws.element ws:tag='h2'>Northstar Product OS</ws.element><ws.element ws:tag='p'>Reusable patterns for teams.</ws.element></ws.element>"
|
||||
}
|
||||
```
|
||||
|
||||
Then run `webstudio insert-fragment --input-file .temp/insert-fragment.json`. Single quotes inside the JSX keep the JSON valid and readable without backslash-escaped attributes.
|
||||
|
||||
Write and review larger fragments as JSX before placing them in the `fragment` field. Common patterns:
|
||||
|
||||
```tsx
|
||||
<ws.element
|
||||
ws:tag="section"
|
||||
style={{ padding: 32, borderRadius: 16 }}
|
||||
>
|
||||
<ws.element ws:tag="h2">Operations Console</ws.element>
|
||||
<ws.element ws:tag="p">
|
||||
React-style object styles become editable Webstudio styles.
|
||||
</ws.element>
|
||||
</ws.element>
|
||||
|
||||
<ws.element
|
||||
ws:tag="section"
|
||||
ws:tokens={[token("accent", css`color: #0f766e;`)]}
|
||||
>
|
||||
<ws.element
|
||||
ws:tag="button"
|
||||
onClick={new ActionValue(["event"], expression`console.log(event)`)}
|
||||
>
|
||||
Track launch
|
||||
</ws.element>
|
||||
</ws.element>
|
||||
|
||||
<ws.element ws:tag="section">
|
||||
<radix.Switch>
|
||||
<radix.SwitchThumb />
|
||||
</radix.Switch>
|
||||
</ws.element>
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- Inside the Webstudio monorepo, replace `webstudio` in the examples above with `node packages/cli/local.js`, for example `node packages/cli/local.js meta.index`.
|
||||
- For a simple authored/styled section, run `meta.index`, then `meta.get_more_tools '{"tools":["insert-fragment"]}'`, then `insert-fragment`. Do not grep source files, dump full MCP resources, or write parser scripts first.
|
||||
- In `insert-fragment` JSX, use `ws:style={css\`...\`}`for Webstudio-native CSS, or use React-style object syntax such as`style={{ padding: 24 }}` when that is simpler. Both forms create editable Webstudio style data.
|
||||
- Prefer JSX for authored/styled content. Common `insert-fragment` inputs:
|
||||
|
||||
```jsonl
|
||||
{"parentInstanceId":"root-id","fragment":"<ws.element ws:tag=\"section\" ws:style={css`padding: 32px; display: grid; gap: 16px;`}><ws.element ws:tag="h2">Northstar Product OS</ws.element><ws.element ws:tag="p">Reusable patterns for teams.</ws.element></ws.element>"}
|
||||
{"parentInstanceId":"root-id","fragment":"<ws.element ws:tag=\"section\" style={{ padding: 32, borderRadius: 16 }}><ws.element ws:tag="h2">Operations Console</ws.element><ws.element ws:tag="p">React-style object styles become editable Webstudio styles.</ws.element></ws.element>"}
|
||||
{"parentInstanceId":"root-id","fragment":"<ws.element ws:tag=\"section\" ws:tokens={[token(\"accent\", css`color: #0f766e;`)]}><ws.element ws:tag="button" onClick={new ActionValue([\"event\"], expression`console.log(event)`)}>Track launch</ws.element></ws.element>"}
|
||||
{"parentInstanceId":"root-id","fragment":"<ws.element ws:tag=\"section\"><radix.Switch><radix.SwitchThumb /></radix.Switch></ws.element>"}
|
||||
```
|
||||
|
||||
- For a simple authored/styled section, run `meta.index`, then `meta.get-more-tools '{"tools":["insert-fragment"]}'`, then `insert-fragment`. Do not grep source files, dump full MCP resources, or write parser scripts first.
|
||||
- In `insert-fragment` JSX, use ``ws:style={css`...`}`` for Webstudio-native CSS, or use React-style object syntax such as `style={{ padding: 24 }}` when that is simpler. Both forms create editable Webstudio style data.
|
||||
- Do not access host globals or dynamic code APIs in JSX fragments, including `process`, `globalThis`, `eval`, `Function`, or `constructor`.
|
||||
- Use Webstudio prop names such as `class` and `for`; do not use React aliases `className` or `htmlFor`.
|
||||
- Use Webstudio actions for event/action props, for example `onClick={new ActionValue(["event"], expression\`console.log(event)\`)}`. Do not pass JavaScript functions such as `onClick={() => ...}`.
|
||||
@@ -210,7 +250,7 @@ Use MCP itself after startup, or call the same tools with `webstudio mcp single-
|
||||
- `resources/list`: available overview and full JSON resources
|
||||
- `meta.index`: concise capability catalog
|
||||
- `meta.guide`: workflow for a user goal; call with a string brief such as `{"brief":"Create a pricing page"}`
|
||||
- `meta.get_more_tools`: detailed params, examples, namespaces, and local/server behavior; prefer exact names such as `{"tools":["insert-fragment"]}` when you know them
|
||||
- `meta.get-more-tools`: detailed params, examples, namespaces, and local/server behavior; prefer exact names such as `{"tools":["insert-fragment"]}` when you know them
|
||||
- `components.list`: compact registry metadata for visible components and templates; use a focused get tool for complete details
|
||||
- `components.summary`: component counts by default; use `{"detail":"components","limit":20}` for paginated entries
|
||||
- `components.coverage-plan`: compact paged plan for design-system coverage tasks that need every component; default returns counts plus the first root page, use `{"detail":"roots"}`, `{"detail":"parts"}`, or `{"detail":"full"}` for more
|
||||
|
||||
@@ -6,16 +6,25 @@ Put each local CLI call in its own shell command; do not chain helper commands w
|
||||
|
||||
```sh
|
||||
node packages/cli/local.js mcp single-op-call meta.index
|
||||
node packages/cli/local.js mcp single-op-call meta.get_more_tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js mcp single-op-call insert-fragment '{"parentInstanceId":"parent-id","fragment":"<ws.element ws:tag=\"section\" ws:style={css`padding: 32px; display: grid; gap: 12px;`}><ws.element ws:tag="h2">Launch Kit</ws.element><ws.element ws:tag="p">A focused section created with Webstudio JSX.</ws.element><ws.element ws:tag="button">Get started</ws.element></ws.element>"}' --dry-run
|
||||
node packages/cli/local.js mcp single-op-call meta.get-more-tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js mcp single-op-call insert-fragment --input-file .temp/insert-fragment.json --dry-run
|
||||
```
|
||||
|
||||
Save the input as `.temp/insert-fragment.json`; use single quotes for JSX attributes so the JSON needs no backslash escaping:
|
||||
|
||||
```json
|
||||
{
|
||||
"parentInstanceId": "parent-id",
|
||||
"fragment": "<ws.element ws:tag='section' ws:style={css`padding: 32px; display: grid; gap: 12px;`}><ws.element ws:tag='h2'>Launch Kit</ws.element><ws.element ws:tag='p'>A focused section created with Webstudio JSX.</ws.element><ws.element ws:tag='button'>Get started</ws.element></ws.element>"
|
||||
}
|
||||
```
|
||||
|
||||
The shorter local shortcut form is preferred for simple shell steps:
|
||||
|
||||
```sh
|
||||
node packages/cli/local.js meta.index
|
||||
node packages/cli/local.js meta.get_more_tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js insert-fragment '{"parentInstanceId":"parent-id","fragment":"<ws.element ws:tag=\"section\" ws:style={css`padding: 32px; display: grid; gap: 12px;`}><ws.element ws:tag="h2">Launch Kit</ws.element><ws.element ws:tag="p">A focused section created with Webstudio JSX.</ws.element><ws.element ws:tag="button">Get started</ws.element></ws.element>"}' --dry-run
|
||||
node packages/cli/local.js meta.get-more-tools '{"tools":["insert-fragment"]}'
|
||||
node packages/cli/local.js insert-fragment --input-file .temp/insert-fragment.json --dry-run
|
||||
```
|
||||
|
||||
For simple authored/styled sections, run the three commands above. Do not grep source files, dump full MCP resources, or write parser scripts first. Use `list-pages`, `get-page-by-path`, or `list-instances` only when you still need the target `parentInstanceId`.
|
||||
@@ -28,9 +37,9 @@ For experiments, pass `--dry-run` to local-capable mutation calls. Read the comp
|
||||
|
||||
Startup marks cached ProjectSession data stale so MCP tools read the current Builder dev build.
|
||||
|
||||
After startup, use focused discovery tools with concrete JSON. For delegated design-system or “use every component” tasks, start with exactly one command: `webstudio workflow.next '{"goal":"design-system-page"}'`; report the returned checkpoint to the parent/user and stop until continued. For other tasks, read `meta.index` first. From a shell, `webstudio mcp list-tools` is a concise alias for the initial tool catalog. Then call shortcuts such as `webstudio meta.guide '{"brief":"Create a design system page using every component"}'`, `webstudio workflow.next '{"goal":"design-system-page"}'`, `webstudio meta.get_more_tools '{"tools":["insert-fragment"]}'`, `webstudio components.list '{"source":"all"}'`, `webstudio components.summary`, `webstudio components.search '{"brief":"radix select"}'`, `webstudio components.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`, `webstudio templates.list`, and `webstudio templates.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`. Use `webstudio mcp single-op-call` when you need the explicit MCP form. Prefer `insert-fragment` for authored/styled sections; use `insert-component` only when inserting one automatic component template. In JSX, use `ws:style={css\`...\`}`for styles,`class`/`for`instead of`className`/`htmlFor`, `ActionValue`for actions instead of JavaScript functions such as`onClick={() => ...}`, only JSON-compatible plain prop values, and no host globals or dynamic code APIs. For bounded multi-step shell work, run inline JSON like `webstudio mcp run '[{"tool":"meta.index"},{"tool":"components.search","input":{"brief":"button"}}]'`; this reuses one CLI session without raw JSON-RPC. For larger batches, write `{ "calls": [{ "tool": "..." }] }`to`.temp/mcp-calls.json`and run`webstudio mcp run .temp/mcp-calls.json`. If any call returns `checkpoint.required`, `mcp run`stops immediately before later calls; report the checkpoint and call`checkpoint.ack {"reported":true,"continueAfterReport":true,"summary":"<what you reported>"}`before continuing. For design-system or “use every component” tasks, call`workflow.next {"goal":"design-system-page"}`for the next bounded phase, report its checkpoint, wait until the parent/user continues, call`checkpoint.ack {"reported":true,"continueAfterReport":true,"summary":"<what you reported>"}`, then run only that phase. Start coverage phases with compact`webstudio components.coverage-plan`, checkpoint, then request component coverage details with `components.coverage-plan {"detail":"roots"}`or`components.coverage-plan {"detail":"parts"}`. Do not pass `detail`to`list-pages`; use `list-pages {}`or`get-page-by-path`for page lookup. Read MCP overview resources`webstudio://project/guide`, `webstudio://project/tools-overview`, and `webstudio://project/components-overview`when useful. Read full resources`webstudio://project/tools`and`webstudio://project/components` only when focused tools are insufficient; do not dump or parse full discovery JSON for common lookup.
|
||||
After startup, use focused discovery tools with concrete JSON. For delegated design-system or “use every component” tasks, start with exactly one command: `webstudio workflow.next '{"goal":"design-system-page"}'`; report the returned checkpoint to the parent/user and stop until continued. For other tasks, read `meta.index` first. From a shell, `webstudio mcp list-tools` is a concise alias for the initial tool catalog. Then call shortcuts such as `webstudio meta.guide '{"brief":"Create a design system page using every component"}'`, `webstudio workflow.next '{"goal":"design-system-page"}'`, `webstudio meta.get-more-tools '{"tools":["insert-fragment"]}'`, `webstudio components.list '{"source":"all"}'`, `webstudio components.summary`, `webstudio components.search '{"brief":"radix select"}'`, `webstudio components.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`, `webstudio templates.list`, and `webstudio templates.get '{"component":"@webstudio-is/sdk-components-react-radix:Select"}'`. Use `webstudio mcp single-op-call` when you need the explicit MCP form. Prefer `insert-fragment` for authored/styled sections; use `insert-component` only when inserting one automatic component template. In JSX, use `ws:style={css\`...\`}`for styles,`class`/`for`instead of`className`/`htmlFor`, `ActionValue`for actions instead of JavaScript functions such as`onClick={() => ...}`, only JSON-compatible plain prop values, and no host globals or dynamic code APIs. For bounded multi-step shell work, run inline JSON like `webstudio mcp run '[{"tool":"meta.index"},{"tool":"components.search","input":{"brief":"button"}}]'`; this reuses one CLI session without raw JSON-RPC. For larger batches, write `{ "calls": [{ "tool": "..." }] }`to`.temp/mcp-calls.json`and run`webstudio mcp run .temp/mcp-calls.json`. If any call returns `checkpoint.required`, `mcp run`stops immediately before later calls; report the checkpoint and call`checkpoint.ack {"reported":true,"continueAfterReport":true,"summary":"<what you reported>"}`before continuing. For design-system or “use every component” tasks, call`workflow.next {"goal":"design-system-page"}`for the next bounded phase, report its checkpoint, wait until the parent/user continues, call`checkpoint.ack {"reported":true,"continueAfterReport":true,"summary":"<what you reported>"}`, then run only that phase. Start coverage phases with compact`webstudio components.coverage-plan`, checkpoint, then request component coverage details with `components.coverage-plan {"detail":"roots"}`or`components.coverage-plan {"detail":"parts"}`. Do not pass `detail`to`list-pages`; use `list-pages {}`or`get-page-by-path`for page lookup. Read MCP overview resources`webstudio://project/guide`, `webstudio://project/tools-overview`, and `webstudio://project/components-overview`when useful. Read full resources`webstudio://project/tools`and`webstudio://project/components` only when focused tools are insufficient; do not dump or parse full discovery JSON for common lookup.
|
||||
|
||||
After startup, MCP clients discover capabilities with `tools/list`, `resources/list`, `meta.index`, `meta.guide`, and `meta.get_more_tools`.
|
||||
After startup, MCP clients discover capabilities with `tools/list`, `resources/list`, `meta.index`, `meta.guide`, and `meta.get-more-tools`.
|
||||
|
||||
stdout is reserved for MCP JSON-RPC messages while the server is running.
|
||||
|
||||
|
||||
Reference in new issue
Block a user