#!/usr/bin/env node
// Check what API key RC5 uses
const { spawn } = require('child_process');
const path = require('path');
class RC5ApiKeyChecker {
constructor() {
this.serverProcess = null;
this.messageId = 1;
this.pendingRequests = new Map();
}
async startRC5() {
console.log('๐ Starting RC5...');
this.serverProcess = spawn('npx', ['tsx', 'src/index.ts'], {
stdio: ['pipe', 'pipe', 'pipe'],
cwd: '/tmp/release-candidate'
});
this.serverProcess.stdout.on('data', (data) => {
const lines = data.toString().split('\n').filter(line => line.trim());
lines.forEach(line => {
try {
const message = JSON.parse(line);
this.handleMessage(message);
} catch (e) {
// Look for debug logs that might show API key info
if (line.includes('apikey') || line.includes('API key') || line.includes('Authorization')) {
console.log('๐ RC5 Debug:', line);
}
}
});
});
this.serverProcess.stderr.on('data', (data) => {
const output = data.toString();
if (output.includes('Umbrella MCP Server started successfully')) {
console.log('โ
RC5 ready');
}
// Look for any authentication debug info
if (output.includes('apikey') || output.includes('API key') || output.includes('Authorization')) {
console.log('๐ RC5 Error Debug:', output);
}
});
await new Promise(resolve => setTimeout(resolve, 3000));
}
handleMessage(message) {
if (message.id && this.pendingRequests.has(message.id)) {
const resolve = this.pendingRequests.get(message.id);
this.pendingRequests.delete(message.id);
resolve(message);
}
}
async sendRequest(method, params) {
const id = this.messageId++;
const request = { jsonrpc: '2.0', id, method, params };
return new Promise((resolve, reject) => {
this.pendingRequests.set(id, resolve);
this.serverProcess.stdin.write(JSON.stringify(request) + '\n');
setTimeout(() => {
if (this.pendingRequests.has(id)) {
this.pendingRequests.delete(id);
reject(new Error('Timeout'));
}
}, 15000);
});
}
async initialize() {
await this.sendRequest('initialize', {
protocolVersion: '2024-11-05',
capabilities: {},
clientInfo: { name: 'api-key-checker', version: '1.0.0' }
});
}
async authenticate() {
console.log('๐ Authenticating RC5...');
const result = await this.sendRequest('tools/call', {
name: 'authenticate_user',
arguments: {
username: 'david+saola@umbrellacost.com',
password: 'Dsamsung1!'
}
});
const response = result.result?.content?.[0]?.text || '';
console.log('โ
RC5 authenticated');
// Look for any API key info in the response
if (response.includes('apikey') || response.includes('API key')) {
console.log('๐ Auth response contains API key info');
}
return result;
}
async testUserInfo() {
console.log('๐ Getting user info from RC5...');
const result = await this.sendRequest('tools/call', {
name: 'api___users',
arguments: {}
});
const response = result.result?.content?.[0]?.text || '';
console.log('Response preview:', response.substring(0, 500));
return result;
}
async disconnect() {
if (this.serverProcess) {
this.serverProcess.kill();
}
}
}
async function checkRC5ApiKey() {
const checker = new RC5ApiKeyChecker();
try {
console.log('๐ CHECKING RC5 API KEY USAGE');
console.log('โ'.repeat(50));
await checker.startRC5();
await checker.initialize();
await checker.authenticate();
await checker.testUserInfo();
} catch (error) {
console.error('โ Check failed:', error.message);
} finally {
await checker.disconnect();
}
}
checkRC5ApiKey();