@yichus/mcp 0.1.0 → 0.1.2

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,50 +4,46 @@ 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. Configure your MCP client to
14
+ 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.2"]
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:
35
-
36
- ```sh
37
- pnpm install
38
- pnpm run yichus-mcp:build
39
- node packages/yichus-mcp/dist/cli.js
40
- ```
27
+ Version 0.1.0 has no calculator saving tool (`yichus_save_calculator`) and
28
+ lacks later relay fixes.
41
29
 
42
30
  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.
31
+ `webmcp_list_sources`, and identify that tab. Discover its schemas and public
32
+ tool names with `webmcp_list_tools`, matching each tool's `sources` to the tab.
33
+ Use `webmcp_call_tool` with `name` and `arguments`. The relay and browser must run on the same computer.
34
+
35
+ The relay waits up to two minutes for a browser tool call, including cold
36
+ compilation. Keep the tab open while it runs. An MCP client may enforce its
37
+ own shorter timeout.
46
38
  For a local site, set `--base-url` to the origin you opened.
47
39
 
48
40
  A browser host with native WebMCP support can call page tools without this
49
41
  relay. See [connection instructions](https://yich.us/reference/agent.html).
50
42
 
43
+ When an agent connects, the relay tells it what the open pages offer and
44
+ that building the person's own app is the studio's job (`npx -y yichus@0.3.1
45
+ studio`, a separate MCP server in the project folder), not this relay's.
46
+
51
47
  ## Choose the tools for the page
52
48
 
53
49
  - **An editable Code & run example** on the website: call
@@ -72,6 +68,9 @@ relay. See [connection instructions](https://yich.us/reference/agent.html).
72
68
  - **Standalone calculator**: `yichus_list_inputs`, `yichus_set_inputs`,
73
69
  `yichus_list_outputs`, `yichus_explain_output`. These operate the running
74
70
  calculator; use an editable source drawer or the editor to change code.
71
+ An explanation is plain data: the formula in the page's labels, the same
72
+ formula with current values, the inputs and outputs it reads, and the
73
+ unlabeled steps in between.
75
74
  - **Explorer and state-machine spec editors**: `yichus_autocomplete_*`
76
75
  provides suggestions for the user to accept. The user then runs the page's
77
76
  checker. These tools do not execute a check themselves. For a complete agent edit/run loop, use page edit/action/feedback below.
@@ -82,7 +81,9 @@ relay. See [connection instructions](https://yich.us/reference/agent.html).
82
81
 
83
82
  The static `yichus_list_calculators` tool lists curated demo URLs;
84
83
  `yichus_open_calculator` opens a chosen slug with the relay flag. The
85
- `playground` slug opens the standalone calculator editor.
84
+ `playground` slug opens the standalone calculator editor. On a machine with
85
+ no browser opener (a container or headless box) it answers `opened: false`
86
+ with the link for a person to open by hand.
86
87
 
87
88
  ## Agent editing loop
88
89
 
@@ -102,6 +103,46 @@ The user accepts the ghost text with Tab or dismisses it with Escape.
102
103
  `yichus_autocomplete_list_editors`, `yichus_autocomplete_get_context`, and
103
104
  `yichus_autocomplete_dismiss` support inspection and cancellation.
104
105
 
106
+ ## Save a browser-compiled calculator
107
+
108
+ The [agent QuickStart](https://yich.us/start/quickstart.html) walks through a
109
+ calculator change, compilation, Why feedback, and local execution.
110
+
111
+ Use `webmcp_list_sources` to identify that page, then `webmcp_list_tools`
112
+ to find its tools by their `sources`. Call the returned public `name`:
113
+ when two tabs publish the same tool, the tab the relay saw first keeps
114
+ the plain name and later tabs' copies gain a tab-id suffix. The
115
+ `webmcp_call_tool` arguments are `name` and `arguments`; it does not accept
116
+ a `sourceId` parameter.
117
+
118
+ After testing the calculator, call the relay's `yichus_save_calculator`
119
+ directly with:
120
+
121
+ ```json
122
+ {
123
+ "exportToolName": "yichus_example_export",
124
+ "exampleId": "event_budget",
125
+ "expectedRevision": 2,
126
+ "outputDirectory": "/absolute/path/to/project/event-budget"
127
+ }
128
+ ```
129
+
130
+ Substitute the public export tool name and revision you actually read.
131
+ The parent directory must exist; the output directory must not. The tool
132
+ transfers bounded chunks from the browser, pins them to one compilation,
133
+ and validates the complete artifact before creating any files. It saves
134
+ the Bosatsu sources and generated HTML and returns paths and byte sizes,
135
+ keeping generated HTML out of the agent's context. A filesystem write
136
+ failure is reported as an error and may leave a partial new directory;
137
+ the tool never overwrites an existing destination.
138
+
139
+ Open the HTML or serve its directory with a static server. It starts at
140
+ the configured defaults, and supporting scripts and styles still load
141
+ from the exported site's URL, so internet access is required. The save
142
+ tool does not execute the program. In other browser hosts, use the page's
143
+ **Save calculator HTML** button or implement the paged
144
+ `yichus_example_export` contract (`nextOffset` and `expectedExportId`).
145
+
105
146
  ## CLI
106
147
 
107
148
  ```text
@@ -123,11 +164,11 @@ page hints the relay widget workspace `yichus` and relay id `yichus`, and
123
164
  the widget refuses a relay whose discovery announcement differs from
124
165
  either. Change them only for a page built to hint the same values.
125
166
 
126
- For local development against a self-hosted Yichus build, point both the
127
- relay's allowed origin and the URL builder at your dev server:
167
+ For a self-hosted copy of the site, point both the relay's allowed origin
168
+ and the URL builder at its server:
128
169
 
129
170
  ```bash
130
- node packages/yichus-mcp/dist/cli.js --base-url http://localhost:8000
171
+ npx -y @yichus/mcp@0.1.2 --base-url http://localhost:8000
131
172
  ```
132
173
 
133
174
  ## What this package does and does not do
@@ -135,9 +176,12 @@ node packages/yichus-mcp/dist/cli.js --base-url http://localhost:8000
135
176
  This package is a thin yichus-curated wrapper around
136
177
  `@mcp-b/webmcp-local-relay`. It does not fork or reimplement the relay;
137
178
  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.
179
+ curated discovery, opening, and file-saving tools on it. Tab naming and
180
+ coalesced `tools/list_changed` notices extend the relay's public classes.
181
+ Adding the curated tools uses two fields the relay does not make public;
182
+ the relay version is pinned exactly and those fields are checked when the
183
+ server is made, so an upstream rename fails at startup rather than when an
184
+ agent calls a tool.
141
185
 
142
186
  For the underlying relay itself (its CLI flags, security model, and
143
187
  runtime compatibility), see the