@lineadraw/mcp 0.1.0 → 0.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.
Files changed (3) hide show
  1. package/README.md +98 -85
  2. package/dist/editor.html +130 -130
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,85 +1,98 @@
1
- # @lineadraw/mcp
2
-
3
- MCP server for Linea CAD documents, with the **full Linea editor in chat**
4
- (MCP Apps extension): Claude creates/edits documents through tools and opens
5
- them as a fully interactive editor directly in the conversation — the user
6
- can draw, snap, dimension, and edit, and their changes flow back into the
7
- same document Claude's tools operate on.
8
-
9
- ## Run
10
-
11
- ```bash
12
- npm run build -w @lineadraw/mcp # bundles the editor into dist/editor.html
13
- npm run serve -w @lineadraw/mcp # streamable HTTP on http://localhost:3001/mcp
14
- ```
15
-
16
- MCP server definition
17
-
18
- ```json
19
- "mcpServers": {
20
- "linea": {
21
- "command": "node",
22
- "args": [
23
- "C:\\Users\\MikhailKoshelev\\source\\repos\\linea\\packages\\mcp\\dist\\server.js",
24
- "--stdio"
25
- ]
26
- }
27
- }
28
- ```
29
-
30
- Claude (web and Desktop) requires an **https** connector URL. Two options:
31
-
32
- **Tunnel** (no account, URL changes each run, briefly internet-reachable):
33
-
34
- ```bash
35
- npx cloudflared tunnel --url http://localhost:3001
36
- ```
37
-
38
- **Local TLS with [mkcert](https://github.com/FiloSottile/mkcert)** (nothing
39
- leaves your machine; the mkcert CA lands in the Windows/macOS trust store,
40
- which Claude Desktop honors):
41
-
42
- ```powershell
43
- mkcert -install
44
- mkcert localhost
45
- $env:TLS_CERT="localhost.pem"; $env:TLS_KEY="localhost-key.pem"; npm run serve -w @lineadraw/mcp
46
- ```
47
-
48
- Settings → Connectors → Add custom connector → the https URL + `/mcp`
49
- (e.g. `https://localhost:3001/mcp`). The MCP endpoint answers on `/` too.
50
-
51
- `node probe.mjs <url>` checks any URL the way a host would (GET probe + full
52
- handshake + a tool call).
53
-
54
- ## Tools
55
-
56
- `linea_new_document` · `linea_open_document` · `linea_save_document` ·
57
- `linea_add_objects` (model space or `layout`) · `linea_update_objects`
58
- (per-id patches) · `linea_remove_objects` · `linea_transform`
59
- (move/rotate/scale/mirror/copy/array; degrees) · `linea_create_layout` ·
60
- `linea_summary` · `linea_get_document` · `linea_replace_document` (full-state
61
- save used by the in-chat editor) · `linea_export` (svg/png/pdf/dxf) ·
62
- **`linea_show_document`** — opens the in-chat editor.
63
-
64
- ## The in-chat editor
65
-
66
- `ui-editor/` bundles the real `@lineadraw/editor` (React + Tailwind v4 + Inter)
67
- into ONE self-contained `dist/editor.html` (~5 MB) — the sandboxed iframe's
68
- CSP allows no external assets. `linea_show_document` renders it with the
69
- document pushed as the tool result. Committed edits are debounced into
70
- `linea_replace_document`, so the conversation's granular tools and the
71
- interactive editor share one source of truth (the server registry). Foreign
72
- changes (Claude's tool calls) are detected by revision polling and remount
73
- the editor with the camera restored.
74
-
75
- Sizing: the app reports a real content height (720px inline) through the
76
- protocol's auto-resize and fills the frame under the host's `fullscreen`
77
- display mode. Placement is the host's decision — the protocol offers
78
- `inline | fullscreen | pip` only, so a persistent "panel right of the chat"
79
- isn't requestable today.
80
-
81
- Open `dist/editor.html#demo` in a browser to develop the editor app
82
- standalone (loads a built-in document, no MCP host needed).
83
-
84
- In-chat caveat: disk-oriented menu items (Open/Save As) are limited by the
85
- iframe sandbox — save through the conversation via `linea_save_document`.
1
+ # @lineadraw/mcp
2
+
3
+ MCP server for [Linea](https://lineadraw.com) CAD documents, with the **full
4
+ Linea editor in chat** (MCP Apps extension): the agent creates and edits
5
+ documents through tools and opens them as a fully interactive editor directly
6
+ in the conversation — you can draw, snap, dimension, and edit, and your
7
+ changes flow back into the same document the agent's tools operate on.
8
+
9
+ Requires Node.js >= 20.
10
+
11
+ ## Use with an MCP client (stdio)
12
+
13
+ Add to your client's MCP configuration (Claude Desktop, Cursor, etc.):
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "lineadraw": {
19
+ "command": "npx",
20
+ "args": ["-y", "@lineadraw/mcp", "--stdio"]
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Claude Code:
27
+
28
+ ```bash
29
+ claude mcp add linea -- npx -y @lineadraw/mcp --stdio
30
+ ```
31
+
32
+ ## Use as an HTTP connector
33
+
34
+ Without `--stdio` the server speaks streamable HTTP on
35
+ `http://localhost:3001/mcp` (`PORT` overrides):
36
+
37
+ ```bash
38
+ npx -y @lineadraw/mcp
39
+ ```
40
+
41
+ Claude (web and Desktop) requires an **https** connector URL. Two options:
42
+
43
+ **Tunnel** (no account, URL changes each run, briefly internet-reachable):
44
+
45
+ ```bash
46
+ npx cloudflared tunnel --url http://localhost:3001
47
+ ```
48
+
49
+ **Local TLS with [mkcert](https://github.com/FiloSottile/mkcert)** (nothing
50
+ leaves your machine; the mkcert CA lands in the Windows/macOS trust store,
51
+ which Claude Desktop honors):
52
+
53
+ ```powershell
54
+ mkcert -install
55
+ mkcert localhost
56
+ $env:TLS_CERT="localhost.pem"; $env:TLS_KEY="localhost-key.pem"; npx -y @lineadraw/mcp
57
+ ```
58
+
59
+ Settings → Connectors → Add custom connector → the https URL + `/mcp`
60
+ (e.g. `https://localhost:3001/mcp`). The MCP endpoint answers on `/` too.
61
+
62
+ All MCP sessions in one server process share the open documents, so a
63
+ reconnecting client keeps its work.
64
+
65
+ ## Tools
66
+
67
+ `linea_new_document` · `linea_open_document` · `linea_save_document` ·
68
+ `linea_add_objects` (model space or `layout`) · `linea_update_objects`
69
+ (per-id patches) · `linea_remove_objects` · `linea_transform`
70
+ (move/rotate/scale/mirror/copy/array; degrees) · `linea_create_layout` ·
71
+ `linea_summary` · `linea_get_document` · `linea_replace_document` (full-state
72
+ save used by the in-chat editor) · `linea_export` (svg/png/pdf/dxf) ·
73
+ **`linea_show_document`** — opens the in-chat editor.
74
+
75
+ Documents are plain `.linea` files (zod-validated JSON); units are
76
+ millimeters, Y-up, angles in radians. For scripted/batch editing without an
77
+ agent in the loop, the same engine is available as a Node SDK:
78
+ [`@lineadraw/sdk`](https://www.npmjs.com/package/@lineadraw/sdk).
79
+
80
+ ## The in-chat editor
81
+
82
+ The package bundles the real `@lineadraw/editor` (React + Tailwind v4 + Inter)
83
+ into ONE self-contained `editor.html` (~8 MB) — the sandboxed iframe's
84
+ CSP allows no external assets. `linea_show_document` renders it with the
85
+ document pushed as the tool result. Committed edits are debounced into
86
+ `linea_replace_document`, so the conversation's granular tools and the
87
+ interactive editor share one source of truth (the server registry). Foreign
88
+ changes (the agent's tool calls) are detected by revision polling and remount
89
+ the editor with the camera restored.
90
+
91
+ Sizing: the app reports a real content height (720px inline) through the
92
+ protocol's auto-resize and fills the frame under the host's `fullscreen`
93
+ display mode. Placement is the host's decision — the protocol offers
94
+ `inline | fullscreen | pip` only, so a persistent "panel right of the chat"
95
+ isn't requestable today.
96
+
97
+ In-chat caveat: disk-oriented menu items (Open/Save As) are limited by the
98
+ iframe sandbox — save through the conversation via `linea_save_document`.