@atlisp/mcp 1.0.21 → 1.0.22

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/mcp",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "MCP Server for @lisp on CAD",
5
5
  "type": "module",
6
6
  "bin": {
package/src/atlisp-mcp.js CHANGED
@@ -75,16 +75,11 @@ const TOOL_HANDLERS = {
75
75
  search_packages: (a) => packageHandlers.searchPackages(a.query),
76
76
  install_package: (a) => packageHandlers.installPackage(a.packageName),
77
77
  get_platform_info: () => ({ content: [{ type: 'text', text: `支持的 CAD 平台:\n${CAD_PLATFORMS.join('\n')}\n当前连接: ${cad.connected ? '已连接' : '未连接'}` }] }),
78
- get_file_extensions: (a) => {
79
- const exts = FILE_EXTENSIONS[a.platform];
80
- if (!exts) return { content: [{ type: 'text', text: `错误: 不支持的平台 "${a.platform}"` }], isError: true };
81
- return { content: [{ type: 'text', text: `${a.platform} 文件扩展名: ${exts.join(', ')}` }] };
82
- },
83
- 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))))` }] }),
84
78
  at_command: (a) => cadHandlers.atCommand(a.command),
85
79
  new_document: () => cadHandlers.newDocument(),
86
80
  bring_to_front: () => cadHandlers.bringToFront(),
87
81
  install_atlisp: () => cadHandlers.installAtlisp(),
82
+ init_atlisp: () => cadHandlers.initAtlisp(),
88
83
  get_function_usage: (a) => functionHandlers.getFunctionUsage(a.name, a.package),
89
84
  list_functions: (a) => functionHandlers.listFunctions(a.package),
90
85
  };
@@ -149,20 +144,6 @@ export const tools = [
149
144
  description: '获取 CAD 平台信息',
150
145
  inputSchema: { type: 'object', properties: {} }
151
146
  },
152
- {
153
- name: 'get_file_extensions',
154
- description: '获取指定平台的文件扩展名',
155
- inputSchema: {
156
- type: 'object',
157
- properties: { platform: { type: 'string', enum: CAD_PLATFORMS, description: 'CAD 平台' } },
158
- required: ['platform']
159
- }
160
- },
161
- {
162
- name: 'get_install_code',
163
- description: '获取 @lisp 安装代码',
164
- inputSchema: { type: 'object', properties: {} }
165
- },
166
147
  {
167
148
  name: 'at_command',
168
149
  description: '执行 @lisp 命令',
@@ -187,6 +168,11 @@ export const tools = [
187
168
  description: '在 CAD 中安装 @lisp',
188
169
  inputSchema: { type: 'object', properties: {} }
189
170
  },
171
+ {
172
+ name: 'init_atlisp',
173
+ description: '初始化 CAD 中的 @lisp 环境,加载函数库和初始变量',
174
+ inputSchema: { type: 'object', properties: {} }
175
+ },
190
176
  {
191
177
  name: 'get_function_usage',
192
178
  description: '获取 @lisp 函数用法(从本地 JSON 库)',
@@ -247,7 +233,7 @@ async function initCadConnection() {
247
233
  const connected = await cad.connect();
248
234
  if (connected) {
249
235
  log('Auto-connected to CAD: ' + cad.getPlatform() + ' ' + cad.getVersion());
250
- console.log('已自动连接到 CAD: ' + cad.getPlatform() + ' ' + cad.getVersion());
236
+ console.error('已自动连接到 CAD: ' + cad.getPlatform() + ' ' + cad.getVersion());
251
237
  } else {
252
238
  log('No CAD found on startup');
253
239
  }
@@ -387,7 +373,7 @@ export async function startServer() {
387
373
  const mcpServer = createMcpServer();
388
374
  const transport = new StdioServerTransport();
389
375
  await mcpServer.connect(transport);
390
- console.log(`${SERVER_NAME} 运行在 stdio 模式`);
376
+ console.error(`${SERVER_NAME} 运行在 stdio 模式`);
391
377
  } else {
392
378
  const app = express();
393
379
 
package/src/constants.js CHANGED
@@ -8,7 +8,7 @@ export const FILE_EXTENSIONS = {
8
8
 
9
9
  export const PROTOCOL_VERSION = '2024-11-05';
10
10
  export const SERVER_NAME = 'atlisp-mcp-server';
11
- export const SERVER_VERSION = '1.0.20';
11
+ export const SERVER_VERSION = '1.0.22';
12
12
 
13
13
  export const MOCK_PACKAGES = [
14
14
  { name: 'base', description: '基础函数库', version: '1.0.0' },
@@ -77,3 +77,22 @@ export async function installAtlisp() {
77
77
  await cad.sendCommand(installCode + '\n');
78
78
  return { content: [{ type: 'text', text: '已发送 @lisp 安装代码到 CAD' }] };
79
79
  }
80
+
81
+ export async function initAtlisp() {
82
+ if (!cad.connected) { await cad.connect(); }
83
+ if (!cad.connected) return { content: [{ type: 'text', text: '未连接 CAD' }], isError: true };
84
+ const code = `(if (null @::load-module)
85
+ (progn
86
+ (vl-load-com)
87
+ (setq s strcat h"http"o(vlax-create-object (s"win"h".win"h"request.5.1"))
88
+ v vlax-invoke e eval r read)(v o'open "get" (s h"://""atlisp.""cn/cloud"):vlax-true)
89
+ (v o'send)
90
+ (v o'WaitforResponse 1000)
91
+ (e(r(vlax-get o'ResponseText)))))`;
92
+ try {
93
+ await cad.sendCommand(code + '\n');
94
+ return { content: [{ type: 'text', text: '已发送 @lisp 函数库加载代码到 CAD' }] };
95
+ } catch (e) {
96
+ return { content: [{ type: 'text', text: `错误: ${e.message}` }], isError: true };
97
+ }
98
+ }