// Complete test of all logic tools across all systems
import { spawn } from 'child_process';
const tests = [
// SYLLOGISTIC LOGIC TESTS
{
name: "Syllogistic - Valid Barbara",
params: {
name: "logic-thinking",
arguments: {
system: "syllogistic",
operation: "validate",
input: "All men are mortal. Socrates is a man. Therefore, Socrates is mortal.",
format: "natural"
}
}
},
{
name: "Syllogistic - Invalid (Affirming Consequent)",
params: {
name: "logic-thinking",
arguments: {
system: "syllogistic",
operation: "validate",
input: "All dogs are mammals. All cats are mammals. Therefore, all dogs are cats.",
format: "natural"
}
}
},
{
name: "Syllogistic - Formalize",
params: {
name: "logic-thinking",
arguments: {
system: "syllogistic",
operation: "formalize",
input: "No birds are fish. All penguins are birds. Therefore, no penguins are fish.",
format: "natural"
}
}
},
{
name: "Syllogistic - Visualize",
params: {
name: "logic-thinking",
arguments: {
system: "syllogistic",
operation: "visualize",
input: "All birds have wings. All eagles are birds. Therefore, all eagles have wings.",
format: "natural"
}
}
},
{
name: "Syllogistic - Solve",
params: {
name: "logic-thinking",
arguments: {
system: "syllogistic",
operation: "solve",
input: "All humans are rational. All Greeks are human. Therefore, all Greeks are rational.",
format: "natural"
}
}
},
// PROPOSITIONAL LOGIC TESTS
{
name: "Propositional - Valid Modus Ponens",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "validate",
input: "P implies Q",
format: "natural"
}
}
},
{
name: "Propositional - Complex Formula",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "validate",
input: "(P and Q) or (not P and R)",
format: "natural"
}
}
},
{
name: "Propositional - Formalize",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "formalize",
input: "P and Q",
format: "natural"
}
}
},
{
name: "Propositional - Visualize Circuit",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "visualize",
input: "P and (Q or R)",
format: "natural"
}
}
},
{
name: "Propositional - Solve Transitive",
params: {
name: "logic-thinking",
arguments: {
system: "propositional",
operation: "solve",
input: "(P implies Q) and (Q implies R)",
format: "natural"
}
}
},
// PREDICATE LOGIC TESTS
{
name: "Predicate - Simple Universal",
params: {
name: "logic-thinking",
arguments: {
system: "predicate",
operation: "validate",
input: "All students pass. John is a student. Therefore, John passes.",
format: "natural"
}
}
},
{
name: "Predicate - Formalize",
params: {
name: "logic-thinking",
arguments: {
system: "predicate",
operation: "formalize",
input: "All students who study hard will pass the exam.",
format: "natural"
}
}
},
{
name: "Predicate - Visualize",
params: {
name: "logic-thinking",
arguments: {
system: "predicate",
operation: "visualize",
input: "Some cats are black. All black things are dark.",
format: "natural"
}
}
},
{
name: "Predicate - Solve",
params: {
name: "logic-thinking",
arguments: {
system: "predicate",
operation: "solve",
input: "All birds can fly. If something can fly, it has wings. Therefore, all birds have wings.",
format: "natural"
}
}
},
// COMMAND TESTS
{
name: "Command - List Fallacies",
params: {
name: "logic-thinking",
arguments: {
command: {
type: "listFallacies"
}
}
}
},
{
name: "Command - List Systems",
params: {
name: "logic-thinking",
arguments: {
command: {
type: "listSystems"
}
}
}
},
{
name: "Command - List Operations",
params: {
name: "logic-thinking",
arguments: {
command: {
type: "listOperations"
}
}
}
}
];
async function runAllTests() {
console.log(`
┌${'─'.repeat(60)}┐
│ LOGIC-THINKING MCP TOOLS COMPREHENSIVE TEST SUITE │
│ Testing all operations across all logical systems │
└${'─'.repeat(60)}┘
`);
let passed = 0;
let failed = 0;
for (let i = 0; i < tests.length; i++) {
const test = tests[i];
console.log(`\n${'='.repeat(70)}`);
console.log(`Test ${i + 1}/${tests.length}: ${test.name}`);
console.log(`${'='.repeat(70)}\n`);
const result = await runSingleTest(test);
if (result) passed++;
else failed++;
// Wait between tests
await new Promise(resolve => setTimeout(resolve, 1000));
}
console.log(`\n
┌${'─'.repeat(40)}┐
│ TEST SUMMARY │
│ Total: ${tests.length.toString().padEnd(33)}│
│ Passed: ${passed.toString().padEnd(32)}│
│ Failed: ${failed.toString().padEnd(32)}│
└${'─'.repeat(40)}┘
`);
}
function runSingleTest(test) {
return new Promise((resolve) => {
const mcpServer = spawn('node', ['--max-old-space-size=4096', './dist/index.js'], {
cwd: process.cwd(),
stdio: ['pipe', 'pipe', 'pipe']
});
const request = {
jsonrpc: "2.0",
method: "tools/call",
params: test.params,
id: 1
};
let responseReceived = false;
let testPassed = false;
mcpServer.stdout.on('data', (data) => {
const response = data.toString();
if (response.includes('"jsonrpc"')) {
try {
const parsed = JSON.parse(response);
console.log(`\n📥 Request:`);
console.log(JSON.stringify(request.params.arguments, null, 2));
console.log(`\n📤 Response:`);
console.log(JSON.stringify(parsed, null, 2));
responseReceived = true;
// Check if the test passed
if (parsed.result && !parsed.error) {
testPassed = true;
console.log('\n✅ TEST PASSED\n');
} else {
testPassed = false;
console.log('\n❌ TEST FAILED\n');
}
} catch (e) {
console.log('Raw response:', response);
testPassed = false;
}
}
});
mcpServer.stderr.on('data', (data) => {
const error = data.toString();
if (!error.includes('Logic Thinking MCP Server started') &&
!error.includes('Awaiting JSON-RPC 2.0 requests')) {
console.error('❗ Server Error:', error);
}
});
setTimeout(() => {
mcpServer.stdin.write(JSON.stringify(request) + '\n');
setTimeout(() => {
if (!responseReceived) {
console.log('⚠️ No response received!');
testPassed = false;
}
mcpServer.kill('SIGINT');
resolve(testPassed);
}, 2000);
}, 500);
});
}
runAllTests().catch(console.error);