#!/usr/bin/env node
import dotenv from 'dotenv';
import { UmbrellaAuth } from './auth.js';
import { UmbrellaApiClient } from './api-client.js';
dotenv.config();
async function debugMSPRequest() {
console.log('🔍 DEBUGGING MSP REQUEST - Comparing MCP Client vs Curl');
console.log('=' .repeat(60));
const baseURL = process.env.UMBRELLA_API_BASE_URL || 'https://api.umbrellacost.io/api/v1';
const credentials = {
username: 'elisha@umbrellacost.cloud',
password: '6K2UX6DoYSgV%E'
};
console.log(`Base URL: ${baseURL}`);
console.log(`Username: ${credentials.username}`);
// Authenticate and get tokens
const auth = new UmbrellaAuth(baseURL);
await auth.authenticate(credentials);
const authHeaders = auth.getAuthHeaders();
console.log('\n📋 AUTHENTICATION HEADERS:');
// API key is built dynamically, not stored
console.log(`Authorization: ${authHeaders.Authorization}`);
// Create API client
const apiClient = new UmbrellaApiClient(baseURL);
apiClient.setAuthToken(authHeaders);
console.log('\n🔧 MAKING MCP CLIENT REQUEST:');
console.log('Endpoint: /msp/customers');
console.log('Method: GET');
console.log('Headers:');
// API key would be built dynamically when needed
console.log(` - Authorization: ${authHeaders.Authorization}`);
console.log(` - Content-Type: application/json`);
console.log(` - Accept: application/json`);
try {
const response = await apiClient.makeRequest('/msp/customers');
console.log('\n📤 MCP CLIENT RESPONSE:');
console.log(`Success: ${response.success}`);
console.log(`Error: ${response.error || 'None'}`);
console.log(`Message: ${response.message || 'None'}`);
console.log(`Data: ${response.data ? JSON.stringify(response.data, null, 2) : 'None'}`);
} catch (error: any) {
console.log('\n❌ MCP CLIENT ERROR:');
console.log(error.message);
}
console.log('\n🔗 EQUIVALENT CURL COMMAND:');
console.log(`curl --location --request GET '${baseURL}/msp/customers' \\`);
// API key would be built dynamically when needed
console.log(`--header 'Authorization: ${authHeaders.Authorization}' \\`);
console.log(`--header 'Content-Type: application/json'`);
console.log('\n✅ VERIFICATION COMPLETE');
console.log('The MCP client should produce the same result as the curl command above.');
}
debugMSPRequest().catch(console.error);