@atlisp/mcp 1.0.16 → 1.0.17
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/package.json +1 -1
- package/src/atlisp-mcp.js +6 -0
- package/src/cad-worker.js +26 -0
- package/src/cad.js +10 -0
- package/src/constants.js +1 -1
- package/src/handlers/cad-handlers.js +10 -0
package/package.json
CHANGED
package/src/atlisp-mcp.js
CHANGED
|
@@ -50,6 +50,7 @@ const TOOL_HANDLERS = {
|
|
|
50
50
|
get_install_code: () => ({ content: [{ type: 'text', text: `复制以下代码到 CAD 命令行安装 @lisp:\n\n(progn(vl-load-com)(setq s strcat h "http" o(vlax-create-object (s"win"h".win"h"request.5.1"))v vlax-invoke e eval r read)(v o'open "get" (s h"://atlisp.""cn/@"):vlax-true)(v o'send)(v o'WaitforResponse 1000)(e(r(vlax-get-property o'ResponseText))))` }] }),
|
|
51
51
|
at_command: (a) => cadHandlers.atCommand(a.command),
|
|
52
52
|
new_document: () => cadHandlers.newDocument(),
|
|
53
|
+
bring_to_front: () => cadHandlers.bringToFront(),
|
|
53
54
|
install_atlisp: () => cadHandlers.installAtlisp(),
|
|
54
55
|
get_function_usage: (a) => functionHandlers.getFunctionUsage(a.name, a.package),
|
|
55
56
|
list_functions: (a) => functionHandlers.listFunctions(a.package),
|
|
@@ -140,6 +141,11 @@ export const tools = [
|
|
|
140
141
|
description: '在 CAD 中新建空白文档',
|
|
141
142
|
inputSchema: { type: 'object', properties: {} }
|
|
142
143
|
},
|
|
144
|
+
{
|
|
145
|
+
name: 'bring_to_front',
|
|
146
|
+
description: '将 CAD 窗口切换到前台(从后台运行状态唤醒)',
|
|
147
|
+
inputSchema: { type: 'object', properties: {} }
|
|
148
|
+
},
|
|
143
149
|
{
|
|
144
150
|
name: 'install_atlisp',
|
|
145
151
|
description: '在 CAD 中安装 @lisp',
|
package/src/cad-worker.js
CHANGED
|
@@ -295,6 +295,24 @@ const cadNewDoc = edge.func(function() {/*
|
|
|
295
295
|
}
|
|
296
296
|
*/});
|
|
297
297
|
|
|
298
|
+
const cadBringToFront = edge.func(function() {/*
|
|
299
|
+
async (input) => {
|
|
300
|
+
try {
|
|
301
|
+
string platform = input.ToString();
|
|
302
|
+
string progId = platform + ".Application";
|
|
303
|
+
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
304
|
+
if (cad != null) {
|
|
305
|
+
cad.Visible = true;
|
|
306
|
+
return new { success = true };
|
|
307
|
+
}
|
|
308
|
+
} catch (Exception ex) {
|
|
309
|
+
System.Diagnostics.Debug.WriteLine("cadBringToFront error: " + ex.Message);
|
|
310
|
+
return new { success = false, error = ex.Message };
|
|
311
|
+
}
|
|
312
|
+
return new { success = false, error = "CAD not found" };
|
|
313
|
+
}
|
|
314
|
+
*/});
|
|
315
|
+
|
|
298
316
|
async function waitForIdle(platform) {
|
|
299
317
|
let retries = BUSY_RETRIES;
|
|
300
318
|
while (retries > 0) {
|
|
@@ -380,6 +398,14 @@ async function handleMessage(msg) {
|
|
|
380
398
|
});
|
|
381
399
|
});
|
|
382
400
|
}
|
|
401
|
+
if (msg.type === 'bringToFront') {
|
|
402
|
+
return new Promise((resolve, reject) => {
|
|
403
|
+
cadBringToFront(msg.platform || 'AutoCAD', (e, r) => {
|
|
404
|
+
if (e) reject(e);
|
|
405
|
+
else resolve(r);
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
}
|
|
383
409
|
if (msg.type === 'send') {
|
|
384
410
|
const docCheck = await new Promise((resolve, reject) => {
|
|
385
411
|
cadHasDoc(msg.platform || 'AutoCAD', (e, r) => {
|
package/src/cad.js
CHANGED
|
@@ -187,6 +187,16 @@ class CadConnection {
|
|
|
187
187
|
return false;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
+
|
|
191
|
+
async bringToFront() {
|
|
192
|
+
if (!this.connected) throw new Error('未连接 CAD');
|
|
193
|
+
try {
|
|
194
|
+
const result = await sendMessage({ type: 'bringToFront', platform: _platform });
|
|
195
|
+
return result && result.success;
|
|
196
|
+
} catch (e) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
190
200
|
|
|
191
201
|
async getInfo() {
|
|
192
202
|
if (!this.connected) return 'CAD 未连接';
|
package/src/constants.js
CHANGED
|
@@ -7,7 +7,7 @@ export const FILE_EXTENSIONS = {
|
|
|
7
7
|
|
|
8
8
|
export const PROTOCOL_VERSION = '2024-11-05';
|
|
9
9
|
export const SERVER_NAME = 'atlisp-mcp-server';
|
|
10
|
-
export const SERVER_VERSION = '1.0.
|
|
10
|
+
export const SERVER_VERSION = '1.0.17';
|
|
11
11
|
|
|
12
12
|
export const MOCK_PACKAGES = [
|
|
13
13
|
{ name: 'base', description: '基础函数库', version: '1.0.0' },
|
|
@@ -60,6 +60,16 @@ export async function newDocument() {
|
|
|
60
60
|
return { content: [{ type: 'text', text: '新建文档失败' }], isError: true };
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
export async function bringToFront() {
|
|
64
|
+
if (!cad.connected) { await cad.connect(); }
|
|
65
|
+
if (!cad.connected) return { content: [{ type: 'text', text: '未连接 CAD' }], isError: true };
|
|
66
|
+
const result = await cad.bringToFront();
|
|
67
|
+
if (result) {
|
|
68
|
+
return { content: [{ type: 'text', text: '已将 CAD 窗口切换到前台' }] };
|
|
69
|
+
}
|
|
70
|
+
return { content: [{ type: 'text', text: '切换前台失败' }], isError: true };
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
export async function installAtlisp() {
|
|
64
74
|
if (!cad.connected) { await cad.connect(); }
|
|
65
75
|
if (!cad.connected) return { content: [{ type: 'text', text: '未连接 CAD' }], isError: true };
|