@mlightcad/cad-mcp-server 1.7.8-preview.0 → 1.7.8-preview.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 +21 -21
- package/README.md +147 -147
- package/dist-runner/index.html +11 -11
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 mlightcad
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mlightcad
|
|
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,147 +1,147 @@
|
|
|
1
|
-
# @mlightcad/cad-mcp-server
|
|
2
|
-
|
|
3
|
-
stdio [Model Context Protocol](https://modelcontextprotocol.io) server that lets
|
|
4
|
-
third-party agents (Claude Code, Cursor, Codex, …) drive CAD drawings through
|
|
5
|
-
the same **script-first** API as the in-app CAD Agent.
|
|
6
|
-
|
|
7
|
-
## Why scripts, not hundreds of tools?
|
|
8
|
-
|
|
9
|
-
MCP is a great way to connect agents to CAD. It is a poor place to re-export
|
|
10
|
-
every drawing primitive as its own tool. A catalog of `draw_line`,
|
|
11
|
-
`draw_circle`, `set_entity_layer`, … never finishes, burns tokens on every
|
|
12
|
-
request, and still cannot cover one-off analysis (“find bolt-hole outliers by
|
|
13
|
-
layer and report them”).
|
|
14
|
-
|
|
15
|
-
This server follows the design in
|
|
16
|
-
[Building a CAD Agent: MCP, Tools, or Let AI Write Code?](https://dev.to/mlightcad/building-a-cad-agent-mcp-tools-or-let-ai-write-code-2nc4):
|
|
17
|
-
|
|
18
|
-
- **Tools** for clear lifecycle steps (open / blank drawing)
|
|
19
|
-
- **Scripts** for combining the CAD API into analysis, edits, and verification
|
|
20
|
-
|
|
21
|
-
The model writes a `cad.*` function body; the headless viewer runs it. Same
|
|
22
|
-
runtime as the in-app CAD Agent (`@mlightcad/cad-agent-core`), so external
|
|
23
|
-
agents (Claude Code, Cursor, Codex, …) get flexibility without a ballooning
|
|
24
|
-
tool list — and with lower token and round-trip cost for bulk work.
|
|
25
|
-
|
|
26
|
-
## Tools (intentionally small)
|
|
27
|
-
|
|
28
|
-
| Tool | Purpose |
|
|
29
|
-
| --- | --- |
|
|
30
|
-
| `open_drawing` | Open a local/remote DXF/DWG, or omit `path` for a blank ISO template |
|
|
31
|
-
| `execute_cad_script` | Run a `cad.*` JavaScript function body ([script API](https://mlightcad.github.io/cad-viewer/guide/script/overview.html)) |
|
|
32
|
-
|
|
33
|
-
There are **no** per-entity `draw_line` / `draw_circle` tools. All drawing,
|
|
34
|
-
queries, edits, and context live inside one script call.
|
|
35
|
-
|
|
36
|
-
## Works with cad-simple-viewer and cad-viewer
|
|
37
|
-
|
|
38
|
-
Both products share `AcApDocManager` from `@mlightcad/cad-simple-viewer`. This
|
|
39
|
-
server’s headless runner boots that kernel (not the Vue UI package). Scripts
|
|
40
|
-
you write for the Script panel or CAD Agent in either product are valid here,
|
|
41
|
-
and the reverse is true.
|
|
42
|
-
|
|
43
|
-
This package does **not** depend on `@mlightcad/cad-viewer`.
|
|
44
|
-
|
|
45
|
-
## Requirements
|
|
46
|
-
|
|
47
|
-
- Node.js ≥ 20
|
|
48
|
-
- Chromium for Playwright (`pnpm --filter @mlightcad/cad-mcp-server install-browser`)
|
|
49
|
-
|
|
50
|
-
## Install / run
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
pnpm --filter @mlightcad/cad-mcp-server build
|
|
54
|
-
pnpm --filter @mlightcad/cad-mcp-server install-browser
|
|
55
|
-
cad-mcp-server
|
|
56
|
-
# or: node packages/cad-mcp-server/dist/cli.js
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## MCP client config
|
|
60
|
-
|
|
61
|
-
### Cursor (`.cursor/mcp.json`)
|
|
62
|
-
|
|
63
|
-
Prefer `${workspaceFolder}` over a hardcoded absolute path or a bare
|
|
64
|
-
relative path (MCP cwd is not always the repo root):
|
|
65
|
-
|
|
66
|
-
```json
|
|
67
|
-
{
|
|
68
|
-
"mcpServers": {
|
|
69
|
-
"cad": {
|
|
70
|
-
"command": "node",
|
|
71
|
-
"args": [
|
|
72
|
-
"${workspaceFolder}/packages/cad-mcp-server/dist/cli.js"
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Claude Code / Claude Desktop
|
|
80
|
-
|
|
81
|
-
```json
|
|
82
|
-
{
|
|
83
|
-
"mcpServers": {
|
|
84
|
-
"cad": {
|
|
85
|
-
"command": "npx",
|
|
86
|
-
"args": ["-y", "@mlightcad/cad-mcp-server"]
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
(After the package is published; for local monorepo use the `node …/dist/cli.js` form.)
|
|
93
|
-
|
|
94
|
-
## Typical flow
|
|
95
|
-
|
|
96
|
-
1. `open_drawing` with `{ "path": "./plan.dxf", "mode": "write" }`
|
|
97
|
-
(local path or http(s) URL; omit `path` to start blank).
|
|
98
|
-
2. `execute_cad_script` with a function body:
|
|
99
|
-
|
|
100
|
-
```js
|
|
101
|
-
let id
|
|
102
|
-
cad.edit.transaction('circle', tx => {
|
|
103
|
-
id = tx.drawCircle({ center: { x: 0, y: 0 }, radius: 100 })
|
|
104
|
-
})
|
|
105
|
-
cad.view.zoomExtents()
|
|
106
|
-
return cad.measure.report([
|
|
107
|
-
cad.measure.check('r', 100, cad.measure.radius(id))
|
|
108
|
-
])
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
`cad.view.capturePreview` is enabled; screenshots are returned as MCP image
|
|
112
|
-
content.
|
|
113
|
-
|
|
114
|
-
## Architecture
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
MCP client --stdio--> cad-mcp-server (Node)
|
|
118
|
-
|
|
|
119
|
-
| Playwright (lazy)
|
|
120
|
-
v
|
|
121
|
-
headless Chromium
|
|
122
|
-
cad-simple-viewer + cad-agent-core
|
|
123
|
-
createCadToolCatalog / execute_cad_script
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
The browser session stays alive for the process lifetime so drawing state
|
|
127
|
-
persists across tool calls.
|
|
128
|
-
|
|
129
|
-
## Library API
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
import {
|
|
133
|
-
createCadMcpServer,
|
|
134
|
-
registerCadMcpTools,
|
|
135
|
-
CadMcpSession
|
|
136
|
-
} from '@mlightcad/cad-mcp-server'
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
`registerCadMcpTools` maps the same tool surface for a custom `McpServer`
|
|
140
|
-
(e.g. a future in-page WebMCP host that already has `AcApDocManager`).
|
|
141
|
-
|
|
142
|
-
## Related packages
|
|
143
|
-
|
|
144
|
-
- `@mlightcad/cad-agent-core` — script host and tool catalog
|
|
145
|
-
- `@mlightcad/cad-agent-plugin` — in-app chat agent
|
|
146
|
-
- `@mlightcad/cad-script-plugin` — manual script console
|
|
147
|
-
- `@mlightcad/cad-simple-viewer-cli` — AutoCAD `.scr` headless CLI (different script model)
|
|
1
|
+
# @mlightcad/cad-mcp-server
|
|
2
|
+
|
|
3
|
+
stdio [Model Context Protocol](https://modelcontextprotocol.io) server that lets
|
|
4
|
+
third-party agents (Claude Code, Cursor, Codex, …) drive CAD drawings through
|
|
5
|
+
the same **script-first** API as the in-app CAD Agent.
|
|
6
|
+
|
|
7
|
+
## Why scripts, not hundreds of tools?
|
|
8
|
+
|
|
9
|
+
MCP is a great way to connect agents to CAD. It is a poor place to re-export
|
|
10
|
+
every drawing primitive as its own tool. A catalog of `draw_line`,
|
|
11
|
+
`draw_circle`, `set_entity_layer`, … never finishes, burns tokens on every
|
|
12
|
+
request, and still cannot cover one-off analysis (“find bolt-hole outliers by
|
|
13
|
+
layer and report them”).
|
|
14
|
+
|
|
15
|
+
This server follows the design in
|
|
16
|
+
[Building a CAD Agent: MCP, Tools, or Let AI Write Code?](https://dev.to/mlightcad/building-a-cad-agent-mcp-tools-or-let-ai-write-code-2nc4):
|
|
17
|
+
|
|
18
|
+
- **Tools** for clear lifecycle steps (open / blank drawing)
|
|
19
|
+
- **Scripts** for combining the CAD API into analysis, edits, and verification
|
|
20
|
+
|
|
21
|
+
The model writes a `cad.*` function body; the headless viewer runs it. Same
|
|
22
|
+
runtime as the in-app CAD Agent (`@mlightcad/cad-agent-core`), so external
|
|
23
|
+
agents (Claude Code, Cursor, Codex, …) get flexibility without a ballooning
|
|
24
|
+
tool list — and with lower token and round-trip cost for bulk work.
|
|
25
|
+
|
|
26
|
+
## Tools (intentionally small)
|
|
27
|
+
|
|
28
|
+
| Tool | Purpose |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `open_drawing` | Open a local/remote DXF/DWG, or omit `path` for a blank ISO template |
|
|
31
|
+
| `execute_cad_script` | Run a `cad.*` JavaScript function body ([script API](https://mlightcad.github.io/cad-viewer/guide/script/overview.html)) |
|
|
32
|
+
|
|
33
|
+
There are **no** per-entity `draw_line` / `draw_circle` tools. All drawing,
|
|
34
|
+
queries, edits, and context live inside one script call.
|
|
35
|
+
|
|
36
|
+
## Works with cad-simple-viewer and cad-viewer
|
|
37
|
+
|
|
38
|
+
Both products share `AcApDocManager` from `@mlightcad/cad-simple-viewer`. This
|
|
39
|
+
server’s headless runner boots that kernel (not the Vue UI package). Scripts
|
|
40
|
+
you write for the Script panel or CAD Agent in either product are valid here,
|
|
41
|
+
and the reverse is true.
|
|
42
|
+
|
|
43
|
+
This package does **not** depend on `@mlightcad/cad-viewer`.
|
|
44
|
+
|
|
45
|
+
## Requirements
|
|
46
|
+
|
|
47
|
+
- Node.js ≥ 20
|
|
48
|
+
- Chromium for Playwright (`pnpm --filter @mlightcad/cad-mcp-server install-browser`)
|
|
49
|
+
|
|
50
|
+
## Install / run
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm --filter @mlightcad/cad-mcp-server build
|
|
54
|
+
pnpm --filter @mlightcad/cad-mcp-server install-browser
|
|
55
|
+
cad-mcp-server
|
|
56
|
+
# or: node packages/cad-mcp-server/dist/cli.js
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## MCP client config
|
|
60
|
+
|
|
61
|
+
### Cursor (`.cursor/mcp.json`)
|
|
62
|
+
|
|
63
|
+
Prefer `${workspaceFolder}` over a hardcoded absolute path or a bare
|
|
64
|
+
relative path (MCP cwd is not always the repo root):
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"mcpServers": {
|
|
69
|
+
"cad": {
|
|
70
|
+
"command": "node",
|
|
71
|
+
"args": [
|
|
72
|
+
"${workspaceFolder}/packages/cad-mcp-server/dist/cli.js"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Claude Code / Claude Desktop
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcpServers": {
|
|
84
|
+
"cad": {
|
|
85
|
+
"command": "npx",
|
|
86
|
+
"args": ["-y", "@mlightcad/cad-mcp-server"]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
(After the package is published; for local monorepo use the `node …/dist/cli.js` form.)
|
|
93
|
+
|
|
94
|
+
## Typical flow
|
|
95
|
+
|
|
96
|
+
1. `open_drawing` with `{ "path": "./plan.dxf", "mode": "write" }`
|
|
97
|
+
(local path or http(s) URL; omit `path` to start blank).
|
|
98
|
+
2. `execute_cad_script` with a function body:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
let id
|
|
102
|
+
cad.edit.transaction('circle', tx => {
|
|
103
|
+
id = tx.drawCircle({ center: { x: 0, y: 0 }, radius: 100 })
|
|
104
|
+
})
|
|
105
|
+
cad.view.zoomExtents()
|
|
106
|
+
return cad.measure.report([
|
|
107
|
+
cad.measure.check('r', 100, cad.measure.radius(id))
|
|
108
|
+
])
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`cad.view.capturePreview` is enabled; screenshots are returned as MCP image
|
|
112
|
+
content.
|
|
113
|
+
|
|
114
|
+
## Architecture
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
MCP client --stdio--> cad-mcp-server (Node)
|
|
118
|
+
|
|
|
119
|
+
| Playwright (lazy)
|
|
120
|
+
v
|
|
121
|
+
headless Chromium
|
|
122
|
+
cad-simple-viewer + cad-agent-core
|
|
123
|
+
createCadToolCatalog / execute_cad_script
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The browser session stays alive for the process lifetime so drawing state
|
|
127
|
+
persists across tool calls.
|
|
128
|
+
|
|
129
|
+
## Library API
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import {
|
|
133
|
+
createCadMcpServer,
|
|
134
|
+
registerCadMcpTools,
|
|
135
|
+
CadMcpSession
|
|
136
|
+
} from '@mlightcad/cad-mcp-server'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`registerCadMcpTools` maps the same tool surface for a custom `McpServer`
|
|
140
|
+
(e.g. a future in-page WebMCP host that already has `AcApDocManager`).
|
|
141
|
+
|
|
142
|
+
## Related packages
|
|
143
|
+
|
|
144
|
+
- `@mlightcad/cad-agent-core` — script host and tool catalog
|
|
145
|
+
- `@mlightcad/cad-agent-plugin` — in-app chat agent
|
|
146
|
+
- `@mlightcad/cad-script-plugin` — manual script console
|
|
147
|
+
- `@mlightcad/cad-simple-viewer-cli` — AutoCAD `.scr` headless CLI (different script model)
|
package/dist-runner/index.html
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<title>CAD MCP runner</title>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>CAD MCP runner</title>
|
|
6
6
|
<style>
|
|
7
7
|
html,
|
|
8
8
|
body {
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
width: 1280px;
|
|
17
17
|
height: 720px;
|
|
18
18
|
}
|
|
19
|
-
</style>
|
|
19
|
+
</style>
|
|
20
20
|
<script type="module" crossorigin src="./assets/index-2iXkmn03.js"></script>
|
|
21
|
-
</head>
|
|
22
|
-
<body>
|
|
23
|
-
<div id="cad-root"></div>
|
|
24
|
-
</body>
|
|
25
|
-
</html>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<div id="cad-root"></div>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mlightcad/cad-mcp-server",
|
|
3
|
-
"version": "1.7.8-preview.
|
|
3
|
+
"version": "1.7.8-preview.1",
|
|
4
4
|
"description": "stdio MCP server for CAD drawings: open_drawing + execute_cad_script (cad-agent-core)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@modelcontextprotocol/sdk": "^1.25.0",
|
|
48
48
|
"playwright": "^1.49.1",
|
|
49
49
|
"zod": "^3.24.0",
|
|
50
|
-
"@mlightcad/cad-
|
|
51
|
-
"@mlightcad/cad-
|
|
50
|
+
"@mlightcad/cad-agent-core": "1.7.8-preview.1",
|
|
51
|
+
"@mlightcad/cad-simple-viewer": "1.7.8-preview.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^20.14.9",
|