#!/usr/bin/env node
// This simulates how Claude runs the MCP server
import { spawn } from 'child_process';
console.log('π§ͺ Testing MCP server startup with API key...');
console.log('ββββββββββββββββββββββββββββββββββββββ\n');
// Simulate Claude's environment configuration
const env = {
...process.env,
OPENAI_API_KEY: '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'
};
const mcpServer = spawn('node', ['build/index.js'], {
env: env,
stdio: ['pipe', 'pipe', 'pipe']
});
let output = '';
let errorOutput = '';
mcpServer.stdout.on('data', (data) => {
output += data.toString();
});
mcpServer.stderr.on('data', (data) => {
errorOutput += data.toString();
console.log('MCP Server:', data.toString());
});
// Wait 3 seconds then send a test command
setTimeout(() => {
console.log('\nπ Sending test request to MCP server...\n');
const testRequest = {
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
params: {}
};
mcpServer.stdin.write(JSON.stringify(testRequest) + '\n');
// Give it time to respond then exit
setTimeout(() => {
console.log('\nβ
Test complete!');
if (errorOutput.includes('OPENAI_API_KEY loaded:')) {
console.log('β
API key is properly loaded in MCP server');
} else {
console.log('β API key might not be loading properly');
}
mcpServer.kill();
process.exit(0);
}, 2000);
}, 1000);