#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
console.log('🔍 COMPARING: server.ts vs server-with-auth.ts\n');
console.log('='.repeat(80));
// Read both server files
const serverPath = path.join(__dirname, '../../src/server.ts');
const serverWithAuthPath = path.join(__dirname, '../../src/server-with-auth.ts');
const serverCode = fs.readFileSync(serverPath, 'utf8');
const serverWithAuthCode = fs.readFileSync(serverWithAuthPath, 'utf8');
console.log('\n📋 ANALYSIS 1: Basic Info\n');
console.log('-'.repeat(80));
console.log(`server.ts: ${serverCode.split('\n').length} lines`);
console.log(`server-with-auth.ts: ${serverWithAuthCode.split('\n').length} lines`);
console.log('\n📋 ANALYSIS 2: Class Names\n');
console.log('-'.repeat(80));
const serverClass = serverCode.match(/export class (\w+)/);
const serverWithAuthClass = serverWithAuthCode.match(/export class (\w+)/);
console.log(`server.ts exports: ${serverClass ? serverClass[1] : 'NOT FOUND'}`);
console.log(`server-with-auth.ts exports: ${serverWithAuthClass ? serverWithAuthClass[1] : 'NOT FOUND'}`);
console.log('\n📋 ANALYSIS 3: API Handling\n');
console.log('-'.repeat(80));
// Check handleApiCall in server.ts
const serverHandleApi = serverCode.includes('handleApiCall');
const serverWithAuthHandleApi = serverWithAuthCode.includes('handleApiCall');
console.log(`server.ts has handleApiCall: ${serverHandleApi}`);
console.log(`server-with-auth.ts has handleApiCall: ${serverWithAuthHandleApi}`);
// Check for parameter validation
const serverValidation = serverCode.includes('QueryParamsSchema');
const serverWithAuthValidation = serverWithAuthCode.includes('QueryParamsSchema');
console.log(`\nserver.ts uses QueryParamsSchema: ${serverValidation}`);
console.log(`server-with-auth.ts uses QueryParamsSchema: ${serverWithAuthValidation}`);
// Check for accountKey handling
const serverAccountKey = serverCode.includes('accountKey');
const serverWithAuthAccountKey = serverWithAuthCode.includes('accountKey');
console.log(`\nserver.ts mentions accountKey: ${serverAccountKey} (${serverCode.split('accountKey').length - 1} times)`);
console.log(`server-with-auth.ts mentions accountKey: ${serverWithAuthAccountKey} (${serverWithAuthCode.split('accountKey').length - 1} times)`);
console.log('\n📋 ANALYSIS 4: Parameter Mapping\n');
console.log('-'.repeat(80));
// Check for customer_account_key mapping
const serverMapping = serverCode.includes('customer_account_key');
const serverWithAuthMapping = serverWithAuthCode.includes('customer_account_key');
console.log(`server.ts has customer_account_key mapping: ${serverMapping}`);
console.log(`server-with-auth.ts has customer_account_key mapping: ${serverWithAuthMapping}`);
// Check for PARAM-DEBUG
const serverDebug = serverCode.includes('[PARAM-DEBUG]');
const serverWithAuthDebug = serverWithAuthCode.includes('[PARAM-DEBUG]');
console.log(`\nserver.ts has [PARAM-DEBUG]: ${serverDebug}`);
console.log(`server-with-auth.ts has [PARAM-DEBUG]: ${serverWithAuthDebug}`);
console.log('\n📋 ANALYSIS 5: API Client Usage\n');
console.log('-'.repeat(80));
// Check how API client is imported
const serverApiImport = serverCode.match(/import.*ApiClient.*from/);
const serverWithAuthApiImport = serverWithAuthCode.match(/import.*ApiClient.*from/);
console.log(`server.ts imports: ${serverApiImport ? serverApiImport[0] : 'NOT FOUND'}`);
console.log(`server-with-auth.ts imports: ${serverWithAuthApiImport ? serverWithAuthApiImport[0] : 'NOT FOUND'}`);
console.log('\n📋 ANALYSIS 6: Key Differences\n');
console.log('-'.repeat(80));
console.log(`
KEY FINDINGS:
1. Class Names:
- server.ts: UmbrellaMcpServer (basic)
- server-with-auth.ts: UmbrellaAuthenticatedMcpServer (with auth)
2. Parameter Handling:
- server-with-auth.ts has extensive parameter validation
- server-with-auth.ts has customer_account_key mapping
- server-with-auth.ts has [PARAM-DEBUG] logging
3. Main Purpose:
- server.ts: Basic MCP server, simpler implementation
- server-with-auth.ts: Full authentication and parameter mapping
4. Current Issue:
- dual-transport.ts imports UmbrellaMcpServer (basic)
- Should it import UmbrellaAuthenticatedMcpServer?
- OR should the fixes be applied to server.ts?
`);
console.log('\n📋 ANALYSIS 7: Which Server Has Our Fixes?\n');
console.log('-'.repeat(80));
// Look for specific fixes
const fixesInServer = {
paramDebug: serverCode.includes('[PARAM-DEBUG]'),
accountKeyMapping: serverCode.includes('validatedParams.customer_account_key = validatedParams.accountKey'),
endpointsRequiringParams: serverCode.includes('ENDPOINTS_REQUIRING_CUSTOMER_PARAMS')
};
const fixesInServerWithAuth = {
paramDebug: serverWithAuthCode.includes('[PARAM-DEBUG]'),
accountKeyMapping: serverWithAuthCode.includes('validatedParams.customer_account_key = validatedParams.accountKey'),
endpointsRequiringParams: serverWithAuthCode.includes('ENDPOINTS_REQUIRING_CUSTOMER_PARAMS')
};
console.log('Fixes in server.ts:');
Object.entries(fixesInServer).forEach(([key, value]) => {
console.log(` ${value ? '✅' : '❌'} ${key}`);
});
console.log('\nFixes in server-with-auth.ts:');
Object.entries(fixesInServerWithAuth).forEach(([key, value]) => {
console.log(` ${value ? '✅' : '❌'} ${key}`);
});
console.log('\n' + '='.repeat(80));
console.log('CONCLUSION');
console.log('='.repeat(80));
console.log(`
The fixes are in server-with-auth.ts but dual-transport.ts uses server.ts!
OPTIONS:
1. Change dual-transport.ts to use server-with-auth.ts
2. Apply the same fixes to server.ts
3. Check if there's a reason for using the basic server
RECOMMENDATION: Need to understand the architecture decision first.
`);