@yichus/mcp 0.1.0 → 0.1.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 CHANGED
@@ -4,45 +4,57 @@ MCP server that exposes the [Yichus](https://yich.us) calculators and the
4
4
  in-browser Bosatsu playground to any agent that speaks the Model Context
5
5
  Protocol.
6
6
 
7
- It bundles the local WebMCP relay and adds calculator discovery/opening tools.
7
+ It bundles the local WebMCP relay and adds calculator discovery, opening, and saving tools.
8
8
  A connected agent works with the same page the user can see: source edits,
9
9
  compiler diagnostics, results, and program diagrams.
10
10
 
11
11
  ## Install and connect
12
12
 
13
- Node 20 or newer. The relay does not need Java.
14
-
15
- ```sh
16
- npm install -g @yichus/mcp
17
- ```
18
-
19
- Configure your MCP client to launch this stdio server:
13
+ Node 20 or newer; the relay does not need Java. `@yichus/mcp` 0.1.0 is on
14
+ npm. Configure your MCP client to launch it as a stdio server:
20
15
 
21
16
  ```json
22
17
  {
23
18
  "mcpServers": {
24
19
  "yichus": {
25
20
  "command": "npx",
26
- "args": ["-y", "@yichus/mcp"]
21
+ "args": ["-y", "@yichus/mcp@0.1.0"]
27
22
  }
28
23
  }
29
24
  }
30
25
  ```
31
26
 
32
- A global install can use `"command": "yichus-mcp"` instead of `npx`.
33
-
34
- To work on the relay from a checkout of this repository:
27
+ Version 0.1.0 predates this README, which describes 0.1.1. It has no
28
+ calculator saving tool (`yichus_save_calculator`) and lacks later relay
29
+ fixes. Until 0.1.1 is published, build the current relay from a checkout
30
+ with Node 20+ and pnpm:
35
31
 
36
32
  ```sh
37
33
  pnpm install
38
34
  pnpm run yichus-mcp:build
39
- node packages/yichus-mcp/dist/cli.js
35
+ ```
36
+
37
+ and launch it by your checkout's absolute path:
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "yichus": {
43
+ "command": "node",
44
+ "args": ["/absolute/path/to/yichus/packages/yichus-mcp/dist/cli.js"]
45
+ }
46
+ }
47
+ }
40
48
  ```
41
49
 
42
50
  Open the desired page with `?webmcp=1`. Keep it open, call
43
- `webmcp_list_sources`, and select the source id for that tab. Discover its
44
- schemas with `webmcp_list_tools`, then use `webmcp_call_tool` with `sourceId`,
45
- `name`, and `arguments`. The relay and browser must run on the same computer.
51
+ `webmcp_list_sources`, and identify that tab. Discover its schemas and public
52
+ tool names with `webmcp_list_tools`, matching each tool's `sources` to the tab.
53
+ Use `webmcp_call_tool` with `name` and `arguments`. The relay and browser must run on the same computer.
54
+
55
+ The relay waits up to two minutes for a browser tool call, including cold
56
+ compilation. Keep the tab open while it runs. An MCP client may enforce its
57
+ own shorter timeout.
46
58
  For a local site, set `--base-url` to the origin you opened.
47
59
 
48
60
  A browser host with native WebMCP support can call page tools without this
@@ -72,6 +84,9 @@ relay. See [connection instructions](https://yich.us/reference/agent.html).
72
84
  - **Standalone calculator**: `yichus_list_inputs`, `yichus_set_inputs`,
73
85
  `yichus_list_outputs`, `yichus_explain_output`. These operate the running
74
86
  calculator; use an editable source drawer or the editor to change code.
87
+ An explanation is plain data: the formula in the page's labels, the same
88
+ formula with current values, the inputs and outputs it reads, and the
89
+ unlabeled steps in between.
75
90
  - **Explorer and state-machine spec editors**: `yichus_autocomplete_*`
76
91
  provides suggestions for the user to accept. The user then runs the page's
77
92
  checker. These tools do not execute a check themselves. For a complete agent edit/run loop, use page edit/action/feedback below.
@@ -82,7 +97,9 @@ relay. See [connection instructions](https://yich.us/reference/agent.html).
82
97
 
83
98
  The static `yichus_list_calculators` tool lists curated demo URLs;
84
99
  `yichus_open_calculator` opens a chosen slug with the relay flag. The
85
- `playground` slug opens the standalone calculator editor.
100
+ `playground` slug opens the standalone calculator editor. On a machine with
101
+ no browser opener (a container or headless box) it answers `opened: false`
102
+ with the link for a person to open by hand.
86
103
 
87
104
  ## Agent editing loop
88
105
 
@@ -102,6 +119,46 @@ The user accepts the ghost text with Tab or dismisses it with Escape.
102
119
  `yichus_autocomplete_list_editors`, `yichus_autocomplete_get_context`, and
103
120
  `yichus_autocomplete_dismiss` support inspection and cancellation.
104
121
 
122
+ ## Save a browser-compiled calculator
123
+
124
+ The [agent QuickStart](https://yich.us/start/quickstart.html) walks through a
125
+ calculator change, compilation, Why feedback, and local execution.
126
+
127
+ Use `webmcp_list_sources` to identify that page, then `webmcp_list_tools`
128
+ to find its tools by their `sources`. Call the returned public `name`:
129
+ when two tabs publish the same tool, the tab the relay saw first keeps
130
+ the plain name and later tabs' copies gain a tab-id suffix. The
131
+ `webmcp_call_tool` arguments are `name` and `arguments`; it does not accept
132
+ a `sourceId` parameter.
133
+
134
+ After testing the calculator, call the relay's `yichus_save_calculator`
135
+ directly with:
136
+
137
+ ```json
138
+ {
139
+ "exportToolName": "yichus_example_export",
140
+ "exampleId": "event_budget",
141
+ "expectedRevision": 2,
142
+ "outputDirectory": "/absolute/path/to/project/event-budget"
143
+ }
144
+ ```
145
+
146
+ Substitute the public export tool name and revision you actually read.
147
+ The parent directory must exist; the output directory must not. The tool
148
+ transfers bounded chunks from the browser, pins them to one compilation,
149
+ and validates the complete artifact before creating any files. It saves
150
+ the Bosatsu sources and generated HTML and returns paths and byte sizes,
151
+ keeping generated HTML out of the agent's context. A filesystem write
152
+ failure is reported as an error and may leave a partial new directory;
153
+ the tool never overwrites an existing destination.
154
+
155
+ Open the HTML or serve its directory with a static server. It starts at
156
+ the configured defaults, and supporting scripts and styles still load
157
+ from the exported site's URL, so internet access is required. The save
158
+ tool does not execute the program. In other browser hosts, use the page's
159
+ **Save calculator HTML** button or implement the paged
160
+ `yichus_example_export` contract (`nextOffset` and `expectedExportId`).
161
+
105
162
  ## CLI
106
163
 
107
164
  ```text
@@ -135,9 +192,12 @@ node packages/yichus-mcp/dist/cli.js --base-url http://localhost:8000
135
192
  This package is a thin yichus-curated wrapper around
136
193
  `@mcp-b/webmcp-local-relay`. It does not fork or reimplement the relay;
137
194
  it constructs a `LocalRelayMcpServer` from the relay package and registers
138
- two extra static tools on it. The relay version is pinned exactly so an
139
- upstream rename of an internal field is a deliberate audit step rather
140
- than a silent breakage.
195
+ curated discovery, opening, and file-saving tools on it. Tab naming and
196
+ coalesced `tools/list_changed` notices extend the relay's public classes.
197
+ Adding the curated tools uses two fields the relay does not make public;
198
+ the relay version is pinned exactly and those fields are checked when the
199
+ server is made, so an upstream rename fails at startup rather than when an
200
+ agent calls a tool.
141
201
 
142
202
  For the underlying relay itself (its CLI flags, security model, and
143
203
  runtime compatibility), see the