This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Response language: Russian Comment language: English
MCP (Model Context Protocol) server for App Store Connect API integration, designed for Claude Code CLI. This server provides tools to manage iOS/macOS apps through App Store Connect.
# Build the project
swift build
# Run all unit tests (436 tests)
swift test
# Run the MCP server (requires environment variables or companies.json)
./.build/debug/asc-mcp
# Run with worker filtering (for clients with tool limits)
./.build/debug/asc-mcp --workers apps,builds,versions,reviews
# Run integration tests
./.build/debug/asc-mcp --test
# Clean build
swift package cleanThree config methods (checked in priority order):
--companies /path/to/companies.json(CLI argument)ASC_MCP_COMPANIESenv var → path to JSON file- Default JSON:
~/.config/asc-mcp/companies.json ASC_COMPANY_1_KEY_ID,ASC_COMPANY_2_KEY_ID... (multi-company env vars)ASC_KEY_ID+ASC_ISSUER_ID+ASC_PRIVATE_KEY_PATH(single company env vars)
Each company needs: keyID, issuerID, privateKeyPath (path to .p8 file).
WorkerManager (Workers/MainWorker/WorkerManager.swift) — central registry, routes tool calls by prefix.
Workers (33 workers, 293 tools):
| Worker | Prefix | Tools | Domain |
|---|---|---|---|
| CompaniesWorker | company_ |
3 | Multi-account management |
| AuthWorker | auth_ |
4 | JWT tokens |
| AppsWorker | apps_ |
9 | App listing, metadata, localizations |
| BuildsWorker | builds_ |
4 | Build management |
| BuildBetaDetailsWorker | builds_*_beta_ |
11 | TestFlight localizations, notifications, beta groups, individual testers |
| BuildProcessingWorker | builds_*_processing_ |
4 | Build states, encryption |
| AppLifecycleWorker | app_versions_ |
14 | Versions, submit, release, phased rollout, delete |
| ReviewsWorker | reviews_ |
8 | Customer reviews, responses, AI summarizations |
| BetaGroupsWorker | beta_groups_ |
9 | TestFlight groups CRUD, testers, builds |
| InAppPurchasesWorker | iap_ |
24 | IAP, subscriptions, localizations, prices, screenshots, availability, images |
| ProvisioningWorker | provisioning_ |
17 | Bundle IDs, devices, certificates, profiles, capabilities |
| BetaTestersWorker | beta_testers_ |
12 | Tester management, search, invite, relationships, invitations |
| AppInfoWorker | app_info_ |
10 | App info, categories, localizations, EULA |
| PricingWorker | pricing_ |
9 | Territories, availability, price points/schedule, app availabilities v2 |
| UsersWorker | users_ |
10 | Team members, roles, invitations, visible apps |
| AppEventsWorker | app_events_ |
9 | In-app events CRUD, localizations |
| AnalyticsWorker | analytics_ |
11 | Sales/financial reports, app summary, analytics reports/instances/segments, snapshot status |
| SubscriptionsWorker | subscriptions_ |
29 | Subscription CRUD, groups, localizations, prices, submit, group localizations, images, review screenshots |
| OfferCodesWorker | offer_codes_ |
10 | Subscription offer codes, one-time codes, custom codes |
| WinBackOffersWorker | winback_ |
5 | Win-back offers for subscriptions |
| IntroductoryOffersWorker | intro_offers_ |
4 | Introductory offers (free trial, pay-as-you-go, pay-up-front) |
| PromotionalOffersWorker | promo_offers_ |
6 | Promotional offers for subscriptions |
| SandboxTestersWorker | sandbox_ |
3 | Sandbox testers (list, update, clear purchase history) |
| BetaAppWorker | beta_app_ |
10 | Beta app localizations, review submissions, review details |
| PreReleaseVersionsWorker | pre_release_ |
3 | Pre-release versions (list, get, builds) |
| BetaLicenseAgreementsWorker | beta_license_ |
3 | Beta license agreements (list, get, update) |
| ScreenshotsWorker | screenshots_ |
16 | Screenshots, previews, sets, reorder, full upload, batch upload |
| CustomProductPagesWorker | custom_pages_ |
10 | Custom product pages, versions, localizations |
| ProductPageOptimizationWorker | ppo_ |
9 | A/B test experiments, treatments |
| PromotedPurchasesWorker | promoted_ |
9 | Promoted in-app purchases, images upload |
| ReviewAttachmentsWorker | review_attachments_ |
4 | App Store review attachments (upload, get, delete, list) |
| MetricsWorker | metrics_ |
4 | Performance/power metrics, diagnostics |
Services: HTTPClient (actor, GET/POST/PATCH/PUT/DELETE + retry with 429), JWTService (ES256), CompaniesManager
- Swift 6 Compliance: All types
Sendable, proper actor isolation - JWT Auth: CryptoKit ES256, tokens expire after 20 min
- Worker Pattern: 3 files per worker (Main + ToolDefinitions + Handlers)
- Routing: WorkerManager routes by tool name prefix
- Error Handling: Custom
ASCErrortype
- No emojis in metadata fields (What's New, Description, etc.)
- Version states:
READY_FOR_SALE: Published, read-onlyPREPARE_FOR_SUBMISSION: EditableWAITING_FOR_REVIEW,IN_REVIEW: Read-only
- Locale codes: Use standard format (en-US, ru-RU, de-DE, etc.)
swift test # Run all 436 tests across 31 suitesTest categories:
- Worker tests (
Tests/ASCMCPTests/Workers/):WorkerToolDefinitionsTests— tool count and name correctness per workerWorkerRoutingTests— unknown tool throwsMCPError.methodNotFoundParameterValidationTests— missing required params returnsisError
- Model tests (
Tests/ASCMCPTests/Models/) — decode, roundtrip, edge cases - Service tests (
Tests/ASCMCPTests/Services/) — JWT generation - Helper tests (
Tests/ASCMCPTests/HelperTests/) — JSON formatting, pagination - Core tests (
Tests/ASCMCPTests/Core/) — ASCError, config models
Test infrastructure: TestFactory (Tests/ASCMCPTests/Helpers/TestHelpers.swift) — creates mock HTTPClient, JWTService, loads fixtures.
./.build/debug/asc-mcp --test # Test company switching
./.build/debug/asc-mcp --test-metadata # Test metadata update- Implement handler in
Worker+Handlers.swift - Add tool definition in
Worker+ToolDefinitions.swift - Register in worker's
getTools()array - Add case to worker's
handleTool()switch - No changes needed in WorkerManager — it automatically routes by prefix
- Create directory
Workers/MyWorker/with 3 files:MyWorker.swift— class,getTools(),handleTool()switchMyWorker+ToolDefinitions.swift— tool schemasMyWorker+Handlers.swift— handler implementations
- Create models in
Models/MyDomain/MyModels.swift - Register in
WorkerManager.swift: property, init,registerWorkers()(ListTools + CallTool),reinitializeWorkers(), getter method - Add worker name to
EntryPoint.swift→validWorkersset - Add prefix description to
Application.swift→ server instructions - Update tests:
WorkerToolDefinitionsTests,WorkerRoutingTests,ParameterValidationTests
- Check version state (must be PREPARE_FOR_SUBMISSION for edits)
- Verify locale exists for the version
- Remove any emojis from text fields
- Check JWT token expiration (20 minutes)
EntryPoint.swift: Entry point with--workersfiltering and test modesCore/Application.swift: MCP server setup and initializationWorkers/MainWorker/WorkerManager.swift: Tool registry and routingModels/: API response/request models organized by domain:AppStoreConnect/,Builds/,AppLifecycle/— apps, versions, buildsInAppPurchases/,Subscriptions/— IAP, subscriptions, offer codes, win-backMarketing/— screenshots, custom pages, PPO experiments, promoted purchasesMetrics/,Analytics/,AppEvents/— performance, reports, eventsProvisioning/,Pricing/,Users/,AppInfo/— provisioning, pricing, usersShared/— shared types (upload operations, image assets)
Services/HTTPClient.swift: HTTP actor with JWT auth and retry logicServices/CompaniesManager.swift: Multi-account managementServices/JWTService.swift: ES256 JWT token generationHelpers/: JSONFormatter, SafeJSONHelpers, PaginationHelper, StderrWriter
- ALWAYS test as real MCP: When testing functionality, use actual MCP commands as if you're a real user working with the server
- Test edge cases and error scenarios
- Verify responses contain all necessary data for practical use
-
After making changes and building the project:
- Always respond: "Ready to reload MCP"
- Wait for user confirmation: "reloaded" or similar
- Then proceed with testing via MCP commands
- Fix any issues found during testing
-
After implementing features:
- Explain what each method returns
- Describe practical use cases for the returned data
- Example: "The
builds_listmethod returns a list of builds with their statuses and dates. This is useful for selecting a build for TestFlight or submitting to the App Store"
- MANDATORY: Comment all public methods with:
/// Brief description of what the method does /// - Returns: Description of return value and its structure /// - Throws: What errors can be thrown
- Document complex logic inline
- Add usage examples for non-obvious methods