// Test with correct syntax that the parser understands
import { spawn } from 'child_process';
const testCases = [
// Test simple propositional logic
{
name: "Validate - Simple proposition",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "validate",
input: "P and Q",
format: "natural"
}
}
},
// Test formalize with proper syntax
{
name: "Formalize - Propositional",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "formalize",
input: "P implies Q",
format: "natural"
}
}
},
// Test visualize with simple formula
{
name: "Visualize - Logic Circuit",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "visualize",
input: "P and Q",
format: "natural"
}
}
},
// Test solve with simple proof
{
name: "Solve - Simple transitive",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "solve",
input: "(P implies Q) and (Q implies R) and (P implies R)",
format: "natural"
}
}
}
];
async function runTests() {
for (let i = 0; i < testCases.length; i++) {
const testCase = testCases[i];
console.log(`\n${'='.repeat(50)}`);
console.log(`Test ${i + 1}: ${testCase.name}`);
console.log(`${'='.repeat(50)}\n`);
await runSingleTest(testCase);
// Wait between tests
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
function runSingleTest(testCase) {
return new Promise((resolve) => {
const mcpServer = spawn('node', ['--max-old-space-size=4096', '--expose-gc', '--max-semi-space-size=64', './dist/index.js'], {
cwd: process.cwd(),
stdio: ['pipe', 'pipe', 'pipe']
});
const request = {
jsonrpc: "2.0",
method: "tools/call",
params: testCase.params,
id: 1
};
mcpServer.stdout.on('data', (data) => {
const response = data.toString();
if (response.includes('"jsonrpc"')) {
try {
const parsed = JSON.parse(response);
console.log('Response:', JSON.stringify(parsed, null, 2));
} catch (e) {
console.log('Raw response:', response);
}
}
});
setTimeout(() => {
console.log('Sending request:', JSON.stringify(request, null, 2));
mcpServer.stdin.write(JSON.stringify(request) + '\n');
setTimeout(() => {
mcpServer.kill('SIGINT');
resolve();
}, 2000);
}, 500);
});
}
runTests().catch(console.error);