@atlisp/mcp 1.1.1 → 1.1.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/package.json +1 -1
- package/src/atlisp-mcp.js +41 -1
- package/src/config.js +25 -3
- package/src/constants.js +1 -1
package/package.json
CHANGED
package/src/atlisp-mcp.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import path from 'path';
|
|
2
3
|
import { fileURLToPath } from 'url';
|
|
3
4
|
import { createRequire } from 'module';
|
|
@@ -6,7 +7,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
6
7
|
const require = createRequire(import.meta.url);
|
|
7
8
|
const { version } = require(path.join(__dirname, '..', 'package.json'));
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const isMcpScript = process.argv[1]?.includes('atlisp-mcp');
|
|
11
|
+
if (isMcpScript) {
|
|
10
12
|
const args = process.argv.slice(2);
|
|
11
13
|
for (let i = 0; i < args.length; i++) {
|
|
12
14
|
if (args[i] === '--version' || args[i] === '-v') {
|
|
@@ -33,6 +35,17 @@ Examples:
|
|
|
33
35
|
atlisp-mcp --transport stdio # Same as --stdio
|
|
34
36
|
`);
|
|
35
37
|
process.exit(0);
|
|
38
|
+
} else if (args[i] === '--transport' && args[i + 1]) {
|
|
39
|
+
process.env.TRANSPORT = args[i + 1];
|
|
40
|
+
i++;
|
|
41
|
+
} else if (args[i] === '--stdio') {
|
|
42
|
+
process.env.TRANSPORT = 'stdio';
|
|
43
|
+
} else if (args[i] === '--port' && args[i + 1]) {
|
|
44
|
+
process.env.PORT = args[i + 1];
|
|
45
|
+
i++;
|
|
46
|
+
} else if (args[i] === '--host' && args[i + 1]) {
|
|
47
|
+
process.env.HOST = args[i + 1];
|
|
48
|
+
i++;
|
|
36
49
|
}
|
|
37
50
|
}
|
|
38
51
|
}
|
|
@@ -111,6 +124,17 @@ const TOOL_HANDLERS = {
|
|
|
111
124
|
init_atlisp: () => cadHandlers.initAtlisp(),
|
|
112
125
|
get_function_usage: (a) => functionHandlers.getFunctionUsage(a.name, a.package),
|
|
113
126
|
list_functions: (a) => functionHandlers.listFunctions(a.package),
|
|
127
|
+
get_file_extensions: (a) => {
|
|
128
|
+
const exts = FILE_EXTENSIONS[a.platform];
|
|
129
|
+
if (!exts) return { content: [{ type: 'text', text: `平台 ${a.platform} 不支持` }], isError: true };
|
|
130
|
+
return { content: [{ type: 'text', text: `${a.platform} 文件扩展名: ${exts.join(', ')}` }] };
|
|
131
|
+
},
|
|
132
|
+
get_install_code: () => ({
|
|
133
|
+
content: [{
|
|
134
|
+
type: 'text',
|
|
135
|
+
text: `复制以下代码到 CAD 命令行加载:\n(load "atlisp" "atlisp")\n(vlax-create-object "atlisp.atlisp.1")`
|
|
136
|
+
}]
|
|
137
|
+
}),
|
|
114
138
|
};
|
|
115
139
|
|
|
116
140
|
export const tools = [
|
|
@@ -223,6 +247,22 @@ export const tools = [
|
|
|
223
247
|
package: { type: 'string', description: '包名,如 string(可选)' }
|
|
224
248
|
}
|
|
225
249
|
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'get_file_extensions',
|
|
253
|
+
description: '获取 CAD 平台对应的文件扩展名',
|
|
254
|
+
inputSchema: {
|
|
255
|
+
type: 'object',
|
|
256
|
+
properties: {
|
|
257
|
+
platform: { type: 'string', description: 'CAD 平台,如 AutoCAD, ZWCAD, GStarCAD, BricsCAD' }
|
|
258
|
+
},
|
|
259
|
+
required: ['platform']
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: 'get_install_code',
|
|
264
|
+
description: '获取 @lisp 安装代码',
|
|
265
|
+
inputSchema: { type: 'object', properties: {} }
|
|
226
266
|
}
|
|
227
267
|
];
|
|
228
268
|
|
package/src/config.js
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
|
+
function parseArgs() {
|
|
2
|
+
const args = process.argv.slice(2);
|
|
3
|
+
const result = { transport: 'http', port: '8110', host: '0.0.0.0' };
|
|
4
|
+
for (let i = 0; i < args.length; i++) {
|
|
5
|
+
if (args[i] === '--transport' && args[i + 1]) {
|
|
6
|
+
result.transport = args[i + 1];
|
|
7
|
+
i++;
|
|
8
|
+
} else if (args[i] === '--stdio') {
|
|
9
|
+
result.transport = 'stdio';
|
|
10
|
+
} else if (args[i] === '--port' && args[i + 1]) {
|
|
11
|
+
result.port = args[i + 1];
|
|
12
|
+
i++;
|
|
13
|
+
} else if (args[i] === '--host' && args[i + 1]) {
|
|
14
|
+
result.host = args[i + 1];
|
|
15
|
+
i++;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const cliArgs = parseArgs();
|
|
22
|
+
|
|
1
23
|
const config = {
|
|
2
|
-
port: parseInt(process.env.PORT ||
|
|
3
|
-
host: process.env.HOST ||
|
|
4
|
-
transport: process.env.TRANSPORT ||
|
|
24
|
+
port: parseInt(process.env.PORT || cliArgs.port, 10),
|
|
25
|
+
host: process.env.HOST || cliArgs.host,
|
|
26
|
+
transport: process.env.TRANSPORT || cliArgs.transport,
|
|
5
27
|
apiKey: process.env.MCP_API_KEY || '',
|
|
6
28
|
enableSse: process.env.ENABLE_SSE !== 'false',
|
|
7
29
|
messageTimeout: parseInt(process.env.MESSAGE_TIMEOUT || '60000', 10),
|
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.
|
|
11
|
+
export const SERVER_VERSION = '1.1.2';
|
|
12
12
|
|
|
13
13
|
export const MOCK_PACKAGES = [
|
|
14
14
|
{ name: 'base', description: '基础函数库', version: '1.0.0' },
|