Skip to main content
Glama
App Store Connect MCP

App Store Connect MCP

by topcheer
README.md
# App Store Connect MCP

A [Model Context Protocol](https://modelcontextprotocol.io/) server that exposes the entire **Apple App Store Connect API** (1,200+ operations) via 4 lightweight MCP tools. Query apps, manage builds, handle submissions, read analytics, manage users, and more — all from your AI assistant.

> **Why only 4 tools?** Registering 1,216 tools would consume ~140K tokens of LLM context, making the server unusable. Instead, the LLM uses `search_apis` → `get_tool_details` → `call_api` to discover and execute any operation on demand — keeping context tiny while maintaining full API coverage.

[![npm version](https://img.shields.io/npm/v/@ggaiteam/appstore-connect-mcp.svg)](https://www.npmjs.com/package/@ggaiteam/appstore-connect-mcp)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org/)

## Features

- **Complete API coverage** — all 1,216 operations from the App Store Connect API v4.4
- **Context-friendly** — only 4 MCP tools registered (not 1,216), protecting LLM context window
- **Tool discovery workflow** — `search_apis` (ranked, synonym-aware) → `get_tool_details` → `call_api`
- **Task recipes as MCP prompts** — 18 multi-call workflows (submit for review, TestFlight distribution, pricing, subscriptions, screenshots, signing, ...) with exact operation chains and pitfalls, plus server instructions and Agent Skills (`skills/`) exports
- **Full request/response schemas** — `get_tool_details` returns the resolved JSON:API body schema (attributes, relationships with target resource types), the response shape, and a ready-to-copy example body — agents never fly blind
- **Response truncation** — large API responses truncated at 25KB to fit LLM context
- **Two transports** — `stdio` for local use (ggcode, Claude Desktop, Cursor), `HTTP` for remote deployment
- **JWT authentication** — automatic ES256 token generation and caching
- **Docker ready** — multi-stage Dockerfile with health checks (TypeScript and Rust images)
- **Rust port** — feature-parallel implementation in [`rust/`](https://github.com/topcheer/appstore-connect-mcp/blob/main/rust/README.md) sharing the same generated catalog: single 6.6MB binary, no runtime deps
- **Auto-publish** — push a git tag `v1.x.x` to publish to npm (OIDC, no token needed)
- **iOS app: ASC Hub** — your .p8 key sealed in the Secure Enclave, serving agents over the LAN with on-phone approvals and a live Activity screen; the npm `--mobile` bridge pairs it with any stdio MCP client (see [ASC Hub](#ios-app-asc-hub--mobile-bridge))

## Quick Start

### 1. Get API Credentials

1. Go to [App Store Connect → Users and Access → Keys](https://appstoreconnect.apple.com/access/api)
2. Click **Generate API Key** (or use an existing one)
3. Note down:
   - **Issuer ID** — shown at the top of the Keys page
   - **Key ID** — shown in the key list
   - **Private Key (.p8 file)** — download it (only available once)

> The key needs at least **App Manager** or **Admin** role for full functionality.

### 2. Install

#### Option A: npm (recommended)

```bash
npm install -g @ggaiteam/appstore-connect-mcp
```

#### Option B: One-line installer

```bash
curl -fsSL https://raw.githubusercontent.com/topcheer/appstore-connect-mcp/main/scripts/install.sh | bash
```

#### Option C: Docker

```bash
docker pull ghcr.io/topcheer/appstore-connect-mcp:latest   # ghcr
docker pull ggcodedev/appstore-connect-mcp:latest          # Docker Hub
```

### 3. Configure Your MCP Client

#### ggcode (topcheer/ggcode) — Recommended

Add to `~/.ggcode/ggcode.yaml` under `mcp_servers`:

```yaml
mcp_servers:
  - args:
      - -y
      - '@ggaiteam/appstore-connect-mcp@latest'
    command: npx
    env:
      APP_STORE_CONNECT_ISSUER_ID: your-issuer-id-here
      APP_STORE_CONNECT_KEY_ID: your-key-id-here
      APP_STORE_CONNECT_P8_FILE: /path/to/AuthKey_XXXXXXXXXX.p8
    name: appstore-connect
    type: stdio
```

Restart ggcode. The 4 MCP tools (`search_apis`, `get_tool_details`, `call_api`, `list_categories`) will be available immediately.

**Example session in ggcode:**

```
> 列出我的 App Store Connect 应用列表

# ggcode will:
# 1. call_api("apps_getCollection", {arguments: {limit: 50}})
# 2. For each app, call_api("appStoreVersions_getToManyRelated", ...)
# 3. Summarize the results
```

#### Claude Desktop

Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "appstore-connect": {
      "command": "npx",
      "args": ["-y", "@ggaiteam/appstore-connect-mcp"],
      "env": {
        "APP_STORE_CONNECT_ISSUER_ID": "your-issuer-id",
        "APP_STORE_CONNECT_KEY_ID": "your-key-id",
        "APP_STORE_CONNECT_P8_FILE": "/path/to/AuthKey_XXXXXXXXXX.p8"
      }
    }
  }
}
```

#### Cursor

Add to your Cursor MCP settings:

```json
{
  "mcpServers": {
    "appstore-connect": {
      "command": "npx",
      "args": ["-y", "@ggaiteam/appstore-connect-mcp"],
      "env": {
        "APP_STORE_CONNECT_ISSUER_ID": "your-issuer-id",
        "APP_STORE_CONNECT_KEY_ID": "your-key-id",
        "APP_STORE_CONNECT_P8_FILE": "/path/to/AuthKey_XXXXXXXXXX.p8"
      }
    }
  }
}
```

> **Alternatively**, inline the private key instead of a file path:
> ```json
> "APP_STORE_CONNECT_PRIVATE_KEY": "-----BEGIN PRIVATE KEY-----\nMIGTAg...\n-----END PRIVATE KEY-----"
> ```

Restart your client.

## Usage

Once connected, ask your AI assistant:

> "List all my apps on App Store Connect"

> "Show me the latest build for bundle ID com.example.myapp"

> "Get all pending app review submissions"

> "Search for subscription-related API operations"

The AI uses `search_apis` → `get_tool_details` → `call_api` to discover and execute operations.

### 4 MCP Tools

| Tool | Description |
|------|-------------|
| `search_apis` | Search 1,216 API operations by keywords (tokenized, ranked, synonym-aware: `testflight` finds `beta*`, `pricing` finds price points). Results include `relatedRecipes` when a task recipe matches |
| `get_tool_details` | Full parameter schema + resolved request-body schema + response shape + copy-ready example for one operation |
| `call_api` | Execute any API operation by name + arguments |
| `list_categories` | List all 192 API resource categories with operation counts |

### How It Works

```
User: "List my apps"
  ↓
AI calls: search_apis("apps")
  → finds: apps_getCollection (GET /v1/apps)
  ↓
AI calls: get_tool_details("apps_getCollection")
  → gets: query params, response shape (collection of apps,
    fields: name, bundleId, sku, ...)
  ↓
AI calls: call_api("apps_getCollection", {arguments: {limit: 10}})
  → returns: [{name: "MyApp", bundleId: "com.example.myapp"}, ...]
```

For POST/PATCH operations the details payload additionally contains the exact
JSON:API body schema - `data.type` enum, all `attributes` with types/enums,
and `relationships` with their target resource types - plus an example body
the model can copy and fill in.

Some endpoints do not return JSON (live-verified): `salesReports` / `financeReports`
return gzip reports and `perfPowerMetrics` returns a vendor JSON type, and Apple
rejects the default `Accept: application/json` with 406. Pass `_accept` inside
`arguments` (`"application/a-gzip"` or `"*/*"`); the npm server returns binary
bodies as `{_binary:{base64}}` (or a temp-file path when large), the Rust build
returns metadata only.

### Common Operations

| What | Operation |
|------|----------|
| List apps | `call_api("apps_getCollection", {})` |
| List builds | `call_api("builds_getCollection", {arguments: {"filter[preReleaseVersion.build.app]": "app-id"}})` |
| App versions | `call_api("appStoreVersions_getCollection", {arguments: {"filter[app]": "app-id"}})` |
| Beta testers | `call_api("betaTesters_getCollection", {})` |
| Sales reports | `call_api("salesReports_getCollection", {arguments: {"filter[frequency]": "DAILY"}})` |

### Task Recipes (Prompts) and Skills

Apple's OpenAPI spec ships with **zero descriptions**, and the generated summaries are derived from operationIds ("Create accessibility Declaration") — so a literal search cannot answer "how do I submit for review?". The server therefore carries curated task knowledge in `src/recipes.json`:

- **18 recipes**, each the exact operation chain for one task (which operation, in which order, which id feeds where, which enums, plus pitfalls). Examples: `submit-for-review` (version → reviewSubmission → item → submitted), `testflight-distribute` (group → build → export compliance → beta review → testers), `change-app-price` (territory → price point → new schedule), `manage-screenshots` (set → reserve → upload → commit → reorder), `signing-cert-device-profile`.
- Exposed through the standard MCP **prompts** capability (`prompts/list`, `prompts/get` with arguments such as `app_id`), summarized in the server **instructions** handed to the model at `initialize`, and hinted from `search_apis` via `relatedRecipes`.
- The same data is exported to **Agent Skills** (`skills/<id>/SKILL.md`, [agentskills.io](https://agentskills.io) format) for clients that load skills from disk, e.g. Claude Code: `/.mcp__appstore-connect__submit-for-review app_id=...` (prompts appear as slash commands) or point your client at the `skills/` directory.

MCP does **not** (as of spec 2026-07-28) define a `skills` primitive — prompts are the protocol-native mechanism, and `SKILL.md` is the client-side file format; this server provides both from one source. `scripts/build-skills.mjs` validates every operation name referenced by a recipe against the catalog (build fails on typos), mirrors the file into `rust/recipes.json`, and regenerates `skills/`.

The Google Play server (`play-mcp`) ships the same kind of task knowledge in `src/gplay-recipes.json`: **27 recipes** with the `gplay-` prefix — `gplay-release-to-track` (edit → upload → tracks → validate → commit), `gplay-staged-rollout`, `gplay-store-listing`, `gplay-store-graphics`, `gplay-testers`, `gplay-reply-to-reviews`, `gplay-subscriptions`, `gplay-one-time-products`, `gplay-orders-refund`, `gplay-purchases-subscriptions`, `gplay-vitals-crash-anr`, `gplay-error-reports`, `gplay-integrity-decode`, `gplay-generated-apks`, ... They are served as prompts, listed in the server instructions, hinted from `search_apis`, and exported to `skills/gplay-*/SKILL.md` by the same build step (validated against `rust/gplay-tools.json`).

A few Google operations have no recipe because they are one call or Console-only edge cases; the server instructions document them as *catalog-only*: `appsigning_enrollApp` / `appsigning_rotateAppSigningKey` (self-hosted Cloud KMS keys only - dangerous, a key change cannot be undone; everything else lives in Play Console > App integrity), the hosted app store APIs (`appstoreappsreview_*`, `appstorecatalog_*`), and `edits_deobfuscationfiles_upload` / `edits_expansionfiles_*` which work like the other edit uploads. Call them directly via `call_api` after `get_tool_details`.

**Code snippets for Google operations** (`get_tool_details` on `play-mcp`, or the generated snippets) follow the same contract as the Apple ones but are provider-aware: absolute URLs because Google spreads the Play APIs over several hosts, `{+name}` / `{name=apps/*}` path templates resolved into the call, and an RS256 service-account helper instead of the ES256 `.p8` one — `rust/helpers/GoogleJWT.swift` (Security.framework, no dependencies), `gplay.ts` (`google-auth-library`), `gplay.py` (`google-auth` + `requests`) and `gplay-token.sh` (openssl). `cargo test` type-checks the generated samples when the toolchains exist (`tsc --strict`, `swiftc`) and pins the RS256 signature against an openssl vector; CI runs the Swift check on a macOS runner.
**Demo mode (both servers):** `MCP_DEMO=1 ./play-mcp` (or `asc-mcp`) starts without credentials. `call_api` answers from `rust/demo/google-play.json` (studio "Orbit Labs": `dev.fixture.app` = Rocket Notes, `dev.fixture.clock`) and the Apple fixtures; edits are staged and only visible after `edits_commit`, dangerous operations still require `confirm: true`, and nothing is sent to Apple or Google. Ideal for trying a recipe end to end before pointing it at a real package.

```
User: "Submit version 2.1 for review"
  ↓
AI: prompts/get(name="submit-for-review", arguments={app_id})
  → gets the 5-step chain + pitfalls
  ↓
AI: get_tool_details("reviewSubmissions_createInstance") → call_api(...)  … per step
```

> **Docker Hub mirror**: when repo secrets `DOCKERHUB_USERNAME` / `DOCKERHUB_TOKEN`
> are configured, the same images are also pushed to
> `docker.io/topcheer/appstore-connect-mcp` and
> `docker.io/topcheer/appstore-connect-mcp-rust` automatically.

## iOS apps: ASC Hub & Play Console Hub + `--mobile` bridge

ASC Hub (`apple/ASC_Hub`) is a SwiftUI app around the same Rust core. The iPhone is the server: it holds the App Store Connect key, signs every JWT on the device and speaks streamable-HTTP MCP on the LAN. The npm package's `--mobile` mode is a stdio ⇄ HTTP bridge, so clients that only speak stdio (ggcode, Claude Desktop, Cursor, VS Code) can use it with one line:

```json
{ "mcpServers": { "appstore-connect": {
    "command": "npx", "args": ["-y", "@ggaiteam/appstore-connect-mcp", "--mobile"] } } }
```

First run: the bridge discovers the phone over Bonjour (`_mcp._tcp`, `vendor=asc-hub`), runs the `p256-aesgcm` handshake (ECDH P-256 → HKDF → AES-256-GCM, HMAC confirms both ways) and you approve on the iPhone with Face ID. The key is sent once, encrypted, sealed with a Secure Enclave key and never leaves the phone. Later runs reuse the saved device token (no re-pairing) and the bridge re-initializes the MCP session automatically after the app restarts.

On the phone you get: **Today** (server, pairing mode, key status, *Next steps* — what your app needs right now), **Activity** (every call live: client, endpoint, HTTP status, latency, Apple error code/detail; tap for the full request), **Reference** (search 1,216 operations + 20 task recipes, copy or AirDrop real Swift/TypeScript/cURL/Python with a client helper that signs the JWT), **Settings** (demo mode, approvals for destructive calls, trusted clients, forget key). A demo mode works without a key.

Build it: `cd apple/ASC_Hub && xcodegen generate && open ASC_Hub.xcodeproj` (Rust core via `rust/build-ios.sh`; `run-sim.sh` builds and installs on a dedicated simulator). See `docs/mobile-app-design.md` for the architecture and protocol.

**Play Console Hub** (`gg.ai.playconsolehub`) is the Google Play twin, built from the same sources with `Store.current == .googlePlay` (an Info.plist key per target): same screens, same pairing and Secure Enclave sealing, but the served catalog is `play-mcp` (206 Google Play Developer API operations + 27 recipes, Kotlin/TypeScript/cURL/Python code), the credential is a service-account JSON, and **Today** lists *next steps* for one Play package (staged rollout to finish, listing locales missing a title, draft base plans, reviews to answer). Demo mode runs the whole app from `rust/demo/google-play.json` (studio "Orbit Labs", packages `dev.fixture.app` / `dev.fixture.clock`) before any key is added. The `--mobile` bridge pairs with it exactly like with ASC Hub (both advertise `vendor=asc-hub`; the phone decides the catalog). Build and run it with `run-sim.sh --play`; the macOS menu-bar targets (`ASC_HubMac`, `PlayConsoleHubMac`) share `Sources/HubKit` with the iOS apps and embed the signed `asc-mcp` / `play-mcp` server. Store copy, review notes and screenshots: `apple/ASC_Hub/store/play-console-hub.md`.

## Installing the Rust binary

**From crates.io** (any platform; MSRV Rust 1.85, build needs cmake + perl for aws-lc-rs):

```bash
cargo install appstore-connect-mcp
```

**Prebuilt binaries** are attached to every GitHub Release (`v1.1.0+`) — macOS
arm64/x86_64 and Linux x86_64:

```bash
# one-line install
curl -fsSL https://raw.githubusercontent.com/topcheer/appstore-connect-mcp/main/install.sh | bash

# or pin a version
bash install.sh v1.2.1
```

The script detects your platform, verifies the SHA-256 checksum, installs to
`~/.local/bin/appstore-connect-mcp` (override with `PREFIX=...`), and re-signs
the binary ad-hoc on macOS so Gatekeeper does not kill it.

From a local checkout instead:

```bash
cargo install --path rust
```

## Google Play server (`play-mcp`)

The same Rust core serves the **Google Play Developer API** as a second binary, `play-mcp`:
`androidpublisher` v3 (edits/tracks/releases, store listing, reviews, in-app products,
subscriptions, orders), Play Developer Reporting (vitals, crashes/ANRs, error reports), Play
Games Services and Play Integrity - 206 operations behind the same 4 tools, with the
edit-transaction model handled for you (`edits_insert` → mutations → `edits_validate` →
`edits_commit`, the server remembers the open edit per package), uploads from
`GPLAY_UPLOAD_ROOTS`, a `confirm: true` gate on dangerous operations (refunds, track changes,
app-signing key rotation), per-bucket quota pacing and 27 task recipes (see above).

**Install** - any of:

```bash
# npm wrapper (downloads the prebuilt binary, SHA-256 verified)
npx -y @ggaiteam/google-play-mcp --check        # verify credentials against the real API
MCP_DEMO=1 npx -y @ggaiteam/google-play-mcp     # try it without any credentials

# install.sh variant
BIN=play-mcp bash install.sh                    # -> ~/.local/bin/play-mcp

# from source / crates.io
cd rust && cargo build --release --bin play-mcp
cargo install appstore-connect-mcp --bin play-mcp

# Docker (same Dockerfile, BIN picks the server)
docker build -f rust/Dockerfile --build-arg BIN=play-mcp -t appstore-connect-mcp:gplay .
docker run --rm -p 3000:3000 -e GOOGLE_PLAY_SERVICE_ACCOUNT_FILE=/k.json -v $PWD/k.json:/k.json appstore-connect-mcp:gplay
```

**Credentials**: a Google Cloud service-account JSON key (Google Cloud Console > IAM & Admin >
Service Accounts > Keys) whose account is added in Play Console > Users and permissions with the
needed permissions, passed as `GOOGLE_PLAY_SERVICE_ACCOUNT_FILE` (or `GOOGLE_PLAY_SERVICE_ACCOUNT_JSON`,
or a raw `GOOGLE_PLAY_ACCESS_TOKEN`). Claude Desktop:

```json
{ "mcpServers": { "google-play": {
    "command": "npx", "args": ["-y", "@ggaiteam/google-play-mcp"],
    "env": { "GOOGLE_PLAY_SERVICE_ACCOUNT_FILE": "/path/service-account.json" } } } }
```

`--check` proves the key (token + Reporting `apps.search`), `scripts/verify-live-gplay.mjs --package <id>`
runs the read-only smoke against a real package, and the release recipes can be rehearsed
first with `MCP_DEMO=1` (fixtures, nothing is sent to Google).

## Remote Deployment (HTTP Mode)

### Docker Compose

```bash
# 1. Create .env file
cp .env.example .env
# Edit .env with your credentials

# 2. Start
docker compose up -d
```

The server is available at `http://localhost:3000/mcp`.

### Docker (manual)

```bash
docker run -d \
  --name appstore-connect-mcp \
  -p 3000:3000 \
  -e APP_STORE_CONNECT_ISSUER_ID=your-issuer-id \
  -e APP_STORE_CONNECT_KEY_ID=your-key-id \
  -e APP_STORE_CONNECT_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" \
  ghcr.io/topcheer/appstore-connect-mcp:latest        # or ggcodedev/appstore-connect-mcp:latest
  # pinned: ...:1.2.1
```

Two images are published on every push and release:

| Image | Runtime | Size |
|-------|---------|------|
| `ghcr.io/topcheer/appstore-connect-mcp` | Node 20 (TypeScript) | ~200MB |
| `ghcr.io/topcheer/appstore-connect-mcp-rust` | debian-slim (Rust binary) | ~146MB |

Both images are published for **`linux/amd64` and `linux/arm64`** (multi-arch
manifest lists; `docker pull` picks the right architecture automatically).
They are mirrored to Docker Hub as `ggcodedev/appstore-connect-mcp`
and `ggcodedev/appstore-connect-mcp-rust` (same tag set), published
automatically whenever the repo secrets `DOCKERHUB_USERNAME` /
`DOCKERHUB_TOKEN` are configured.

Multi-arch note: the Rust image cross-compiles on the native build
platform (`FROM --platform=$BUILDPLATFORM` + gcc cross toolchains) because
aws-lc-rs cannot be compiled under qemu emulation - see rust/Dockerfile.

Both expose the same MCP surface: `POST /mcp`, `DELETE /mcp`, `GET /health`,
port 3000, HTTP transport by default. The Rust image additionally refuses
`GET /mcp` (server-initiated SSE) with 405, which MCP clients treat as
optional.

### Health Check

```bash
curl http://localhost:3000/health
# {"status":"ok","server":"appstore-connect-mcp","version":"1.0.5"}
```

### Connect Remote MCP to Claude Desktop

```json
{
  "mcpServers": {
    "appstore-connect": {
      "url": "http://your-server:3000/mcp"
    }
  }
}
```

## CLI Usage

```bash
# Stdio mode (default — for local MCP clients)
appstore-connect-mcp

# HTTP mode (for remote deployment)
appstore-connect-mcp --transport http --port 3000 --host 0.0.0.0

# With verbose logging
appstore-connect-mcp --verbose
```

### CLI Flags

| Flag | Default | Description |
|------|---------|-------------|
| `--transport` | `stdio` | Transport mode: `stdio` or `http` |
| `--port` | `3000` | HTTP port (HTTP mode only) |
| `--host` | `0.0.0.0` | HTTP bind host |
| `--issuer-id` | env | App Store Connect issuer ID |
| `--key-id` | env | API key ID |
| `--p8-file` | env | Path to .p8 private key file |
| `--mobile` | off | Bridge to the ASC Hub iPhone app instead of calling Apple directly |
| `--mobile-url` | Bonjour | Explicit phone URL, e.g. `http://192.168.1.5:47470` (skips discovery) |
| `--mobile-device` | first | Prefer a phone by name/id when several are visible |
| `--mobile-config` | `~/.config/appstore-connect-mcp/mobile.json` | Where the device token is saved |
| `--mobile-session-only` | off | Ask the phone not to remember the key |
| `--verbose` | off | Enable verbose logging |

### Environment Variables

| Variable | Description |
|----------|-------------|
| `APP_STORE_CONNECT_ISSUER_ID` | Issuer ID from App Store Connect |
| `APP_STORE_CONNECT_KEY_ID` | Key ID |
| `APP_STORE_CONNECT_PRIVATE_KEY` | PEM private key content (inline) |
| `APP_STORE_CONNECT_P8_FILE` | Path to .p8 file (alternative to above) |
| `MCP_TRANSPORT` | `stdio` or `http` |
| `MCP_PORT` | HTTP port |
| `MCP_HOST` | HTTP host |
| `MCP_VERBOSE` | `1` to enable verbose logging |
| `MCP_DEMO` | `1` starts in demo mode: no credentials needed, `call_api` answers from fixtures (`rust/demo/*.json`) and nothing is sent to Apple or Google. Works for both servers; edits in the Google demo are staged and committed like the real API. |
| `GOOGLE_PLAY_SERVICE_ACCOUNT_FILE` | Google service-account JSON key (`play-mcp`); `_JSON` for inline |
| `GOOGLE_PLAY_SCOPES` | Space-separated scope override (default: androidpublisher, playdeveloperreporting, games, playintegrity) |
| `GPLAY_UPLOAD_ROOTS` | Colon-separated directories `play-mcp` may upload from |
| `GOOGLE_PLAY_DOWNLOAD_DIR` | Where `generatedapks.download` / `systemapks.variants.download` write files |
| `GOOGLE_PLAY_QPM_<BUCKET>` | Requests-per-minute override for a quota bucket (publishing, reporting, ...) |

## Architecture

```
┌──────────────────┐     ┌──────────────────┐
│  MCP Client      │     │  MCP Server      │
│  (Claude, etc.)  │◄───►│                  │
└──────────────────┘     │  ┌────────────┐  │     ┌─────────────────┐
                         │  │ Tool       │  │     │ App Store       │
   stdio or HTTP/SSE     │  │ Registry   │──┼────►│ Connect API     │
                         │  │ (1,216     │  │     │ api.appstore    │
                         │  │  tools)    │  │     │ connect.apple   │
                         │  └────────────┘  │     │ .com            │
                         │       │          │     └─────────────────┘
                         │  ┌────▼─────┐    │            ▲
                         │  │ JWT Auth │    │            │
                         │  │ (ES256)  │────┼────────────┘
                         │  └──────────┘    │
                         └──────────────────┘
```

- **Tool data** is generated from Apple's OpenAPI spec (`scripts/generate-tools.py`)
- **Runtime** loads `tools.json` (1,216 ops) but only registers 4 MCP tools
- **JWT tokens** are cached and auto-refreshed (20-minute TTL)
- **Responses** are truncated at 25KB to fit LLM context windows

### Two Implementations

| | TypeScript (`src/`) | Rust ([`rust/`](https://github.com/topcheer/appstore-connect-mcp/blob/main/rust/README.md)) |
|---|---------------------|----------------------------------|
| Runtime | Node >= 18, npm package | Single static binary |
| MCP layer | `@modelcontextprotocol/sdk` | Protocol implemented directly (JSON-RPC 2.0) |
| HTTP transport | SDK StreamableHTTP (GET SSE wired, unused) | axum, `POST/DELETE /mcp` + `/health` (GET SSE -> 405) |
| Catalog | `dist/tools.json` loaded at startup | Same file embedded at compile time (`include_str!`) |
| Package | `@ggaiteam/appstore-connect-mcp` on npm | `ghcr.io/topcheer/appstore-connect-mcp-rust` image |
| Env vars / CLI flags | identical | identical |

Both share `src/tools.json` as the single source of truth — regenerate it
with `npm run generate` and each implementation picks it up (TS: copy at
build; Rust: embed at compile).

### Regenerating Tools

When Apple updates their API:

```bash
# Download the latest OpenAPI spec
# https://developer.apple.com/app-store-connect/

# Generate updated tools.json
python3 scripts/generate-tools.py openapi.oas.json src/tools.json

# Rebuild
npm run build
```

## Development

```bash
# Clone
git clone https://github.com/topcheer/appstore-connect-mcp.git
cd appstore-connect-mcp

# Install
npm install

# Generate tools from OpenAPI spec
npm run generate

# Build
npm run build

# Run locally
APP_STORE_CONNECT_ISSUER_ID=... \
APP_STORE_CONNECT_KEY_ID=... \
APP_STORE_CONNECT_P8_FILE=... \
npm start
```

### Project Structure

```
├── scripts/
│   ├── generate-tools.py     # OpenAPI → tools.json generator
│   ├── build-skills.mjs      # recipes.json → validate ops, mirror to rust/, export skills/
│   └── install.sh            # One-line installer
├── src/
│   ├── index.ts              # Entry point + CLI
│   ├── server.ts             # MCP server (4 tools + prompts + instructions)
│   ├── transport.ts          # stdio + HTTP transports
│   ├── auth.ts               # JWT (ES256) token generation
│   ├── client.ts             # App Store Connect API client
│   ├── tools.ts              # Tool schema builder + executor
│   ├── search.ts             # Ranked, synonym-aware operation search
│   ├── recipes.ts            # Task recipes: loader, prompt renderer, instructions
│   ├── recipes.json          # Curated knowledge: synonyms, intent phrases, 18 recipes
│   ├── types.ts              # TypeScript type definitions
│   └── tools.json            # Generated tool definitions (1,216 ops)
├── rust/src/                 # Rust port (same 4 tools, prompts, instructions, search)
│   └── knowledge.rs         # recipes/search port (embeds rust/recipes.json)
├── skills/                   # Agent Skills export (skills/<id>/SKILL.md)
├── test/                     # node:test: search regression + real stdio MCP handshake
├── Dockerfile                # Multi-stage Docker build
├── docker-compose.yml        # Remote deployment config
├── .github/workflows/
│   ├── ci.yml                # Lint + build + test
│   ├── npm-publish.yml       # Auto-publish to npm on release
│   └── docker.yml            # Build + push Docker image
└── package.json
```

## npm Publishing

Publishing is fully automated via GitHub Actions with OIDC trusted publishing — **no NPM_TOKEN needed**.

### Release a new version

```bash
git tag v1.0.3
git push origin v1.0.3
```

That's it. The workflow will:
1. Extract version from the tag
2. Check if version already exists on npm (skip if so)
3. Build the package
4. Publish to npm with `--provenance=false --access public`
5. Auto-create a GitHub Release

### First-time setup (already done)

1. Package must exist on npm (first publish is manual: `npm publish --access public`)
2. Configure trusted publishing on npm: link the package to `topcheer/appstore-connect-mcp`
3. No NPM_TOKEN secret needed — OIDC handles authentication

## API Coverage

This server covers **all 1,216 operations** across the App Store Connect API:

| Method | Count |
|--------|-------|
| GET    | 768   |
| POST   | 168   |
| PATCH  | 153   |
| DELETE | 127   |

Including: Apps, Builds, App Store Versions, Beta Testing, Subscriptions, In-App Purchases, User Management, Sales Reports, Analytics, App Clips, Game Center, and more (192 categories total).

## Auth & Token Lifecycle

Both implementations share the same authentication behavior:

- **JWT (ES256)** signed from your `.p8` key, 20-minute TTL (Apple's maximum)
- **Automatic renewal** — the token is cached and transparently re-signed when
  less than 60 seconds of life remain; every `call_api` picks up a valid token
  with zero manual intervention
- **401 self-healing** — if Apple rejects the cached token (clock skew,
  server-side revocation between calls), the client force-signs a fresh JWT
  and retries exactly once before surfacing an error
- **No persistent connection** — every API call is an independent HTTPS
  request; there is no session to expire, so the server can stay mounted
  indefinitely. The only terminal failure mode is revoking the `.p8` key
  itself (both implementations fail identically then)
- `/health` reports process liveness only; credential validity is exercised
  by real API calls (deliberately, to avoid burning rate limits on a probe)

### Array query parameters

For `filter[...]`, `fields[...]`, `include`, `sort`, and `limit[...]` style
parameters, pass a JSON array — `call_api` serializes it the way
App Store Connect requires (comma-joined: `fields[apps]=name,bundleId`),
not as repeated keys, which Apple rejects with
`400 PARAMETER_ERROR.DUPLICATE`.

## Security

- Private keys are read from environment variables or files — never logged
- JWT tokens are short-lived (20 minutes max) and cached in memory only
- No data is stored or persisted between requests
- For remote deployment, use HTTPS/TLS termination at your reverse proxy

## License

MIT — see [LICENSE](LICENSE)

## Acknowledgments

- [Apple App Store Connect API](https://developer.apple.com/app-store-connect/) — API and OpenAPI specification
- [Model Context Protocol](https://modelcontextprotocol.io/) — Protocol specification