import { spawn } from 'child_process'
// Test the enhanced MCP server with detailed output
const server = spawn('node', ['dist/index.js'], {
stdio: ['pipe', 'pipe', 'pipe']
})
let requestId = 1
function sendRequest(method, params = {}) {
const request = {
jsonrpc: '2.0',
id: requestId++,
method,
params
}
server.stdin.write(JSON.stringify(request) + '\n')
}
server.stdout.on('data', (data) => {
try {
const response = JSON.parse(data.toString().trim())
console.log('โ
Response:', JSON.stringify(response, null, 2))
} catch (e) {
console.log('๐ Raw output:', data.toString())
}
})
server.stderr.on('data', (data) => {
console.log('โ Error:', data.toString())
})
server.on('close', (code) => {
console.log('๐ Server closed with code:', code)
})
// Test sequence
setTimeout(() => {
console.log('๐ Testing enhanced MCP server...')
// 1. Initialize the server
sendRequest('initialize', {
protocolVersion: '2024-11-05',
capabilities: {
tools: {}
},
clientInfo: {
name: 'test-client',
version: '1.0.0'
}
})
}, 100)
setTimeout(() => {
// 2. Send initialized notification
sendRequest('notifications/initialized', {})
}, 200)
setTimeout(() => {
// 3. Test enhanced detailed diff with more complex example
sendRequest('tools/call', {
name: 'get_detailed_diff',
arguments: {
text1: `function hello() {
console.log("Hello World");
return true;
}`,
text2: `function hello() {
console.log("Hello World!");
return false;
}`,
includeFormattedOutput: true
}
})
}, 300)
setTimeout(() => {
// 4. Test with identical texts
sendRequest('tools/call', {
name: 'compare_texts',
arguments: {
text1: 'Hello World',
text2: 'Hello World'
}
})
}, 400)
setTimeout(() => {
server.kill()
console.log('๐งช Enhanced test completed')
}, 3000)