@atlisp/mcp 1.0.1 → 1.0.2

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 (2) hide show
  1. package/package.json +9 -2
  2. package/src/index.js +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlisp/mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
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/atlisp-kernel",
35
+ "bugs": {
36
+ "url": "https://gitee.com/atlisp/atlisp-kernel/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
  });