@bicharts/chart-mcp 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/LICENSE.txt ADDED
@@ -0,0 +1,134 @@
1
+ BIC Chart MCP Server (@bicharts/chart-mcp)
2
+ Copyright (c) 2026 CodeX Enterprises LLC. All rights reserved.
3
+
4
+ This is proprietary software, distributed as a built bundle. It is NOT open source
5
+ and is NOT covered by the Apache-2.0 licence that applies to @bicharts/chart-host
6
+ and @bicharts/shape-core.
7
+
8
+ Two documents govern, and they cover different things:
9
+
10
+ * THIS FILE governs the SOFTWARE — the bundle in this package. It is fixed to the
11
+ version you installed and does not change under you.
12
+ * The BIC Terms of Use at https://bizintelligencechampions.com/terms-llmchart, plus
13
+ your account agreement, govern the SERVICE this software calls and your account.
14
+ Those can change over time, as service terms do.
15
+
16
+ Where the two conflict, this file controls the software and the online terms control
17
+ the service and the account.
18
+
19
+
20
+ 1. GRANT
21
+ --------
22
+ You are granted a non-exclusive, non-transferable, revocable licence to install and
23
+ run this software for the purpose of accessing the BIC chart generation service with
24
+ a valid BIC trial or paid account.
25
+
26
+ Installing it as a dependency of your own project, and redistributing it unmodified
27
+ through a normal package manager as part of that project's dependency tree, is
28
+ expressly permitted.
29
+
30
+
31
+ 2. GENERATED OUTPUT IS YOURS
32
+ ----------------------------
33
+ The chart code, sample data, preview files and other output this software writes for
34
+ you ("Output") are yours. CodeX Enterprises LLC claims no ownership of Output and
35
+ asserts no licence over it. Use it, modify it, commit it, ship it, sell it — including
36
+ commercially, including after you stop paying us, including forever. Nothing in this
37
+ licence or the service terms requires a running account, a network connection, or any
38
+ further payment in order to keep using Output you have already received.
39
+
40
+ That is the product, not a concession: a generated chart is source you own, not a
41
+ service you call.
42
+
43
+ Two things to understand about what that ownership does and does not mean.
44
+
45
+ NOT EXCLUSIVE. Output is generated from your data by an automated system that
46
+ serves many customers. Another customer with similar data may receive similar or
47
+ substantially identical Output, and we may generate such Output for them. Your
48
+ ownership of your Output does not prevent that, and cannot.
49
+
50
+ YOUR RISK. Output is produced by an automated system, including large language
51
+ models. It is not reviewed by us before you receive it, and it can be wrong: it can
52
+ misrepresent your data, compute the wrong thing, fail to render, behave unexpectedly
53
+ in your application, or resemble other work. YOU ARE SOLELY RESPONSIBLE for
54
+ reviewing, testing, securing and validating any Output before relying on it, and you
55
+ accept all risk and all liability arising from your use of it. We provide no
56
+ warranty of any kind as to Output — including no warranty of correctness, accuracy,
57
+ fitness for any purpose, security, or non-infringement.
58
+
59
+ Output executes as code in your application. Treat it as you would any code you
60
+ accept into your codebase: read it, test it, and take responsibility for it.
61
+
62
+
63
+ 3. WHAT REMAINS OURS
64
+ --------------------
65
+ Your ownership of Output does not transfer any right in the MEANS of producing it.
66
+ CodeX Enterprises LLC retains all right, title and interest in this software, the BIC
67
+ backend service, and everything behind it — the chart-type selection engine, prompts,
68
+ rules, guardrails, correctness gates, quality-control passes, models, weights,
69
+ telemetry, and all related intellectual property. No licence to any of it is granted
70
+ by implication, estoppel or otherwise.
71
+
72
+ In short: the chart is yours; the machine that made it is ours.
73
+
74
+
75
+ 4. RESTRICTIONS
76
+ ---------------
77
+ You may not:
78
+
79
+ * reverse engineer, decompile, or disassemble this software, except to the extent
80
+ that applicable law expressly permits despite this limitation;
81
+ * remove or alter this notice or any proprietary marking;
82
+ * redistribute this software, or a modified form of it, as your own product or as
83
+ part of a competing product or service;
84
+ * use this software or the service to build, train, or improve a competing chart
85
+ generation product or model, including by systematically collecting Output for
86
+ that purpose;
87
+ * access the BIC backend other than through a valid account, or circumvent account
88
+ limits, metering, rate limiting, or credit accounting.
89
+
90
+
91
+ 5. THIRD-PARTY COMPONENTS
92
+ -------------------------
93
+ This package depends on separately licensed open-source software, each under its own
94
+ terms, including @bicharts/chart-host and @bicharts/shape-core (Apache-2.0, which
95
+ embed geographic reference data from GeoNames under CC BY 4.0 — see the NOTICE file in
96
+ those packages), @modelcontextprotocol/sdk, papaparse, and zod. Nothing in this licence
97
+ limits your rights under theirs.
98
+
99
+
100
+ 6. NO WARRANTY
101
+ --------------
102
+ THE SOFTWARE AND ALL OUTPUT ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
103
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
104
+ FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, AND NONINFRINGEMENT. WE DO NOT WARRANT
105
+ THAT THE SOFTWARE OR THE SERVICE WILL BE UNINTERRUPTED, ERROR-FREE, OR THAT ANY
106
+ OUTPUT WILL BE CORRECT OR SUITABLE FOR ANY PURPOSE.
107
+
108
+
109
+ 7. LIMITATION OF LIABILITY
110
+ --------------------------
111
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL CODEX ENTERPRISES LLC BE
112
+ LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, EXEMPLARY OR PUNITIVE
113
+ DAMAGES, OR FOR ANY LOSS OF PROFITS, REVENUE, DATA, OR BUSINESS, ARISING OUT OF OR IN
114
+ CONNECTION WITH THIS SOFTWARE, THE SERVICE, OR ANY OUTPUT, WHETHER IN CONTRACT, TORT
115
+ OR OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. OUR TOTAL AGGREGATE
116
+ LIABILITY SHALL NOT EXCEED THE AMOUNT YOU PAID US FOR THE SERVICE IN THE TWELVE MONTHS
117
+ PRECEDING THE CLAIM.
118
+
119
+ Some jurisdictions do not allow certain exclusions or limitations, in which case the
120
+ above apply to the greatest extent permitted, and nothing here limits liability that
121
+ cannot lawfully be limited.
122
+
123
+
124
+ 8. SERVICE, CREDITS AND TERMINATION
125
+ -----------------------------------
126
+ Use of the BIC backend through this software consumes credits and is governed by the
127
+ Terms of Use and your account agreement. This licence terminates automatically if you
128
+ materially breach it. On termination you must stop using this software — but your
129
+ rights in Output you already received survive, permanently and unconditionally.
130
+
131
+ Sections 2, 3, 5, 6, 7 and this sentence survive termination.
132
+
133
+
134
+ Questions: info@bizintelligencechampions.com
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # @bicharts/chart-mcp (experimental)
2
+
3
+ An MCP (Model Context Protocol) stdio server that lets any MCP-capable AI client
4
+ (Claude Code, Claude Desktop, Copilot Studio, Cursor, …) use the BIC chart engine:
5
+
6
+ - **`assess_data_shape`** — profiles a CSV **locally** with the same measurement
7
+ engine the Power BI visual uses (`@bicharts/shape-core`). No backend call, no
8
+ credentials, no data leaves the machine. The free-teaser tool.
9
+ - **`list_eligible_charts`** — the **authoritative** list of chart types that can
10
+ render this data (server-side policy, not a local guess; **zero-credit**, no LLM).
11
+ By default it **auto-detects the project's language** (JS/TS vs Python from the
12
+ working dir) and returns the charts for THAT language — **scoped to its renderers
13
+ and ranked by the picker's chart-type×renderer weights** (best first), each tagged
14
+ with its **source language** (JavaScript for D3/Vega, Python for Plotly/matplotlib),
15
+ its renderer, and a 0–100 score. Pass `language: "javascript"|"python"` to force it,
16
+ `renderer: "D3"/"PLOTLY"/…` to rank one specific renderer, or `renderer: ""` for the
17
+ full **renderer-agnostic** eligibility across all renderers (unranked — the wide "what
18
+ *can* render" net). `top: N` trims to the best N. If the language can't be auto-detected
19
+ and none is given, the tool asks you to specify one. Credentials optional (a license
20
+ only unlocks *draft* types).
21
+ - **`generate_chart`** — profiles locally, then calls the BIC backend, which picks
22
+ an eligible chart type for the measured shape (or honors `chart_type`) and
23
+ returns code that has passed the backend's gates/QC. Renderer selection is the same
24
+ **language-aware** intersection: with no explicit `renderer`, the detected/`language`
25
+ narrows the backend's auto renderer pick to that language (JS → D3/Vega, Python →
26
+ Plotly/matplotlib); an explicit `renderer` always wins. For D3 output, passing
27
+ **`preview_html: true`** alongside `out_dir` also writes a standalone `preview.html`
28
+ you can open with no build step. It is **off by default** — the code is meant to be
29
+ merged into your app, not run as an index.html.
30
+
31
+ ## Language & renderer
32
+
33
+ Both list/generate tools speak **language** (what your project is written in) as well as
34
+ **renderer** (a specific chart library). The server maps `javascript`/`typescript` → D3 +
35
+ Vega and `python` → Plotly + matplotlib, and the picker's weights rank across that
36
+ language's renderers. Precedence is **explicit `renderer` > `language` > auto-detected
37
+ language**. The MCP sniffs the working directory (or `project_dir`) for language markers
38
+ (`package.json`/`tsconfig.json` → JS, `pyproject.toml`/`requirements.txt` → Python) plus a
39
+ bounded source-file count; when the signal is genuinely mixed or absent it asks you to
40
+ pick rather than silently assuming one.
41
+
42
+ ## Data inputs — CSV or a pre-typed table
43
+
44
+ Both tools accept, as alternatives:
45
+
46
+ - `csv_path` / `csv_text` — a CSV; column types and measure/dimension roles are
47
+ **inferred** (numeric-non-identifier = measure), and you can steer them with the
48
+ `measures`/`dimensions`/`formats`/`descriptions` levers.
49
+ - `data: { columns, rows }` — a **pre-typed table**, the shape a **Fabric DAX
50
+ Execute-Queries result**, a dataframe, or an arrow table already has. `columns`
51
+ carry `name` and (optionally) `dataType`, `isMeasure`, `format`, `description`;
52
+ `rows` are positional arrays **or** objects keyed by column name. When a caller
53
+ supplies `isMeasure` + `format` + `description` from a semantic model, the shape
54
+ matches Power BI fidelity with **no heuristic guessing** — the profiler engine
55
+ is the same one the visual runs; CSV was only ever one adapter over it.
56
+
57
+ Example (a semantic-model query result):
58
+
59
+ ```json
60
+ {
61
+ "data": {
62
+ "columns": [
63
+ { "name": "Region", "dataType": "String", "isMeasure": false },
64
+ { "name": "Revenue", "dataType": "Decimal", "isMeasure": true,
65
+ "format": "$#,##0", "description": "Net booked revenue" }
66
+ ],
67
+ "rows": [ { "Region": "West", "Revenue": 12000.5 }, { "Region": "East", "Revenue": 9000 } ]
68
+ }
69
+ }
70
+ ```
71
+
72
+ ## Build
73
+
74
+ ```powershell
75
+ cd mcp
76
+ npm install
77
+ npm run build # bundles to dist/index.mjs (single file)
78
+ ```
79
+
80
+ ## Credentials (generate_chart only)
81
+
82
+ **A trial or paid BIC account is required — no freemium.** Use the same
83
+ **License Key**, **Licensee**, and **Secret Key** from your BIC account (the ones
84
+ the Power BI visual's license settings use). `assess_data_shape` needs no
85
+ credentials at all (it runs entirely locally).
86
+
87
+ Two ways to supply them — env wins over the file:
88
+
89
+ **1. Env vars** (via the MCP server's `env` block — see registration below):
90
+
91
+ | Var | Meaning |
92
+ | --- | --- |
93
+ | `BIC_LICENSE_KEY` | required |
94
+ | `BIC_LICENSEE` | required (account name) |
95
+ | `BIC_SECRET_KEY` | optional |
96
+ | `BIC_URL` | override backend (default `https://bizintelligencechampions.com`) |
97
+ | `BIC_MCP_REASONING` | OPTIONAL override of the default reasoning mode (else `""` = leave-to-visual, same as the PBI visual) |
98
+ | `BIC_MCP_MODEL` | OPTIONAL override of the default model (else `""` = the account's IsDefault model, same as the visual) |
99
+
100
+ **Defaults match the Power BI visual.** Unset, the MCP sends `model=""` (server
101
+ resolves the `IsDefault` model), `reasoning_mode=""` (leave-to-visual heuristic), and
102
+ `privacy_level="20"` (detailed stats, **no sample rows** — see below). The two env
103
+ vars above are escape hatches only; leave them unset for visual parity.
104
+
105
+ ### Response timeouts (HTTP 499 / dropped connection)
106
+
107
+ The backend completes long multi-pass generations (the visual regularly runs several
108
+ minutes on rich charts). A dropped connection is therefore a **delivery timeout in
109
+ the calling path** — the MCP host's tool-call timeout or an intermediary proxy — not
110
+ a server ceiling, and not a generation failure (the chart likely generated and may
111
+ have been billed). The parity-preserving fix is to **let the call take as long as it
112
+ needs**:
113
+
114
+ - **Built in:** the server sends MCP progress notifications every 10s during a
115
+ generation; spec-compliant hosts (including Claude Code) reset their per-call
116
+ timeout on progress, so the call stays alive as long as the generation needs —
117
+ no user configuration required.
118
+ - Fallback for hosts that don't reset on progress: raise the host's per-tool
119
+ timeout (Claude Code: `MCP_TOOL_TIMEOUT` in ms, set in the environment Claude
120
+ Code itself runs in — e.g. the `env` block of `settings.json`).
121
+ - (Planned) retrieve an already-generated result by `correlationId` so a dropped
122
+ connection recovers the billed code instead of re-generating.
123
+
124
+ `BIC_MCP_REASONING=CP`/`1P` *would* finish faster, but that trades away visual parity
125
+ (no validator) — prefer raising the timeout.
126
+
127
+ **2. A credentials file** — so secrets never sit in a project-committed
128
+ `.mcp.json`. Default `~/.bic/credentials.json` (override with
129
+ `BIC_CREDENTIALS_FILE`):
130
+
131
+ ```json
132
+ { "licenseKey": "…", "licensee": "…" }
133
+ ```
134
+
135
+ (`secretKey` optional.)
136
+
137
+ Prefer the file, or a **user-scoped** `claude mcp add` (stored in your user
138
+ config), over putting secrets in a repo-committed `.mcp.json`.
139
+
140
+ Note: this package deliberately does NOT contain the freemium key-mint secret —
141
+ consistent with trial/paid-only access, and safe if the folder is ever published.
142
+
143
+ ### Credit charges
144
+
145
+ Each `generate_chart` call spends credits on your account, exactly like the Power BI
146
+ visual (the MCP hits the same billed endpoint):
147
+
148
+ - **Hosted** (our models) → **token-based** — you pay for the tokens the generation
149
+ actually used.
150
+ - **BYO** (your own API key) → a **flat operating fee per request**. The MCP/SDK
151
+ surface has its own dial (`LLMSdkByoOperatingCost`, default **3 credits**),
152
+ separate from the visual's fee, so it can be priced independently.
153
+
154
+ The response header line shows `credits: N` so you can see what each call cost.
155
+
156
+ ## Register with Claude Code
157
+
158
+ ```powershell
159
+ claude mcp add --scope user bic-chart -- npx -y @bicharts/chart-mcp
160
+ ```
161
+
162
+ `--scope user` stores it in your user config so it works in every project. With
163
+ credentials in `~/.bic/credentials.json` you need no `-e` flags at all; add them only
164
+ if you prefer env vars:
165
+
166
+ ```powershell
167
+ claude mcp add --scope user bic-chart -e BIC_LICENSE_KEY=... -e BIC_LICENSEE=... -- npx -y @bicharts/chart-mcp
168
+ ```
169
+
170
+ or in a project `.mcp.json`:
171
+
172
+ ```json
173
+ {
174
+ "mcpServers": {
175
+ "bic-chart": {
176
+ "command": "npx",
177
+ "args": ["-y", "@bicharts/chart-mcp"]
178
+ }
179
+ }
180
+ }
181
+ ```
182
+
183
+ Claude Desktop uses the same `command`/`args`/`env` block in
184
+ `claude_desktop_config.json` under `mcpServers`.
185
+
186
+ **Developing on the server itself?** Point at your build instead, so you are not
187
+ running whatever npx last cached:
188
+
189
+ ```powershell
190
+ claude mcp add --scope user bic-chart-dev -- node c:/Source/PowerBI_Controls/llmchart/mcp/dist/index.mjs
191
+ ```
192
+
193
+ The ready banner prints the build stamp, which is how you tell the two apart.
194
+
195
+ Try: *"Assess the shape of testharness/datasets/divisional_revenue_by_year.csv,
196
+ then generate a chart for it and write the preview to ./out."*
197
+
198
+ ## Wire notes
199
+
200
+ Wire-compatible with the visual/harness envelope (see
201
+ `testharness/harness/client.py`, the reference implementation): gzip→base64→`.`
202
+ body, FNV X-Signature, `clientVersion >= 2.0.0.0`, plus `host: "SDK"` so prompts
203
+ resolve to the generic host profile once server rev 144 + tokenized config are
204
+ live (older servers ignore the field — deployment-order safe).
205
+
206
+ ## Publishing (when the experiment proves out — NOT yet)
207
+
208
+ 1. Keep `"private": true` until the conscious decision to release.
209
+ 2. Publish **built artifacts only** (`files: ["dist"]` already enforces this —
210
+ the tarball carries the bundled `dist/index.mjs`, no source, no history).
211
+ 3. `npm publish --access public` under the org scope; users then configure
212
+ `"command": "npx", "args": ["-y", "@bicharts/chart-mcp"]` — zero-install.
213
+ 4. List in MCP registries/directories for discoverability.
214
+ 5. shape-core rides inside the bundle minified (shared, not shown); the
215
+ open-source decision for readable source is separate and deferred.