Skip to main content
Glama

App Store Connect MCP Server

v1.1.1-learnings-summary.mdβ€’5.49 kB
# App Store Connect MCP v1.1.1 - Key Learnings & Architecture ## 🎯 Executive Summary Successfully fixed revenue calculation issue. Root cause: FINANCIAL reports contain complete revenue (including renewals), while SALES reports only show new purchases. Solution implemented aggregates all regions from FINANCIAL reports. **Results:** - **Accuracy Improvement**: 3x better than previous version - **Data Coverage**: Now includes all subscription renewals - **Architecture**: Service-based approach for better organization ## πŸ” Critical Discoveries ### 1. The FINANCIAL vs SALES Report Distinction - **SALES Reports**: Only new purchases (incomplete data) - **FINANCIAL Reports**: Complete revenue including renewals - **Key Insight**: Must aggregate regions (US, CA, EU, JP, AU, WW) - Z1 doesn't work ### 2. Currency Conversion Complexity - Developer Proceeds field varies by transaction type - High-value currencies (IDR, VND, TZS) need special handling - Implemented intelligent detection to prevent double-conversion ### 3. Report Availability Delays - FINANCIAL reports delayed ~1 month (normal for reconciliation) - Implemented automatic fallback to latest available month - Added graceful degradation to SALES reports when needed ## πŸ—οΈ Architecture Improvements ### Service-Based Architecture Created dedicated services for each App Store Connect domain: ``` /src/services/ β”œβ”€β”€ app-service.ts # App management β”œβ”€β”€ finance-service.ts # SALES reports & basic metrics β”œβ”€β”€ finance-report-service.ts # FINANCIAL reports (complete revenue) β”œβ”€β”€ analytics-service.ts # Usage analytics β”œβ”€β”€ beta-service.ts # TestFlight management β”œβ”€β”€ review-service.ts # Customer reviews └── subscription-service.ts # Subscription metrics ``` ### MCP Tool Enhancement - Primary source: FINANCIAL reports for revenue metrics - Automatic fallback: SALES reports if FINANCIAL unavailable - Proper Map to Object conversion for JSON serialization ## πŸ§ͺ Testing Strategy ### Retained Test Utilities - `test-mcp-server.ts` - Validates MCP protocol implementation - `test-all-tools.ts` - Comprehensive tool testing - `test-finance-reports.ts` - Financial API validation - `test-worldwide-revenue.ts` - Complete revenue aggregation test - `test-final-integration.ts` - End-to-end validation ### Testing Commands ```bash # Validate complete revenue npx tsx src/test-worldwide-revenue.ts # Test MCP integration npx tsx src/test-final-integration.ts # Verify all tools work npx tsx src/test-all-tools.ts ``` ## πŸ“Š Data Flow ``` Apple App Store Connect API β”œβ”€β”€ /financeReports (FINANCIAL) β”‚ β”œβ”€β”€ US Region β†’ Primary market β”‚ β”œβ”€β”€ CA Region β†’ Secondary market β”‚ β”œβ”€β”€ EU Region β†’ Growing market β”‚ β”œβ”€β”€ JP Region β†’ Strategic market β”‚ β”œβ”€β”€ AU Region β†’ Emerging market β”‚ └── WW Region β†’ Rest of world β”‚ └── Total: Complete revenue data β”‚ └── /salesReports (SALES - fallback only) └── Daily reports β†’ New purchases only ``` ## πŸ”§ Implementation Details ### Currency Handling Logic ```typescript // Intelligent currency detection const highValueCurrencies = ['IDR', 'VND', 'TZS', 'KRW', 'CLP', 'COP']; if (highValueCurrencies.includes(customerCurrency)) { if (proceedsRaw > 1000) { // Likely in local currency, needs conversion proceedsUSD = this.convertToUSD(proceedsRaw, customerCurrency); } } ``` ### Fiscal Period Mapping Apple's fiscal calendar starts in October: - Oct=1, Nov=2, Dec=3, Jan=4, Feb=5, Mar=6 - Apr=7, May=8, Jun=9, Jul=10, Aug=11, Sep=12 ### Report Aggregation Strategy 1. Fetch each region separately (Z1 doesn't work) 2. Sum Extended Partner Share column 3. Handle Sales vs Returns appropriately 4. Cache latest available month ## πŸš€ Version History ### v1.1.1 (Current) - Fixed revenue calculation accuracy - Added FINANCIAL reports integration - Implemented intelligent currency handling - Created service-based architecture ### v1.1.0 - Added comprehensive MCP tools - Initial financial reporting - Basic subscription metrics ### v1.0.0 - Initial MCP server implementation - Basic App Store Connect integration ## πŸ“ Debugging Philosophy Applied Following pragmatic principles from CLAUDE.md: - **Fix the problem, not the blame**: Found actual data structure differences - **Don't assume itβ€”prove it**: Tested each currency and report type - **Find root causes**: Identified FINANCIAL vs SALES distinction - **Use tracer bullets**: Built end-to-end tests first - **Keep it simple**: Direct aggregation instead of complex logic ## 🎯 Next Steps 1. **Monitor**: Track monthly revenue using FINANCIAL reports 2. **Optimize**: Consider caching strategies for report data 3. **Extend**: Add more detailed subscription analytics 4. **Document**: Keep test utilities documented for future debugging ## πŸ”‘ Critical Files **Core Implementation:** - `/src/services/finance-report-service.ts` - FINANCIAL reports handler - `/src/server/mcp-server.ts` - MCP tool definitions with fallback logic - `/src/services/finance-service.ts` - SALES reports and currency handling **Documentation:** - `/docs/revenue-calculation-fix-analysis.md` - Detailed bug analysis - `/docs/v1.1.1-learnings-summary.md` - This file - `/docs/CLAUDE.md` - Project-specific instructions --- *Last Updated: August 27, 2025* *Version: 1.1.1* *Status: Production Ready*

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