-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-server.mjs
More file actions
88 lines (75 loc) · 2.63 KB
/
Copy pathdebug-server.mjs
File metadata and controls
88 lines (75 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env node
// Test script to debug SolidWorks MCP Server initialization
console.error('[DEBUG] Starting SolidWorks MCP Server debug test...');
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
console.error('[DEBUG] MCP SDK imported successfully');
try {
// Test winax import
console.error('[DEBUG] Attempting to import winax...');
const winax = await import('winax');
console.error('[DEBUG] Winax imported successfully');
// Try to create ActiveX object
console.error('[DEBUG] Testing ActiveX connection...');
try {
const { createActiveXObject } = winax.default || winax;
console.error('[DEBUG] CreateActiveXObject function found');
// Test actual SolidWorks connection
console.error('[DEBUG] Attempting to connect to SolidWorks...');
try {
const swApp = createActiveXObject('SldWorks.Application');
console.error('[DEBUG] SUCCESS: Connected to SolidWorks!');
console.error('[DEBUG] SolidWorks is available');
} catch (swError) {
console.error('[DEBUG] WARNING: Could not connect to SolidWorks:', swError.message);
console.error('[DEBUG] This might be because SolidWorks is not running or not installed');
}
} catch (axError) {
console.error('[DEBUG] ActiveX error:', axError.message);
}
} catch (winaxError) {
console.error('[DEBUG] Winax import error:', winaxError.message);
console.error('[DEBUG] This is likely the issue - winax module not properly built');
}
// Create a minimal MCP server
console.error('[DEBUG] Creating minimal MCP server...');
const server = new Server(
{
name: 'solidworks-debug',
version: '1.0.0'
},
{
capabilities: {
tools: {}
}
}
);
// Add a simple test tool using the correct schema
server.setRequestHandler(ListToolsRequestSchema, () => {
console.error('[DEBUG] tools/list called');
return {
tools: [{
name: 'test',
description: 'Test tool - server is working',
inputSchema: {
type: 'object',
properties: {}
}
}]
};
});
console.error('[DEBUG] Starting server with stdio transport...');
try {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error('[DEBUG] Server started successfully, waiting for messages...');
} catch (serverError) {
console.error('[DEBUG] Server startup error:', serverError.message);
process.exit(1);
}
// Handle shutdown
process.on('SIGINT', () => {
console.error('[DEBUG] Shutting down...');
process.exit(0);
});