@tradecanvas/mcp 0.0.0-stage → 1.32.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TradeCanvas Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ # @tradecanvas/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An [MCP](https://modelcontextprotocol.io) server for [TradeCanvas](https://tradecanvas.dev/), so a coding agent looks names up instead of guessing them. It answers from a catalog generated from the library's own code: the same version, the same names.
4
+
5
+ ```bash
6
+ claude mcp add tradecanvas -- npx -y @tradecanvas/mcp
7
+ ```
8
+
9
+ On Windows outside WSL, npx starts through `cmd`:
10
+
11
+ ```bash
12
+ claude mcp add tradecanvas -- cmd /c npx -y @tradecanvas/mcp
13
+ ```
14
+
15
+ Cursor, Claude Desktop and most other clients take the same command in their MCP settings (on Windows, `"command": "cmd", "args": ["/c", "npx", "-y", "@tradecanvas/mcp"]`):
16
+
17
+ ```json
18
+ {
19
+ "mcpServers": {
20
+ "tradecanvas": { "command": "npx", "args": ["-y", "@tradecanvas/mcp"] }
21
+ }
22
+ }
23
+ ```
24
+
25
+ ## Tools
26
+
27
+ All of them read only; none touches the network or your files.
28
+
29
+ | Tool | What it answers |
30
+ |---|---|
31
+ | `list_indicators` | The built-in indicators: id, name, and whether it draws over the price or in a pane. Search by words. |
32
+ | `get_indicator` | One indicator in full: default params, inputs, the keys of its lines (RSI's is `value`, not `rsi`), levels, and code that adds it and reads it. |
33
+ | `list_drawing_tools` | The drawing tools: the `type` that `addDrawing` and `setDrawingTool` take, the points each needs, its options. |
34
+ | `list_options` | The options of `ChartWidget`, `Chart` or `ChartWidgetGrid`: name, TypeScript type, doc, allowed values. |
35
+ | `list_widget_features` | The names `ChartWidget`'s `features` switch takes. |
36
+ | `list_style_keys` | The chart's style keys and the value each takes, for `overrides` and `applyOverrides`. |
37
+ | `validate_options` | Checks an options object before it is used: unknown names with the one likely meant, values outside the allowed ones, numbers given as strings, intervals, feature switches, style overrides, languages, and nested options. |
38
+
39
+ A check, for instance:
40
+
41
+ ```json
42
+ { "target": "ChartWidget", "options": { "timeFrame": "5m", "chartType": "line", "locale": "ja" } }
43
+ ```
44
+
45
+ ```text
46
+ - timeFrame: Unknown option 'timeFrame' for ChartWidget. Did you mean 'timeframe'?
47
+ - chartType: Unknown option 'chartType' for ChartWidget. It is a Chart option: on ChartWidget it goes in `chartOptions`.
48
+ Note: 日本語 ('ja') is not built into the widget: call registerWidgetLocales() from '@tradecanvas/chart/widget/locales' before creating it.
49
+ ```
50
+
51
+ ## Also
52
+
53
+ - The agent skill teaches the API itself, with worked examples: `/plugin marketplace add bonguynvan/tradecanvas` in Claude Code, or `npx skills add bonguynvan/tradecanvas`.
54
+ - [llms.txt](https://tradecanvas.dev/llms.txt) and [llms-full.txt](https://tradecanvas.dev/llms-full.txt) hold the docs in one file.
55
+
56
+ Node 20.19 or later. MIT.
@@ -0,0 +1,65 @@
1
+ /** A built-in indicator: what `chart.addIndicator(id, params)` takes and what it draws. */
2
+ export interface IndicatorEntry {
3
+ id: string;
4
+ name: string;
5
+ shortName: string;
6
+ placement: 'overlay' | 'panel';
7
+ params: Record<string, unknown>;
8
+ inputs?: Record<string, unknown>;
9
+ plots: {
10
+ key: string;
11
+ title: string;
12
+ kind: string;
13
+ }[];
14
+ levels?: number[];
15
+ scale?: unknown;
16
+ }
17
+ /** A built-in drawing tool: its `type`, and the points (`anchors`) it takes. */
18
+ export interface DrawingToolEntry {
19
+ type: string;
20
+ name: string;
21
+ anchors: number;
22
+ creation?: string;
23
+ options?: Record<string, {
24
+ kind: string;
25
+ label: string;
26
+ default: unknown;
27
+ }>;
28
+ }
29
+ /** One option of an entry point, read from its TypeScript declaration. */
30
+ export interface OptionEntry {
31
+ name: string;
32
+ /** The type as written in the declaration. */
33
+ type: string;
34
+ doc?: string;
35
+ /** The only values it takes, when its type is a union of strings or numbers. */
36
+ values?: (string | number)[];
37
+ /** The values each item takes, when it is an array of such a union. */
38
+ items?: (string | number)[];
39
+ /** The one plain kind of value it takes, when it is that simple. */
40
+ kind?: 'boolean' | 'number' | 'string' | 'function';
41
+ }
42
+ export type Target = 'ChartWidget' | 'Chart' | 'ChartWidgetGrid';
43
+ export declare const TARGETS: readonly Target[];
44
+ export interface Catalog {
45
+ indicators: IndicatorEntry[];
46
+ drawingTools: DrawingToolEntry[];
47
+ chartTypes: string[];
48
+ /** The named intervals; `isTimeFrame` also takes any `<n><s|m|h|d|w|M>` and `<n>T`. */
49
+ timeframes: string[];
50
+ widgetFeatures: string[];
51
+ /** Each style key and the kind of value it takes: color, boolean, lineStyle or width. */
52
+ styleKeys: Record<string, string>;
53
+ looks: string[];
54
+ languages: {
55
+ code: string;
56
+ name: string;
57
+ builtIn: boolean;
58
+ }[];
59
+ options: Record<Target, OptionEntry[]>;
60
+ /** Nested option objects, by `<entry>.<option>`: `Chart.features`. */
61
+ nested: Record<string, OptionEntry[]>;
62
+ }
63
+ /** Generated from the code by scripts/gen-ai-docs.mjs. */
64
+ export declare const CATALOG: Catalog;
65
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,gFAAgF;AAChF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC7E;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,C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@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import { i as createServer, t as splitLines } from "./server.js";
3
+ //#region src/cli.ts
4
+ var server = createServer({ version: "1.32.0" });
5
+ var pending = "";
6
+ function answer(chunk, ended) {
7
+ const { lines, rest } = splitLines(pending, chunk, ended);
8
+ pending = rest;
9
+ for (const line of lines) {
10
+ const reply = server.handleLine(line);
11
+ if (reply) process.stdout.write(`${reply}\n`);
12
+ }
13
+ }
14
+ process.stdin.setEncoding("utf8");
15
+ process.stdin.on("data", (chunk) => answer(chunk, false));
16
+ process.stdin.on("end", () => answer("", true));
17
+ //#endregion
@@ -0,0 +1,10 @@
1
+ export { createServer, PROTOCOLS, LATEST_PROTOCOL } from './server.js';
2
+ export type { Server, Response } from './server.js';
3
+ export { TOOLS, runTool } from './tools.js';
4
+ export type { ToolDefinition, ToolResult } from './tools.js';
5
+ export { validateOptions } from './validate.js';
6
+ export type { Problem, Validation } from './validate.js';
7
+ export { CATALOG, TARGETS } from './catalog.js';
8
+ export type { Catalog, Target, IndicatorEntry, DrawingToolEntry, OptionEntry } from './catalog.js';
9
+ export { splitLines } from './lines.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5C,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { a as TOOLS, c as CATALOG, i as createServer, l as TARGETS, n as LATEST_PROTOCOL, o as runTool, r as PROTOCOLS, s as validateOptions, t as splitLines } from "./server.js";
2
+ export { CATALOG, LATEST_PROTOCOL, PROTOCOLS, TARGETS, TOOLS, createServer, runTool, splitLines, validateOptions };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The stdio transport sends one JSON message a line. Splits what has arrived
3
+ * into whole lines (blank ones dropped, a `\r` before the `\n` too) and keeps
4
+ * the unfinished end for the next chunk; at the end of input (`ended`) that
5
+ * end is a message too, newline or not.
6
+ */
7
+ export declare function splitLines(pending: string, chunk: string, ended?: boolean): {
8
+ lines: string[];
9
+ rest: string;
10
+ };
11
+ //# sourceMappingURL=lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../src/lines.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAK3G"}
@@ -0,0 +1,32 @@
1
+ import { Catalog } from './catalog.js';
2
+ /** The protocol versions this server speaks, newest first. */
3
+ export declare const PROTOCOLS: readonly ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
4
+ export declare const LATEST_PROTOCOL: "2025-11-25";
5
+ type Id = string | number | null;
6
+ export type Response = {
7
+ jsonrpc: '2.0';
8
+ id: Id;
9
+ result: unknown;
10
+ } | {
11
+ jsonrpc: '2.0';
12
+ id: Id;
13
+ error: {
14
+ code: number;
15
+ message: string;
16
+ };
17
+ };
18
+ export interface Server {
19
+ /**
20
+ * Answers one JSON-RPC message, or a batch of them with an array; null when
21
+ * nothing needs an answer (notifications, and responses: the server asks nothing).
22
+ */
23
+ handle(message: unknown): Response | Response[] | null;
24
+ /** Answers one line of the stdio transport, as a line to write back (null: nothing to write). */
25
+ handleLine(line: string): string | null;
26
+ }
27
+ /** The TradeCanvas MCP server: tools only, every one of them read-only. */
28
+ export declare function createServer(info: {
29
+ version: string;
30
+ }, catalog?: Catalog): Server;
31
+ export {};
32
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAGrD,8DAA8D;AAC9D,eAAO,MAAM,SAAS,mEAAoE,CAAC;AAC3F,eAAO,MAAM,eAAe,cAAe,CAAC;AAS5C,KAAK,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEjC,MAAM,MAAM,QAAQ,GAChB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC3C;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,EAAE,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAezE,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC;IACvD,iGAAiG;IACjG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,GAAE,OAAiB,GAAG,MAAM,CA+E1F"}