sayshape-mcp 0.3.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/README.md +14 -8
- package/dist/server.js +2607 -711
- package/dist/ui.html +124 -120
- package/dist/widget-engine.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ you: "Compare the three phone plans I pasted"
|
|
|
17
17
|
| | |
|
|
18
18
|
|---|---|
|
|
19
19
|
| `show_interface` | Takes a spec (and an optional title), checks it with SayShape's own parser and returns any skipped lines with line numbers, along with the docs for the elements on those lines. The chat app shows the result in the view. Its description carries a short quick start (about 450 tokens): the syntax, every element's name, every expression function and how to write for a chat. |
|
|
20
|
-
| `sayshape_docs` | Props and an example for just the elements the model names (a `table` brings its `table-column`), and topics on request: expressions, actions, lists, rules, examples, chat, database. |
|
|
20
|
+
| `sayshape_docs` | Props and an example for just the elements the model names (a `table` brings its `table-column`), and topics on request: expressions, actions, lists, rules, examples, look, motion, pictures, chat, database. `look` (the look line), `motion` (`enter=` and `stagger=`) and `pictures` (content over an image, `shape=`, `zoom=`) come from the same generators as the guide's optional sections; the quick start only names them, so they cost nothing until a model asks. |
|
|
21
21
|
| `ui://sayshape/interface.html` | The view: the SayShape engine, the Instrument Sans font and a small bridge script, all in one HTML file. It loads nothing from anywhere else. |
|
|
22
22
|
|
|
23
23
|
In chat apps that stream tool input, the interface builds line by line while the model is still writing it. When the person presses a button with `on=emit:name`, the view sends a message into the conversation naming the action, its value and the interface's current values. The model can then reply or show an updated interface. That's the only way anything leaves an interface: specs can't run code, open links or make requests.
|
|
@@ -27,7 +27,7 @@ Interfaces match the chat app they're in. The view follows its light or dark mod
|
|
|
27
27
|
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
|
-
- **Copy text** (a copy icon).
|
|
30
|
+
- **Copy text** (a copy icon). With nothing selected, 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
31
|
- **Save as PDF, Save as PowerPoint and Present**, while a slide deck is showing. See [Slide decks](#slide-decks).
|
|
32
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.
|
|
33
33
|
|
|
@@ -42,12 +42,17 @@ When none is on, there's no toolbar at all. Whoever installs the server chooses,
|
|
|
42
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 |
|
|
43
43
|
| `--no-save-image` | Hide Save image (shown by default where the chat app can download) |
|
|
44
44
|
| `--no-copy-text` | Hide Copy text, and leave Ctrl+C alone (shown by default) |
|
|
45
|
+
| `--select-touch` | Let a long press on a touch screen select the word under the finger, with the phone's own handles and Copy menu. Off by default until it has been checked on real phones; `--no-select-touch` says off explicitly. Mouse and pen selection are unaffected |
|
|
46
|
+
| `--no-select-text` | No invisible text layer: words can't be selected by dragging or found with Ctrl/Cmd+F, and nothing extra is added to the page (on by default) |
|
|
45
47
|
| `--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. |
|
|
46
48
|
| `--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. |
|
|
49
|
+
| `--layout-first` | Tell models to write the layout first and the data last: elements, then `state` lines with long lists at the very end (small values a control starts from, like a selected tab, may still go first). The view draws from the first element while the spec streams in, with placeholders for data that hasn't arrived, instead of waiting for a long list to be written. Changes only the guide text in `show_interface`'s description and `sayshape_docs`; off by default, and then the text is exactly what it was. See [the model guide](../docs/model.md#layout-first-while-streaming). |
|
|
47
50
|
| `--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
51
|
| `--slides` | Does nothing. Slide decks need no flag; this is accepted so setups written for an earlier version still start. |
|
|
49
|
-
| `--image-hosts cdn.example.com,*.img.example.com` |
|
|
52
|
+
| `--image-hosts cdn.example.com,*.img.example.com` | The only hosts `image` elements may load from, comma-separated; `*.example.com` allows its subdomains. Left out, images load from the common sites models know addresses on (`COMMON_IMAGE_HOSTS`). See [Images](#images). |
|
|
53
|
+
| `--no-image-hosts` | Allow no images from anywhere. Not with `--image-hosts` |
|
|
50
54
|
| `--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). |
|
|
55
|
+
| `--widget-inline` | With `--widget-dir` only: write the engine into each file as plain script text, not packed. For chat apps that show the file but say the engine didn't start, because their sandbox runs a file's own scripts and no `blob:` script (Antigravity's embeds). Files are about twice the size. |
|
|
51
56
|
| `--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). |
|
|
52
57
|
|
|
53
58
|
```json
|
|
@@ -74,13 +79,13 @@ Then ask for something that moves or can be pressed: *"Draw a traffic light I ca
|
|
|
74
79
|
|
|
75
80
|
### Images
|
|
76
81
|
|
|
77
|
-
The view has no website of its own, so an `image` only loads from a host
|
|
82
|
+
The view has no website of its own, so an `image` only loads from a host on its list. By default that is `COMMON_IMAGE_HOSTS`, the sites models know image addresses on (Wikimedia, Unsplash, Picsum, flag, poster and cover sites and the like; the list and the rule for what may be on it are in `src/images.ts`). `--image-hosts` replaces it with only your hosts, usually your company's image CDN, and `--no-image-hosts` allows none, so no images show. Chat apps repeat the hosts throughout the view's content policy and won't open a view whose policy passes 8 KiB, so the hosts may come to 1,200 characters in all, counting `https://` on each (`MAX_IMAGE_HOSTS_CHARS`, about 35 typical hosts):
|
|
78
83
|
|
|
79
84
|
```json
|
|
80
85
|
"sayshape": { "command": "node", "args": ["/full/path/to/sayshape/mcp/dist/server.js", "--image-hosts", "cdn.acme.com,images.unsplash.com"] }
|
|
81
86
|
```
|
|
82
87
|
|
|
83
|
-
The one list does three things: the view's engine loads from those hosts and no others, the server asks the chat app to allow them in the view's Content Security Policy (MCP Apps `resourceDomains`), and the model is told which hosts work, so it doesn't invent URLs elsewhere. Images must be https, and the host must send CORS headers (`Access-Control-Allow-Origin`), as image CDNs do, because the view keeps its canvas readable for Save image and Copy text. An image that can't load shows its description instead. Some chat apps may not honour a view's CSP request; then images show their descriptions there.
|
|
88
|
+
Each image is requested from its host by the person's browser, so that host sees their IP address. The one list does three things: the view's engine loads from those hosts and no others, the server asks the chat app to allow them in the view's Content Security Policy (MCP Apps `resourceDomains`), and the model is told which hosts work, so it doesn't invent URLs elsewhere. Images must be https, and the host must send CORS headers (`Access-Control-Allow-Origin`), as image CDNs do, because the view keeps its canvas readable for Save image and Copy text. An image that can't load shows its description instead. Some chat apps may not honour a view's CSP request; then images show their descriptions there.
|
|
84
89
|
|
|
85
90
|
## In chat apps that can't draw interfaces
|
|
86
91
|
|
|
@@ -104,7 +109,7 @@ What doesn't work there:
|
|
|
104
109
|
- **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.
|
|
105
110
|
- **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.
|
|
106
111
|
- 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.
|
|
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).)
|
|
112
|
+
- 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. Its pinned engine has no look line, entrance motion or content over images, so these clients aren't offered the `look`, `motion` and `pictures` topics (a widget file, which carries this server's engine, is). ([Why](https://github.com/premmannava/sayshape/blob/main/docs/releasing.md#the-engine-version-the-text-only-page-loads).)
|
|
108
113
|
- 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).
|
|
109
114
|
- 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.
|
|
110
115
|
|
|
@@ -121,6 +126,7 @@ Start the server with `--widget-dir <folder>` and, for a client that announces n
|
|
|
121
126
|
```
|
|
122
127
|
|
|
123
128
|
- **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.
|
|
129
|
+
- **Where the file shows "The SayShape engine didn't start in this chat app", add `--widget-inline`.** That sentence means the app showed the file and could unpack the engine but refused to run it as a `blob:` script (Antigravity's embeds do; Muse doesn't). With the flag the engine is written into the file as it is, in a `<script>` of its own before the loader, so there is nothing to unpack and nothing is run from a URL of any kind. A plain interface then makes a larger file, and one with a map may pass 1 MB and be refused with the usual message.
|
|
124
130
|
- **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
131
|
- **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
132
|
- **Light and dark** follow `data-theme="light|dark"` on the root element and the system's `prefers-color-scheme`, and changes to either.
|
|
@@ -144,7 +150,7 @@ What changes with it, for clients that get a file:
|
|
|
144
150
|
|
|
145
151
|
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.
|
|
146
152
|
|
|
147
|
-
Each call makes a new interface in the chat, so the server and view keep the chat tidy when a model calls more than it should, which smaller models often do. An interface with problems the model was asked to fix
|
|
153
|
+
Each call makes a new interface in the chat, so the server and view keep the chat tidy when a model calls more than it should, which smaller models often do. An interface with problems the model was asked to fix is hidden, and the view collapses to nothing. The same interface sent again within ten minutes, without changes, is answered with "already showing" and is hidden the same way. Repeats are tracked per conversation over stdio; the stateless HTTP mode doesn't track them.
|
|
148
154
|
|
|
149
155
|
## Show data from a database
|
|
150
156
|
|
|
@@ -267,7 +273,7 @@ To give Claude, ChatGPT and other chat apps a permanent HTTPS address, run the H
|
|
|
267
273
|
Start it with an exact version, never `@latest`, so what runs is what you checked:
|
|
268
274
|
|
|
269
275
|
```bash
|
|
270
|
-
npx -y sayshape-mcp@0.
|
|
276
|
+
npx -y sayshape-mcp@0.5.0 --http --host 0.0.0.0 --trust-proxy
|
|
271
277
|
```
|
|
272
278
|
|
|
273
279
|
| | |
|