/**
* MCP Connection Test
* Verify the MCP server can be connected to and used
*/
import { spawn } from 'child_process';
import { setTimeout } from 'timers/promises';
async function testMcpConnection() {
console.log('๐งช Testing MCP Server Connection...\n');
const server = spawn('npm', ['run', 'mcp'], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: process.cwd()
});
let serverReady = false;
let output = '';
server.stdout.on('data', (data) => {
const message = data.toString();
output += message;
if (message.includes('MCP Server started and ready for connections')) {
serverReady = true;
}
});
server.stderr.on('data', (data) => {
output += data.toString();
});
// Wait for server to start
let attempts = 0;
while (!serverReady && attempts < 20) {
await setTimeout(500);
attempts++;
}
if (serverReady) {
console.log('โ
MCP Server started successfully!');
console.log('๐ Server initialization output:');
console.log(output);
console.log('\n๐ MCP Server Features Available:');
console.log(' โ
save_context - Save contexts with validation');
console.log(' โ
search_contexts - Advanced context search');
console.log(' โ
get_context - Retrieve specific contexts');
console.log(' โ
generate_template - Create reusable templates');
console.log(' โ
apply_template - Use templates for contexts');
console.log(' โ
get_recent_sessions - Session management');
console.log(' โ
resume_session - Quick session resume');
console.log(' โ
get_system_status - Health and statistics');
console.log('\n๐ Ready for Claude Code Integration!');
console.log('Add this to your .claude_code/claude_code.config.json:');
console.log(JSON.stringify({
mcpServers: {
"persistent-context-store": {
command: "npm",
args: ["run", "mcp"],
cwd: process.cwd()
}
}
}, null, 2));
console.log('\n๐ MCP Server connection test completed successfully!');
} else {
console.log('โ MCP Server failed to start within timeout');
console.log('Output:', output);
}
// Clean shutdown
server.kill('SIGTERM');
await setTimeout(1000);
}
testMcpConnection().catch(console.error);