@fusedashlabs/ui9000-mcp 5.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Ido Salomon
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,495 @@
1
+ # UI9000-MCP
2
+
3
+ MCP server for creating charts from data. Attach a CSV or pass values in chat, choose a chart type (bar, line, pie, map, KPI, network, and more), and the chart renders in the MCP Apps view — Cursor, Claude Desktop, or any host that supports MCP Apps.
4
+
5
+ **npm:** [`@fusedashlabs/ui9000-mcp`](https://www.npmjs.com/package/@fusedashlabs/ui9000-mcp)
6
+ **Server key** in Cursor / Claude: `UI9000-MCP`
7
+
8
+ ---
9
+
10
+ ## Install in Cursor or Claude (npm)
11
+
12
+ Node.js 22+. The CLI starts **stdio MCP** plus a local **data-link HTTP** server on `127.0.0.1` (so widgets can fetch JSON). No clone required.
13
+
14
+ ### Cursor
15
+
16
+ Add to `~/.cursor/mcp.json` (or project `.cursor/mcp.json`):
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "UI9000-MCP": {
22
+ "command": "npx",
23
+ "args": ["-y", "@fusedashlabs/ui9000-mcp"],
24
+ "env": {
25
+ "MCP_TOOL_PROFILE": "mvp"
26
+ }
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ Restart Cursor. Use `"full"` for every chart tool.
33
+
34
+ ### Claude Desktop
35
+
36
+ Edit `claude_desktop_config.json`:
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "UI9000-MCP": {
42
+ "command": "npx",
43
+ "args": ["-y", "@fusedashlabs/ui9000-mcp"],
44
+ "env": {
45
+ "MCP_TOOL_PROFILE": "mvp"
46
+ }
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ Optional env:
53
+
54
+ | Variable | Default (npx CLI) | Meaning |
55
+ | --- | --- | --- |
56
+ | `MCP_TOOL_PROFILE` | `mvp` | `mvp` = 6 chart tools; `full` = all chart types |
57
+ | `MCP_BASE_URL` | auto `http://127.0.0.1:8088` | Skip local HTTP if you already run `pnpm mcp:serve` |
58
+ | `MCP_UI_RESOURCE_MIME` | `mcp-app` | Claude / Cursor MCP Apps MIME |
59
+ | `PORT` | `8088` | Local data-link port (`0` / in-use → random) |
60
+ | `STORAGE_DIR` | `~/.mcp-ui/data` | Signed payload files |
61
+ | `MCP_DATA_LINK_SECRET` | dev default locally | Required in production-like envs |
62
+
63
+ Attach a CSV in chat, then ask for a chart (see `chart-test-kit/prompts.md` in the workspace).
64
+
65
+ ---
66
+
67
+ ## Requirements
68
+
69
+ - **Node.js 22+**
70
+ - **pnpm** (via corepack or global install)
71
+ - Sibling package **`ui9000-widgets`** at `../ui9000-widgets` when building the MCP App View (`file:` dependency)
72
+
73
+ ---
74
+
75
+ ## Quick Start (<10 min)
76
+
77
+ 1. **Install:**
78
+ ```bash
79
+ pnpm install
80
+ pnpm --dir ../ui9000-widgets build # if widgets changed / first clone
81
+ pnpm build:mcp-app
82
+ ```
83
+
84
+ 2. **Environment:**
85
+ ```bash
86
+ cp env.local .env # or env.prod / .env.example
87
+ ```
88
+
89
+ 3. **HTTP/SSE** (signed data-links + local HTTP):
90
+ ```bash
91
+ pnpm run mcp:serve
92
+ ```
93
+ Default port from `.env` (often `8088` or `5173`). Expect: `MCP Server running over SSE on port …`
94
+
95
+ 4. **Stdio** (Claude Desktop / Cursor local MCP):
96
+ ```bash
97
+ pnpm run mcp:serve:stdio
98
+ ```
99
+ Stdio alone does **not** serve `/v1/data-links`. Keep `pnpm mcp:serve` running (or point `MCP_BASE_URL` at a deployed HTTP instance) whenever charts need signed payloads. Data-link files live under **`mcp-ui/.data`** (package root), not `process.cwd()`, so Cursor/Claude stdio and `mcp:serve` share the same store.
100
+
101
+ ### Install in Claude Desktop (from a clone)
102
+
103
+ Prefer **npx** (see [Install in Cursor or Claude (npm)](#install-in-cursor-or-claude-npm)). Clone + stdio is for local development.
104
+
105
+ Edit `claude_desktop_config.json` (absolute paths; prefer `tsx` over `pnpm` to avoid Corepack version checks):
106
+
107
+ ```json
108
+ {
109
+ "mcpServers": {
110
+ "UI9000-MCP": {
111
+ "command": "/absolute/path/to/mcp-ui/node_modules/.bin/tsx",
112
+ "args": ["/absolute/path/to/mcp-ui/src/mcp-stdio.ts"],
113
+ "env": {
114
+ "MCP_BASE_URL": "http://localhost:8088",
115
+ "MCP_TOOL_PROFILE": "mvp"
116
+ }
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ Or install the **`.mcpb`** bundle (see [MCPB pack](#mcpb-pack-p28)) via Claude’s extension install dialog.
123
+
124
+ ### Install in Cursor (from a clone)
125
+
126
+ Prefer **npx** (see [Install in Cursor or Claude (npm)](#install-in-cursor-or-claude-npm)). Clone + `tsx` is for local development.
127
+
128
+ Add to `~/.cursor/mcp.json` (or project `.cursor/mcp.json`). Prefer invoking **`tsx` directly** (avoids Corepack/pnpm version mismatch when Cursor spawns the process):
129
+
130
+ ```json
131
+ {
132
+ "mcpServers": {
133
+ "UI9000-MCP": {
134
+ "command": "/absolute/path/to/mcp-ui/node_modules/.bin/tsx",
135
+ "args": ["/absolute/path/to/mcp-ui/src/mcp-stdio.ts"],
136
+ "env": {
137
+ "MCP_BASE_URL": "http://localhost:5173",
138
+ "MCP_TOOL_PROFILE": "mvp"
139
+ }
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ Run `pnpm install` once so `node_modules/.bin/tsx` exists. Keep `pnpm mcp:serve` running for signed data-links.
146
+
147
+ Match `MCP_BASE_URL` / `PORT` to your running `mcp:serve`. Cursor may show tool results as links/text; full MCP Apps iframe rendering varies by host (see [Known limitations](#known-limitations)).
148
+
149
+ ### Prompt examples (copy-paste)
150
+
151
+ | # | Prompt | Expected tool / chart |
152
+ |---|--------|------------------------|
153
+ | 1 | `Create a line chart of monthly sales: Jan 10, Feb 20, Mar 15. Title "Sales trend".` | `generate_simple_single_series_chart` → `lineChart` (inline `@ui9000/widgets`) |
154
+ | 2 | `Pie chart of share: Alpha 40, Beta 35, Gamma 25. Title "Market share".` | `generate_pie_chart` → pie (`@ui9000/widgets`) |
155
+ | 3 | `Load this CSV as a dataset then chart revenue by region with a bar chart:` *(paste small CSV or use `load_dataset` then chart with `datasetId`)* | `load_dataset` → `generate_simple_single_series_chart` / bar |
156
+
157
+ ### Screenshot
158
+
159
+ Add a PNG of a rendered chart in Claude (MCP Apps) at `docs/screenshots/claude-chart.png` when available. Until then, verify locally: tool result `_meta.dataUrl` in the MCP App View.
160
+
161
+ ### Transport support
162
+
163
+ | Transport | Command / endpoint | FuseDash | Claude Desktop | Cursor |
164
+ |-----------|--------------------|----------|----------------|--------|
165
+ | Streamable HTTP | `POST /mcp` via `mcp:serve` | Yes | Supported | Possible via URL config |
166
+ | SSE | `GET /sse` via `mcp:serve` | Yes | Supported | Possible via URL config |
167
+ | Stdio | `pnpm mcp:serve:stdio` | No | Primary local path | Primary local path |
168
+
169
+ **P13 verification:** automated IT covers list-tools / read `ui://ui9000/chart` / call chart tool on in-memory, Streamable HTTP, SSE, and stdio (`src/mcp/transport.integration.test.ts`). Claude Desktop visual check: install via stdio config above (or `.mcpb`), confirm MCP App View loads; for HTTP use local `mcp:serve` URL if the host allows remote MCP.
170
+
171
+ Chart tools advertise `_meta.ui.resourceUri: ui://ui9000/chart`. CSP `connectDomains` comes from `MCP_BASE_URL` (`frameDomains` is empty — widgets fetch JSON, no nested charts app).
172
+
173
+ **Render:** `@ui9000/widgets` in the MCP App View. Unsupported `chartType` values show the View empty state (no `apps/charts` iframe).
174
+
175
+ Rebuild the View after editing `src/mcp-app/` or widgets:
176
+
177
+ ```bash
178
+ pnpm --dir ../ui9000-widgets build
179
+ pnpm build:mcp-app
180
+ ```
181
+
182
+ ### MCPB pack (P28)
183
+
184
+ ```bash
185
+ pnpm pack:mcpb
186
+ ```
187
+
188
+ Produces `dist/mcp-ui.mcpb` from `manifest.json` (stdio entry via `pnpm` + this directory). Requires Node 22 + pnpm on the install host. User config prompts for `MCP_BASE_URL`.
189
+
190
+ ### GitHub release (P29)
191
+
192
+ Push a tag `mcp-v*` or `v*` (or run **Release mcpb** workflow dispatch) to:
193
+ 1. Pack `dist/mcp-ui.mcpb` and attach it to a GitHub Release
194
+ 2. Trigger the existing `ci.yml` tag path that deploys HTTP/SSE to staging (`mcp-v*`)
195
+
196
+ Remote clients: use staging `MCP_BASE_URL` → `GET /sse` or `POST /mcp`, plus `/v1/data-links` for chart payloads.
197
+
198
+ ### Known limitations
199
+
200
+ | Topic | Detail |
201
+ |-------|--------|
202
+ | Map charts | Empty View until Mapbox/PMTiles land in `@ui9000/widgets` |
203
+ | Host UI | Claude MCP Apps render `ui://`; Cursor/VS Code may only show tool text/`dataUrl` |
204
+ | Stdio vs data-links | Chart tools need HTTP `MCP_BASE_URL` reachable for signed payloads |
205
+ | Widget coverage | Unsupported types show empty state in the MCP App View — no charts iframe |
206
+ | SSE “reconnect” | `GET /sse?sessionId=…` returns **400** — clients must open a new SSE session |
207
+ | Tool profile | `MCP_TOOL_PROFILE=mvp` shrinks `tools/list`; FuseDash uses `full` by default |
208
+
209
+ ### Host verification (P31)
210
+
211
+ Same stdio / HTTP / `.mcpb` artifacts for every host — **no per-host code forks**.
212
+
213
+ | Host | Install path | Tools / data-links | MCP Apps UI (`ui://`) | Status |
214
+ |------|--------------|--------------------|----------------------|--------|
215
+ | Claude Desktop | Stdio or `.mcpb` | Yes (with HTTP `MCP_BASE_URL`) | Yes (primary) | Verified path (P13 + IT) |
216
+ | Cursor | Stdio (`~/.cursor/mcp.json`) | Yes | Partial / host-dependent | Smoke locally |
217
+ | VS Code Insiders (MCP) | Stdio or HTTP URL | Expected yes | Depends on MCP Apps support in extension | Not fully verified — re-test after release |
218
+ | ChatGPT (MCP Apps) | Remote HTTP when host allows | Expected yes | Depends on host CSP / Apps support | Not fully verified — use same HTTP artifact |
219
+ | Goose | Stdio or HTTP | Expected yes | Host-dependent | Not fully verified — no Goose-specific code |
220
+
221
+ If a host needs a code branch, fix handshake/CSP in P1 instead of forking.
222
+
223
+ ### Production secret check (P04)
224
+
225
+ ```bash
226
+ # Offline: ensure env.prod (or ENV_FILE) is not the known-dev default — never prints the secret
227
+ pnpm check:data-link-secret
228
+ ENV_FILE=env.prod pnpm check:data-link-secret
229
+ ```
230
+
231
+ HTTP/stdio entrypoints refuse to start when `NODE_ENV`/`MCP_ENV`/`ENV_FILE` look production-like and `MCP_DATA_LINK_SECRET` is missing, too short, or a known default (`dev-secret-key-for-testing`, `secret`, …).
232
+
233
+ ### Known limitations
234
+
235
+ 1. **Build the image:**
236
+ ```bash
237
+ docker build --build-arg ENV_FILE=env.prod -t mcp-ui .
238
+ ```
239
+
240
+ The build process will extract the `PORT` value from your `env.prod` file and display it in the logs.
241
+
242
+ 2. **Run the container:**
243
+ ```bash
244
+ docker run -p 5173:5173 mcp-ui
245
+ ```
246
+
247
+ Replace `5173` with the actual `PORT` value from your `env.prod` file (shown during build).
248
+
249
+ **With persistent storage:**
250
+ ```bash
251
+ # Windows PowerShell
252
+ docker run -p 5173:5173 -v ${PWD}/.data:/app/.data mcp-ui
253
+
254
+ # macOS/Linux
255
+ docker run -p 5173:5173 -v $(pwd)/.data:/app/.data mcp-ui
256
+ ```
257
+
258
+ **Run in background:**
259
+ ```bash
260
+ docker run -d -p 5173:5173 --name mcp-ui-container mcp-ui
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Environment Variables
266
+
267
+ Create a `.env` file in the project root with the following variables:
268
+
269
+ | Variable | Description | Default |
270
+ |----------|-------------|---------|
271
+ | `PORT` | Port for the Express MCP server | `8088` |
272
+ | `MCP_BASE_URL` | Base URL for signed data links | `http://localhost:8088` |
273
+ | `MCP_DATA_LINK_SECRET` | Secret key for signing data links | `dev-secret-key-for-testing` |
274
+ | `CORS_ALLOWED_ORIGINS` | Comma-separated list of allowed origins or `*` | `*` |
275
+ | `STORAGE_DIR` | Directory for storing chart payloads (relative to project root) | `.data` |
276
+ | `DATA_LINK_TTL_HOURS` | Time-to-live for data links in hours | `24` |
277
+ | `MAX_PAYLOAD_SIZE_MB` | Maximum payload size in megabytes for data links | `1.5` |
278
+ | `MCP_TOOL_PROFILE` | `full` (default, FuseDash) or `mvp` (6 charts + helpers) | `full` |
279
+ | `MCP_UI_RESOURCE_MIME` | MCP Apps MIME (`mcp-app`) | `mcp-app` (npx) |
280
+
281
+ **Example `.env` file:**
282
+ ```env
283
+ PORT=5173
284
+ STORAGE_DIR=.data
285
+ MCP_BASE_URL=http://localhost:5173
286
+ MCP_DATA_LINK_SECRET=your-secret-key-here
287
+ DATA_LINK_TTL_HOURS=24
288
+ MAX_PAYLOAD_SIZE_MB=1.5
289
+ CORS_ALLOWED_ORIGINS=https://charts.example.com,https://mcp.example.com
290
+ ```
291
+
292
+ ---
293
+
294
+ ## API Endpoints
295
+
296
+ ### Data Links
297
+
298
+ **Create a data link:**
299
+ ```http
300
+ POST /v1/data-links
301
+ Content-Type: application/json
302
+
303
+ {
304
+ "config": { ... },
305
+ "data": { ... },
306
+ "meta": {
307
+ "source": "mcp",
308
+ "expiresInHours": 24
309
+ }
310
+ }
311
+ ```
312
+
313
+ **Response:**
314
+ ```json
315
+ {
316
+ "id": "abc123",
317
+ "dataUrl": "http://localhost:5173/v1/data-links/abc123?sig=...&exp=..."
318
+ }
319
+ ```
320
+
321
+ **Retrieve a data link:**
322
+ ```http
323
+ GET /v1/data-links/:id?sig=...&exp=...
324
+ ```
325
+
326
+ **Response:**
327
+ ```json
328
+ {
329
+ "id": "abc123",
330
+ "config": { ... },
331
+ "data": { ... },
332
+ "createdAt": "2024-01-01T00:00:00Z",
333
+ "ttlSeconds": 86400,
334
+ "meta": { ... }
335
+ }
336
+ ```
337
+
338
+ ### Health Checks
339
+
340
+ - `GET /health` - Detailed health status with stats
341
+ - `GET /health/ready` - Readiness probe
342
+ - `GET /health/live` - Liveness probe
343
+
344
+ ---
345
+
346
+ ## MCP Tools (SSE)
347
+
348
+ The MCP server exposes tools via Server-Sent Events (SSE):
349
+
350
+ - **SSE Endpoint:** `GET /sse` and `POST /sse/message`
351
+ - **Alias:** `GET /mcp` and `POST /mcp/message`
352
+
353
+ ### Available Chart Tools
354
+
355
+ All tools are defined in `src/mcp/registerTools.ts` and include:
356
+
357
+ - **Basic Charts:** Bar, Line, Lollipop, Area (simple, grouped, stacked, cumulative)
358
+ - **Advanced Charts:** Sankey, Treemap, Histogram, Bubble, Scatterplot, Boxplot, Punchcard
359
+ - **Specialized:** SparkLine, SparkArea, KPIs, Map (with multiple layer types)
360
+ - **ML/Stats:** KS Plot, ROC Curve, Gini Impurity & Entropy, Violin, Partial Dependence, Bias-Variance Tradeoff
361
+ - **Q-Q Plot:** Scatterplot with reference line option
362
+
363
+ All tools return an `externalUrl` UI resource that embeds the charting application with the signed data link.
364
+
365
+ ---
366
+
367
+ ## Storage
368
+
369
+ Chart payloads are stored as JSON files in the `STORAGE_DIR` directory (default: `.data/`):
370
+
371
+ - Each data link is saved as `{id}.json`
372
+ - Files are automatically cleaned up when expired (TTL check on access)
373
+ - Storage directory is created automatically if it doesn't exist
374
+
375
+ **Location:** `{STORAGE_DIR}/{id}.json` relative to the project root (or container working directory).
376
+
377
+ ---
378
+
379
+ ## Development
380
+
381
+ ### Scripts
382
+
383
+ - `pnpm run mcp:serve` - Run the MCP Node.js server (Express + SSE)
384
+ - `pnpm run dev` - Run the React Router UI in development mode
385
+ - `pnpm run build` - Build the React Router application
386
+ - `pnpm run typecheck` - Type check the codebase
387
+ - `pnpm test` - Run tests
388
+ - `pnpm run lint` - Lint code
389
+ - `pnpm run lint:fix` - Fix linting issues
390
+
391
+ ### Project Structure
392
+
393
+ ```
394
+ src/
395
+ ├── mcp-node.ts # Express server + MCP initialization
396
+ ├── mcp/
397
+ │ └── registerTools.ts # MCP tool definitions
398
+ ├── api/
399
+ │ ├── healthCheck.ts # Health check handlers
400
+ │ └── handleDataLink.ts # Data link API handlers
401
+ └── utils/
402
+ ├── dataLinkStore.ts # Filesystem-based TTL storage
403
+ ├── dataLinkHandlers.ts # CORS, validation, rate limiting
404
+ └── createChartData.ts # Helper for chart data links
405
+ ```
406
+
407
+ ---
408
+
409
+ ## Docker Details
410
+
411
+ ### Build Process
412
+
413
+ The Dockerfile:
414
+ 1. Extracts the `PORT` value from the specified `ENV_FILE` during build
415
+ 2. Displays the extracted port in build logs
416
+ 3. Copies the environment file as `.env` for runtime use
417
+ 4. Runs the MCP server with `pnpm run mcp:serve`
418
+
419
+ ### Build Arguments
420
+
421
+ - `ENV_FILE` - Environment file to use (default: `env.prod`)
422
+
423
+ ### Example Build & Run
424
+
425
+ ```bash
426
+ # Build with custom env file
427
+ docker build --build-arg ENV_FILE=env.prod -t mcp-ui .
428
+
429
+ # Check the PORT value in build logs (look for "PORT extracted from env.prod: XXXX")
430
+
431
+ # Run with the extracted port
432
+ docker run -p 5173:5173 mcp-ui
433
+
434
+ # Run with persistent storage
435
+ docker run -p 5173:5173 -v ${PWD}/.data:/app/.data mcp-ui
436
+
437
+ # Run in background
438
+ docker run -d -p 5173:5173 --name mcp-ui-container mcp-ui
439
+
440
+ # View logs
441
+ docker logs mcp-ui-container
442
+
443
+ # Stop container
444
+ docker stop mcp-ui-container
445
+ ```
446
+
447
+ ---
448
+
449
+ ## Security Notes
450
+
451
+ - **Use a strong `MCP_DATA_LINK_SECRET`** in production
452
+ - **Restrict `CORS_ALLOWED_ORIGINS`** to specific domains instead of `*`
453
+ - **Adjust `DATA_LINK_TTL_HOURS`** based on your data retention requirements
454
+ - **Rate limiting** can be enabled in `src/utils/dataLinkHandlers.ts`
455
+
456
+ ---
457
+
458
+ ## FAQ
459
+
460
+ **Q: Where are data files stored?**
461
+ A: In the `STORAGE_DIR` directory (default: `.data/`) relative to the project root. Files are named `{id}.json`.
462
+
463
+ **Q: How are charts rendered?**
464
+ A: MCP Apps View (`ui://ui9000/chart`) plus `_meta.dataUrl`. There is no `apps/charts` iframe.
465
+
466
+ **Q: How do I enforce strict CORS?**
467
+ A: Set `CORS_ALLOWED_ORIGINS` to a comma-separated list of allowed domains: `CORS_ALLOWED_ORIGINS=https://example.com,https://other.com`
468
+
469
+ **Q: What port does the server use?**
470
+ A: The port is read from the `PORT` environment variable (in `.env` file). Default is `8088`.
471
+
472
+ **Q: How do I check if the server is running?**
473
+ A: Visit `http://localhost:<PORT>/health` or use the health check endpoints.
474
+
475
+ ---
476
+
477
+ ## Publish to npm
478
+
479
+ From this repo (must be logged in to an npm user/org that can publish `@fusedashlabs/*`):
480
+
481
+ ```bash
482
+ pnpm install
483
+ pnpm build:npm
484
+ npm publish --access public
485
+ ```
486
+
487
+ CI: push a `v*` / `mcp-v*` tag or run the **Publish npm** workflow. Set GitHub secret `NPM_TOKEN`.
488
+
489
+ After publish, Cursor/Claude use `npx -y @fusedashlabs/ui9000-mcp` with server key `UI9000-MCP` (see top of this README).
490
+
491
+ ---
492
+
493
+ ## License
494
+
495
+ Apache-2.0