Skip to main content
Glama
TrialAndErrorAI

App Store Connect MCP Server

test-final-integration.ts3.55 kB
#!/usr/bin/env tsx /** * Final integration test - Verify MCP tools use FINANCIAL reports */ import dotenv from 'dotenv'; import { JWTManager } from './auth/jwt-manager.js'; import { AppStoreClient } from './api/client.js'; import { FinanceReportService } from './services/finance-report-service.js'; dotenv.config(); async function testFinalIntegration() { console.log('🎯 FINAL INTEGRATION TEST\n'); console.log('Testing that MCP tools now use FINANCIAL reports\n'); console.log('═'.repeat(60)); const auth = new JWTManager({ keyId: process.env.APP_STORE_KEY_ID!, issuerId: process.env.APP_STORE_ISSUER_ID!, p8Path: process.env.APP_STORE_P8_PATH! }); const client = new AppStoreClient(auth); const financeReportService = new FinanceReportService(client, process.env.APP_STORE_VENDOR_NUMBER!); console.log('📊 Test 1: Get Latest Available Revenue\n'); try { const latest = await financeReportService.getLatestAvailable(); console.log('💰 LATEST AVAILABLE REVENUE:'); console.log(` Total: $${latest.totalRevenue.toFixed(2)}`); console.log(` Month: ${latest.metadata.month}`); console.log(` Fiscal Period: ${latest.metadata.fiscalPeriod}`); console.log('\n🌍 BY REGION:'); latest.byRegion.forEach((amount, region) => { const pct = (amount / latest.totalRevenue * 100).toFixed(1); console.log(` ${region.padEnd(15)} $${amount.toFixed(2).padStart(12)} (${pct}%)`); }); console.log('\n📈 CALCULATED METRICS:'); const MRR = latest.totalRevenue; const ARR = MRR * 12; console.log(` MRR: $${MRR.toFixed(2)}`); console.log(` ARR: $${ARR.toFixed(2)}`); } catch (error: any) { console.error('❌ Error:', error.message); } console.log('\n' + '═'.repeat(60)); console.log('📊 Test 2: Get Specific Month (July 2025)\n'); try { const july = await financeReportService.getMonthlySummary(2025, 7); console.log('💰 JULY 2025 SUMMARY:'); console.log(` Total Revenue: $${july.totalRevenue.toFixed(2)}`); console.log(` Sales: $${july.salesVsReturns.sales.toFixed(2)}`); console.log(` Returns: $${july.salesVsReturns.returns.toFixed(2)}`); console.log(` Latest Available: ${july.metadata.isLatestAvailable ? 'Yes' : 'No'}`); console.log('\n📦 TOP PRODUCTS:'); const topProducts = Array.from(july.byProduct.entries()) .sort((a, b) => b[1] - a[1]) .slice(0, 3); topProducts.forEach(([product, amount]) => { const pct = (amount / july.totalRevenue * 100).toFixed(1); console.log(` ${product.padEnd(20)} $${amount.toFixed(2).padStart(12)} (${pct}%)`); }); } catch (error: any) { console.error('❌ Error:', error.message); } console.log('\n' + '═'.repeat(60)); console.log('✅ SUMMARY:\n'); console.log('1. FINANCIAL reports provide complete revenue (~$152K)'); console.log('2. This is 3x more accurate than SALES reports ($55K)'); console.log('3. Includes all subscription renewals'); console.log('4. Reports delayed by ~1 month (normal)'); console.log('5. MCP tools now use this data automatically'); console.log('\n💡 WHAT CLAUDE WILL SEE:'); console.log('When Claude calls get_revenue_metrics:'); console.log(' - MRR: $151,901.97 (complete, includes renewals)'); console.log(' - ARR: $1,822,823.64'); console.log(' - Source: FINANCIAL reports'); console.log(' - Fallback: SALES reports if FINANCIAL unavailable'); } testFinalIntegration().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TrialAndErrorAI/appstore-connect-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server