@atlisp/mcp 1.0.1 → 1.0.3
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/README.md +7 -13
- package/package.json +9 -2
- package/src/index.js +18 -1
package/README.md
CHANGED
|
@@ -2,37 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
MCP (Model Context Protocol) Server for @lisp on CAD - 为 CAD 环境提供 @lisp 包管理服务的 MCP 服务器。
|
|
4
4
|
|
|
5
|
+
同时为 AI AGENT 操控 cad 提供调用工具和通道。
|
|
6
|
+
|
|
5
7
|
## 功能特性
|
|
6
8
|
|
|
7
9
|
- 连接 AutoCAD/ZWCAD/GStarCAD/BricsCAD
|
|
8
10
|
- 执行 AutoLISP 代码
|
|
9
|
-
- 管理 @lisp 包(列出、搜索、安装)
|
|
10
11
|
- 获取 CAD 平台信息
|
|
11
12
|
- 通过 MCP 协议提供标准化接口
|
|
13
|
+
- 管理 @lisp 包(列出、搜索、安装)
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
## 安装
|
|
14
17
|
|
|
15
18
|
```bash
|
|
16
|
-
|
|
17
|
-
npm install
|
|
19
|
+
npm i -g @atlisp/mcp
|
|
18
20
|
```
|
|
19
21
|
|
|
20
22
|
## 使用方法
|
|
21
23
|
|
|
22
24
|
### 启动服务器
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
**同时支持HTTP 和studio模式**:
|
|
25
27
|
```bash
|
|
26
|
-
|
|
27
|
-
# 或
|
|
28
|
-
TRANSPORT=http node src/index.js
|
|
28
|
+
atlisp-mcp
|
|
29
29
|
```
|
|
30
|
-
|
|
31
|
-
**Stdio 模式**(用于 MCP 客户端):
|
|
32
|
-
```bash
|
|
33
|
-
TRANSPORT=stdio node src/index.js
|
|
34
|
-
```
|
|
35
|
-
|
|
36
30
|
### 环境变量
|
|
37
31
|
|
|
38
32
|
| 变量 | 默认值 | 说明 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlisp/mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "MCP Server for @lisp on CAD",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"start": "node src/index.js",
|
|
19
|
-
"build": "webpack",
|
|
20
19
|
"test": "echo \"No tests yet\" && exit 0"
|
|
21
20
|
},
|
|
22
21
|
"keywords": [
|
|
@@ -28,6 +27,14 @@
|
|
|
28
27
|
],
|
|
29
28
|
"author": "vitalgg",
|
|
30
29
|
"license": "ISC",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://gitee.com/atlisp/atlisp-kernel.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://gitee.com/atlisp",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://gitee.com/organizations/atlisp/issues"
|
|
37
|
+
},
|
|
31
38
|
"dependencies": {
|
|
32
39
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
33
40
|
"edge-js": "^25.0.1"
|
package/src/index.js
CHANGED
|
@@ -205,7 +205,23 @@ mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
205
205
|
return await handleToolCall(name, args || {});
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
+
async function initCadConnection() {
|
|
209
|
+
log('Attempting to connect to CAD on startup...');
|
|
210
|
+
try {
|
|
211
|
+
const connected = await cad.connect();
|
|
212
|
+
if (connected) {
|
|
213
|
+
log('Auto-connected to CAD: ' + cad.getPlatform() + ' ' + cad.getVersion());
|
|
214
|
+
console.error('已自动连接到 CAD: ' + cad.getPlatform() + ' ' + cad.getVersion());
|
|
215
|
+
} else {
|
|
216
|
+
log('No CAD found on startup');
|
|
217
|
+
}
|
|
218
|
+
} catch (e) {
|
|
219
|
+
log('Auto-connect failed: ' + e.message);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
208
223
|
if (TRANSPORT === 'stdio') {
|
|
224
|
+
await initCadConnection();
|
|
209
225
|
const transport = new StdioServerTransport();
|
|
210
226
|
await mcpServer.connect(transport);
|
|
211
227
|
console.error('@lisp MCP Server 运行在 stdio 模式');
|
|
@@ -272,7 +288,8 @@ if (TRANSPORT === 'stdio') {
|
|
|
272
288
|
}
|
|
273
289
|
});
|
|
274
290
|
|
|
275
|
-
app.listen(PORT, HOST, () => {
|
|
291
|
+
app.listen(PORT, HOST, async () => {
|
|
292
|
+
await initCadConnection();
|
|
276
293
|
const status = cad.connected ? '已连接 CAD' : '未连接 CAD';
|
|
277
294
|
console.error(`@lisp MCP Server 启动 - http://${HOST}:${PORT} - ${status}`);
|
|
278
295
|
});
|