import { spawn } from 'child_process';
const payload = {
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'file_reader',
arguments: {
path: 'C:\\MCP server\\README.md'
}
}
};
const child = spawn('node', ['dist/mcp/server.js'], { stdio: ['pipe', 'pipe', 'inherit'] });
child.stdout.on('data', (data) => {
const lines = data.toString().split(/\r?\n/).filter(Boolean);
for (const line of lines) {
try {
const parsed = JSON.parse(line);
console.log('Server response:', JSON.stringify(parsed, null, 2));
} catch (e) {
console.log('Non-JSON output:', line);
}
}
});
child.on('close', (code) => {
// child exited
});
child.stdin.write(JSON.stringify(payload) + '\n');
setTimeout(() => child.stdin.end(), 200);
setTimeout(() => child.kill(), 2000);