test-minimal.mjsโข3.68 kB
// Test the minimal MCP server
import { spawn } from 'child_process';
console.log('๐งช Testing Minimal MCP Server');
console.log('=' .repeat(40));
async function testMinimalServer() {
return new Promise((resolve) => {
console.log('๐ก Starting minimal test server...');
const server = spawn('node', ['test-server.mjs'], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: process.cwd()
});
let serverReady = false;
server.stdout.on('data', (data) => {
const text = data.toString();
if (text.includes('running on stdio') && !serverReady) {
serverReady = true;
console.log('โ
Test server started');
// Test tools/list first
const listRequest = {
jsonrpc: "2.0",
id: 1,
method: "tools/list",
params: {}
};
console.log('๐ค Requesting tools list...');
server.stdin.write(JSON.stringify(listRequest) + '\n');
// Wait a bit then test the Visum tool
setTimeout(() => {
const visumRequest = {
jsonrpc: "2.0",
id: 2,
method: "tools/call",
params: {
name: "check_visum",
arguments: {}
}
};
console.log('๐ค Testing check_visum tool...');
server.stdin.write(JSON.stringify(visumRequest) + '\n');
}, 2000);
}
// Parse responses
const lines = text.split('\n');
for (const line of lines) {
if (line.trim().startsWith('{') && line.includes('"jsonrpc"')) {
try {
const response = JSON.parse(line.trim());
if (response.id === 1 && response.result?.tools) {
console.log(`โ
Tools list received: ${response.result.tools.length} tools`);
response.result.tools.forEach(tool => {
console.log(` โข ${tool.name}`);
});
} else if (response.id === 2) {
console.log('โ
Visum tool response received!');
if (response.result?.content?.[0]?.text) {
const text = response.result.content[0].text;
console.log('๐ Response:', text.split('\n')[0]);
if (text.includes('โ
**Visum Available**')) {
console.log('๐ SUCCESS: Visum is working through minimal MCP!');
} else {
console.log('โ ๏ธ Visum not available, but MCP communication works');
}
}
setTimeout(() => {
server.kill();
resolve(true);
}, 1000);
}
} catch (e) {
// Not JSON
}
}
}
});
server.stderr.on('data', (data) => {
console.log('๐ Server:', data.toString().trim());
});
server.on('close', (code) => {
if (!serverReady) {
console.log('โ Server failed to start');
resolve(false);
}
});
setTimeout(() => {
console.log('โฑ๏ธ Test timeout');
server.kill();
resolve(false);
}, 10000);
});
}
testMinimalServer().then(success => {
console.log('\n' + '=' .repeat(40));
if (success) {
console.log('๐ Minimal MCP server works!');
console.log('๐ก The issue is likely in the main server code');
console.log('๐ก Claude should be able to use this minimal version');
} else {
console.log('โ Even minimal MCP server fails');
console.log('๐ก This suggests an SDK or environment issue');
}
}).catch(console.error);