sayshape-mcp 0.2.1 → 0.3.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/README.md CHANGED
@@ -28,6 +28,7 @@ Above each interface, at the right, the view can show a slim toolbar:
28
28
 
29
29
  - **Save image** (a download icon), in chat apps that let views download files (MCP Apps' `downloadFile` capability). It saves the interface as it looks now, after anything the person changed, as a sharp PNG (twice the screen's resolution, on the theme's background, without hover or messages) named after the interface's title, ready to paste into an email, a chat or a slide. Nothing is sent to the model.
30
30
  - **Copy text** (a copy icon). A canvas has no text to select, so this copies the whole interface as it is now: headings and text as lines, fields as "Label: value", checkboxes as [x] or [ ], and tables and chart data as tab-separated rows that paste straight into Excel or Google Sheets as cells. Buttons are left out and passwords are never copied. Ctrl+C (Cmd+C on a Mac) does the same unless the person is typing in a field. The server asks the chat app for clipboard access; where it isn't given, the view says so. Nothing is sent to the model.
31
+ - **Save as PDF, Save as PowerPoint and Present**, while a slide deck is showing. See [Slide decks](#slide-decks).
31
32
  - **A theme selector** for SayShape's Teal, Purple, Blue and Neutral presets, when the server is started with `--theme-picker`. Useful for demos; for a company, set its theme with `--theme` instead.
32
33
 
33
34
  When none is on, there's no toolbar at all. Whoever installs the server chooses, with flags in the chat app's `args`:
@@ -36,12 +37,18 @@ When none is on, there's no toolbar at all. Whoever installs the server chooses,
36
37
  |---|---|
37
38
  | `--theme-picker` | Show the theme selector (off by default) |
38
39
  | `--theme teal\|purple\|blue\|neutral\|studio` | The theme interfaces use (default `teal`). `studio` is the Studio look: Inter, rounder corners and an indigo-to-violet accent |
39
- | `--accent "#e4572e"` | A brand color (hex, `#rrggbb` or `#rgb`) for buttons, highlights and charts' first series, laid over the theme. Text in it must stay readable (4.5:1), and no color manages that on both white and near-black, so it's darkened in light mode or lightened in dark mode where needed; the server says at startup what each mode uses |
40
+ | `--accent "#e4572e"` | A brand color (hex, `#rrggbb` or `#rgb`) for buttons, highlights and charts' first series, laid over the theme. The same as `--colors` with one color: the other five chart series are worked out from it. Text in it must stay readable (4.5:1), and no color manages that on both white and near-black, so it's darkened in light mode or lightened in dark mode where needed; the server says at startup what each mode uses. Without `--accent` or `--colors`, a few known chat apps (Claude, ChatGPT, VS Code, Gemini, Grok) get their own brand color as the accent, unless the person picks a theme in the selector or `--theme` is not the default |
41
+ | `--colors "#e4572e,#2e86ab,#f2c14e"` | Up to six brand colors, hex, in one quoted argument separated by commas, most important first. The first does what `--accent` does (buttons, highlights, the first chart series); the rest are the next chart series in that order, each made readable (3:1); the series the list does not cover are worked out from the first color, kept quieter so it stays the strongest, and away from the colors used for good and bad. A color too like an earlier one is replaced by a worked-out one. Only the accent and the chart series change: surface, text, lines and the good, warn and bad colors still follow the chat app. A bad entry, an empty one or more than six stops the server at startup and names the problem. Use either `--colors` or `--accent`, not both |
42
+ | `--no-model-colors` | Take away `show_interface`'s `colors` argument. Without this flag, a model sends `colors` (a list of hex colors, most important first) only when the person, or its instructions, named colors to use; they're drawn over everything above (the server's `--colors`, a theme the person picked, the chat app's color), entries that aren't hex colors are ignored, and the result reminds the model to send the same colors on later calls in the conversation, since nothing is stored. With the flag, the tool is exactly what it was before the argument existed and the view ignores colors sent anyway. Chat apps that can't draw views draw the page in them (see below) and get the same reminder; `--widget-dir` files don't use the argument yet |
40
43
  | `--no-save-image` | Hide Save image (shown by default where the chat app can download) |
41
44
  | `--no-copy-text` | Hide Copy text, and leave Ctrl+C alone (shown by default) |
42
45
  | `--scene` | **Experimental.** Turn on scenes: pictures and animations the model paints from shapes, with parts people can press and soft shadows, glow and shine for depth (off by default). Leave it out to turn them off again. |
43
46
  | `--behavior` | **Experimental.** Turn on behavior: things that change by themselves on a timer (a countdown, a simulation) and, together with `--scene`, shapes people drag (off by default). Rules only change the interface's own values; they still can't run code. Chat apps that can't draw views don't get it. |
47
+ | `--logo https://cdn.example.com/logo.png` | An https image drawn small in the corner of every slide of a deck. Its host is allowed like `--image-hosts`, so the logo loads. See [Slide decks](#slide-decks). |
48
+ | `--slides` | Does nothing. Slide decks need no flag; this is accepted so setups written for an earlier version still start. |
44
49
  | `--image-hosts cdn.example.com,*.img.example.com` | Hosts `image` elements may load from, comma-separated; `*.example.com` allows its subdomains. None by default, so no images show. See [Images](#images). |
50
+ | `--widget-dir <folder>` | For chat apps that can't draw MCP Apps views but can show a widget made from a file: write each interface there as one self-contained file (stdio only; refused with `--http`). Off by default. See [Chat apps that show widgets from files](#chat-apps-that-show-widgets-from-files). |
51
+ | `--widget-host <name>` | With `--widget-dir` only: hook that chat app's adapter into every file, so `emit:` presses (and the interface's state) are saved for the model's next turn. Names: `muse`. An unknown name, or no `--widget-dir`, stops the server with a message. Off by default. See [Adapting a file to a chat app](#adapting-a-file-to-a-chat-app---widget-host). |
45
52
 
46
53
  ```json
47
54
  "sayshape": { "command": "node", "args": ["/full/path/to/sayshape/mcp/dist/server.js", "--theme", "blue", "--theme-picker"] }
@@ -55,6 +62,16 @@ With both experimental features on:
55
62
 
56
63
  Then ask for something that moves or can be pressed: *"Draw a traffic light I can press, where the active light glows"*, *"Draw a shiny ball bouncing with a shadow on the floor"* or *"A 30-second countdown I can pause"*. Both features may still change between releases.
57
64
 
65
+ ### Slide decks
66
+
67
+ `deck` and `slide` are ordinary elements: the quick start in `show_interface`'s description lists them ("a presentation or slide deck, one idea per slide: `deck bind=page`", and "a deck at the top level, not inside a card; a slide per idea"), and `sayshape_docs` gives their props and an example like any other element. Ask for *"A short deck for our Q3 business review"* and the model writes a deck of 16:9 slides that the view shows one at a time, with arrows, dots, Left and Right, and a swipe. The language is described in [the language reference](../docs/language.md#slide-decks).
68
+
69
+ - **No flag.** Earlier versions needed `--slides`. It is still accepted and does nothing, so existing setups keep starting.
70
+ - **`--logo <https url>`** draws a small logo in the bottom left corner of every slide. The address must be https with a plain host; the host is added to `--image-hosts` (and to the view's content security policy), so it loads. It works on its own, without `--slides`.
71
+ - **Files.** While a deck is showing, and where the chat app lets views download files (and not with `--no-save-image`), the download button saves a **PDF** and a second button saves a **PowerPoint file**, one page per slide (up to 60). Each page is a picture of the slide as the engine draws it, after anything the person changed, so the file looks exactly like the chat and can't be edited. Nothing is sent to the model.
72
+ - **Present.** Where the chat app has a full-screen mode, a Present button shows the deck at the largest size that fits, and puts it back.
73
+ - **Text-only clients get a sentence, not a page.** Their page loads an engine pinned at least two weeks behind releases (`PAGE_ENGINE_VERSION`, see [releasing](../docs/releasing.md#the-engine-version-the-text-only-page-loads)), which has no slides yet. So `show_interface` checks the deck as usual and answers with one plain sentence: the deck is written correctly, but this app can't show slide decks yet, and the person needs a chat app that draws SayShape views. A server started with `--widget-dir` is the exception: its file carries this server's own engine, so a deck draws there.
74
+
58
75
  ### Images
59
76
 
60
77
  The view has no website of its own, so an `image` only loads from a host you list with `--image-hosts`, usually your company's image CDN:
@@ -71,6 +88,8 @@ Coding agents and other text-only clients (Claude Code, Codex, Antigravity and o
71
88
 
72
89
  The page is a few kilobytes plus the spec: a canvas, the engine loaded from jsDelivr (`sayshape@<version>/dist/sayshape.global.js`, and the map's own script when the spec has a map), and the spec embedded as JSON with `<` escaped, so nothing in it can end the script. It follows light and dark mode, and a `data-theme="light"` or `"dark"` on its root element; its background is the engine theme's own; and it fits a phone with no sideways scrolling.
73
90
 
91
+ Brand colors reach the page too. The server works out the final colors for light and dark itself, from the `colors` argument if the model sent it, else `--colors` or `--accent`, and writes the accent, the text on it, the map's highlight and the six chart series into the page as values; the page lays them over the engine's own themes, so the pinned engine needs to know nothing about color lists. When the model's colors were used, the result ends with the same reminder the view's results do, outside the page, to send them again on later calls. Without any colors the page is exactly what it was.
92
+
74
93
  A page outside the chat has no conversation to send `emit:` actions to, so for these clients only:
75
94
 
76
95
  - **The model is told not to use `emit:`.** Their quick start (in `show_interface`'s description and `sayshape_docs` with nothing named) says to leave it out and ask the person to reply in the chat instead.
@@ -84,12 +103,43 @@ What doesn't work there:
84
103
  - **Save image and Copy text** aren't on the page.
85
104
  - **It needs internet access** to load the engine from the CDN; without it, or before the pinned version is on the CDN, the page names the engine version that didn't load.
86
105
  - **Interfaces that load datasets** (`--data`, `--mcp-result`) can't be shown: the page has no way to fetch rows, and the rows never go through the conversation. The model is told so and answers in text.
87
- - It uses the default Teal light and dark themes; `--theme`, `--theme-picker` and the chat app's own colors and fonts apply only to the view.
106
+ - It uses SayShape's default look in light and dark; `--theme`, `--theme-picker` and the chat app's own colors and fonts apply only to the view. Brand colors (`--colors`, `--accent` and the `colors` argument) are the one thing from them the page does use.
88
107
  - The engine version is pinned and moves at releases, so the page can be one release behind the server: an element added in the newest release may not draw there yet. ([Why](https://github.com/premmannava/sayshape/blob/main/docs/releasing.md#the-engine-version-the-text-only-page-loads).)
108
+ - For chat apps whose sandbox blocks the CDN but can show a widget from a file, see [`--widget-dir`](#chat-apps-that-show-widgets-from-files).
89
109
  - In `--http` mode the server makes a new server for every request and never sees what the client announced, so it always answers as for a client that draws views.
90
110
 
91
111
  The same interface sent again gets no second page, and a spec with problems gets them to fix first, with no page. To see what a client announces, start the server with `SAYSHAPE_LOG_CLIENT=1` in its environment: each connection writes the client's name and capabilities to stderr.
92
112
 
113
+ ### Chat apps that show widgets from files
114
+
115
+ Some chat apps show a widget built from a file on your computer, inside a sandbox that loads nothing from outside: no scripts from a CDN, no network requests, no remote images. The page above can't draw there, because it loads the engine from jsDelivr. Muse is the one this was tested in. What its sandbox allows is what such an app needs the file to be: inline scripts, `blob:` scripts and `DecompressionStream` work; the widget has to be an HTML fragment (no `<!doctype>`, `<html>`, `<head>` or `<body>`) under 1 MB, stored whole with the chat and run in its own frame, so nothing is shared between widgets; the app scans a widget's source for browser storage names; and the frame is about 656 px wide with Times as its default font.
116
+
117
+ Start the server with `--widget-dir <folder>` and, for a client that announces no MCP Apps support, `show_interface` writes the interface into that folder and returns a short text result instead of a page: the file's absolute path, and an instruction to create the widget from that file exactly as it is, without reading or editing it. The engine is inside the file, so it never passes through the model's context. Problems to fix are reported as before, with no file. Clients that draw views, and every client when the flag is off, get what they got before.
118
+
119
+ ```json
120
+ "sayshape": { "command": "node", "args": ["/full/path/to/sayshape/mcp/dist/server.js", "--widget-dir", "/Users/you/sayshape-widgets"] }
121
+ ```
122
+
123
+ - **One file, made from this server's own engine.** `npm run build` builds the engine from this repository's `src/` (`scripts/pack-widget-engine.mjs`: the same entry as the page's CDN build, built from this repository's `src/`, so it has the slide elements even while the page's pinned older engine doesn't), gzips it with Node's zlib and ships it in the package as `dist/widget-engine.json`, so the file always matches the server that checked the spec. The fragment holds one wrapping `<div>` (full width, at most 760 px, with its own font), a canvas, the spec (as JSON with `<` escaped, so `</script>` in a spec stays inert), the packed engine and a loader: it decodes and unpacks the engine with `DecompressionStream` and runs it as a `blob:` script, so nothing is fetched and the engine still can't run anything a spec says. A spec that mentions a browser storage name has its first letter escaped, so the words never appear in the file. Where the engine can't be unpacked, a short plain note shows in place of the canvas. A plain interface makes a file of about 260 KB; one with a map about 480 KB (the map's outlines are a second packed script). If a file would reach 1 MB, none is written and the result says why.
124
+ - **The name is a hash** of the spec and everything that changes the file (the settings below and the engine), so the same interface reuses one file. The folder keeps the newest 50 (`sayshape-<16 hex digits>.html`); older ones are deleted, and nothing else in the folder is ever touched.
125
+ - **The server's settings reach the file.** `--theme`, `--accent` or `--colors`, `--image-hosts` (and `--logo`), `--scene` and `--behavior` all apply (`--slides` is accepted and does nothing: decks need no flag), and unlike the page, behavior and decks work, because the file carries this server's engine and not an older pinned one. (Images from other hosts can't load in a sandbox like Muse's, so an `image` shows its description there.) Fonts: the file draws in the system font where Instrument Sans or Inter isn't installed.
126
+ - **Light and dark** follow `data-theme="light|dark"` on the root element and the system's `prefers-color-scheme`, and changes to either.
127
+ - **As on the page:** interfaces that load datasets are refused with the same message, `emit:` is refused and removed by the model first (a widget has no chat to send to yet; see `--widget-host` below for the way around that), and links pressed in `rich=true` text open in a new tab (https only).
128
+
129
+ ### Adapting a file to a chat app (`--widget-host`)
130
+
131
+ The fragment builder (`mcp/src/widget-file.ts`) takes a `host` option: the source of a function the loader calls once after the first draw, as `(source)(ui, sayshape, root)`, which may return `{ emit(action) }` to receive the actions that aren't links. `--widget-host <name>` sets it to one of the adapters in `mcp/src/widget-hosts/`; `muse` is the only one so far. It only works together with `--widget-dir`:
132
+
133
+ ```json
134
+ "sayshape": { "command": "node", "args": ["/full/path/to/sayshape/mcp/dist/server.js", "--widget-dir", "/Users/you/sayshape-widgets", "--widget-host", "muse"] }
135
+ ```
136
+
137
+ What changes with it, for clients that get a file:
138
+
139
+ - **The file carries the adapter.** The Muse adapter keeps `emit:` actions in a short list in the widget's state bridge, next to the interface's own state (saved without passwords, and skipped when it is large), and puts that state back when the widget is mounted again. If `--theme`, `--accent` or `--colors` was given, the adapter ignores the chat app's colors and the interface keeps its own; otherwise it follows the app's.
140
+ - **`emit:` is allowed.** The quick start no longer says not to use it, and a line with `emit:` is no longer a problem to fix. It says that presses are saved for the model's next turn instead: after the person's next message, the model reads the widget's state, where `actions` lists what they pressed (name, value, time). The result for a spec that uses `emit:` says the same.
141
+ - **Nothing else changes.** Without the flag, `emit:` is handled exactly as above; clients that draw MCP Apps views get the same tools, docs and results with or without it.
142
+
93
143
  ## Tokens
94
144
 
95
145
  A model never reads the whole language guide (about 7,500 tokens). It gets a quick start in `show_interface`'s description (about 450) and asks `sayshape_docs` for only the elements it's about to use: about 140 tokens for a button, 700 for a chart and a table, 1,200 for a six-element dashboard. If it guesses an element wrong, the result of `show_interface` brings that element's docs, so a wrong guess costs one retry, not the whole guide. Retries are the expensive part, because each call resends the whole conversation, so the server avoids the needless ones: it quietly fixes Markdown fences and typographic quotes (the view tidies the same way), tells the model when a problem was only an ignored prop and needs no new call, and answers an unknown function like `argmax` with the one to use instead (`first(sort(rows, 'revenue', 'desc'))`). With a database, the rows go from the database to the interface, so the model's tokens don't grow with the data either.
@@ -217,7 +267,7 @@ To give Claude, ChatGPT and other chat apps a permanent HTTPS address, run the H
217
267
  Start it with an exact version, never `@latest`, so what runs is what you checked:
218
268
 
219
269
  ```bash
220
- npx -y sayshape-mcp@0.2.1 --http --host 0.0.0.0 --trust-proxy
270
+ npx -y sayshape-mcp@0.3.0 --http --host 0.0.0.0 --trust-proxy
221
271
  ```
222
272
 
223
273
  | | |
@@ -247,6 +297,6 @@ npm run build
247
297
  npm run test:e2e # the built view in Chromium, inside a sandboxed iframe driven by the MCP Apps host bridge
248
298
  ```
249
299
 
250
- `test:e2e` runs the browser canvas/host-action test, the database-to-interface test, the **text-only page test** (`scripts/e2e-fallback.mjs`: a client without MCP Apps gets a page, which is opened from a file in Chromium with the engine built from `../src` standing in for jsDelivr, and must paint in light, dark and `data-theme`, fit 400px and keep a spec containing `</script>` inert), and the **stdio MCP result import test** (`scripts/e2e-import.mjs`). The last one starts the built server with `--mcp-result`, lists the imported schema, calls `show_interface` and verifies the exact rows delivered by app-only `fetch_dataset`. Screenshots from the browser tests go to `e2e-output/`.
300
+ `test:e2e` runs the browser canvas/host-action test, the database-to-interface test, the **text-only page test** (`scripts/e2e-fallback.mjs`: a client without MCP Apps gets a page, which is opened from a file in Chromium with the engine built from `../src` standing in for jsDelivr, and must paint in light, dark and `data-theme`, fit 400px and keep a spec containing `</script>` inert), the **widget file test** (`scripts/e2e-widget.mjs`: the file `--widget-dir` writes is opened in Chromium under a Content Security Policy that blocks every external script, connection and image, and must draw in light and dark, fit 400px, change on a press and keep a hostile spec inert), and the **stdio MCP result import test** (`scripts/e2e-import.mjs`). The last one starts the built server with `--mcp-result`, lists the imported schema, calls `show_interface` and verifies the exact rows delivered by app-only `fetch_dataset`. Screenshots from the browser tests go to `e2e-output/`.
251
301
 
252
302
  The server bundles the engine from `../src`, so the guide, the parser and the view always match the library they were built with. The MCP packages (`@modelcontextprotocol/sdk`, `@modelcontextprotocol/ext-apps`, `zod`) are dependencies of this package only. The SayShape library itself still has none.