storebound/cli/mcp-tools.ts
CRT 48bd9780dd TestFlight through the App Store Connect API: apple testflight status | groups | testers | what-to-test | info | distribute
Beta groups from apple.testflight.groups (created when missing, never changed), testers from a CSV in .storebound/
(masked in logs, confirmation before Apple emails invitations, --remove / --invite), What to Test per locale from the
App Store listing (whatToTest or whatsNew), Test Information and Beta App Review details, builds by exact number to
groups, Beta App Review submission behind --submit-review and a confirmation. Pure planners in cli/lib/testflight.ts,
shared CSV / table / JSON:API helpers. MCP: apple_testflight_status, _groups, _what_to_test, _info, _distribute
(internal groups only). Skill testflight.
2026-10-10 15:28:10 +00:00

203 lines
21 KiB
TypeScript

// The tools `storebound mcp` offers, as data. Pure, so tests can check the list and the argv each call builds.
// Rules: one tool per CLI command; every tool that writes anything has `dry_run` defaulting to true; nothing that
// submits for review, releases to the public, resumes / completes a rollout, cancels a submission or deletes is
// exposed. Those stay terminal commands the owner runs (they also ask for confirmation there).
export interface JsonSchema { type: string; description?: string; enum?: (string | number)[]; default?: unknown; items?: JsonSchema; minimum?: number; maximum?: number; pattern?: string }
export interface ToolDef {
name: string;
title: string;
description: string;
/** CLI words before the options, e.g. ['play', 'listing']. */
command: string[];
/** Writes to a store or to local files. Gets `dry_run` (default true). */
write: boolean;
/** Replaces existing data (screenshots, a whole form) instead of only adding. */
destructive?: boolean;
idempotent?: boolean;
/** Talks to a store API or the internet. */
network: boolean;
props?: Record<string, JsonSchema>;
required?: string[];
/** Input -> extra CLI options (dry_run is handled for every write tool). */
args?: (i: Record<string, unknown>) => string[];
}
const only: JsonSchema = { type: 'string', description: 'Comma-separated ids / language codes to limit the run to (optional)' };
const lang: JsonSchema = { type: 'string', description: 'Comma-separated language ids from the config (default: all)' };
const variant: JsonSchema = { type: 'string', pattern: '^[a-z0-9][a-z0-9-]*$', description: 'A/B variant id from shots.variants (default: the base renders)' };
const source: JsonSchema = { type: 'string', enum: ['web', 'ios-sim', 'android-emu', 'folder'], description: 'Default: from the config' };
const opt = (flag: string, v: unknown): string[] => (v === undefined || v === null || v === '' ? [] : [`--${flag}`, String(v)]);
const flag = (name: string, v: unknown): string[] => (v === true ? [`--${name}`] : []);
export const TOOLS: ToolDef[] = [
{ name: 'check', title: 'Offline config check', command: ['check'], write: false, network: false,
description: 'Validate storebound.config.ts, both listing files, screenshot copy, Data safety answers, product texts and referenced files. Offline.' },
{ name: 'check_aso', title: 'Keyword audit', command: ['check'], write: false, network: false,
description: 'Offline ASO audit of the listing files: App Store keyword field rules (100 chars, no spaces, no name/subtitle repeats, >= 90% used) and Play keyword stuffing.',
props: { storefront: { type: 'string', description: 'App Store storefront for the cross-locale hint', default: 'US' } },
args: i => ['--aso', ...opt('storefront', i.storefront)] },
{ name: 'validate', title: 'Store readiness report', command: ['validate'], write: false, network: true,
description: 'Read-only readiness report for App Store Connect and/or Google Play with ordered blockers (build, encryption, metadata, screenshots, review details, age rating, prices, IAPs, privacy URL, app-ads.txt, tracks, products).',
props: { store: { type: 'string', enum: ['both', 'apple', 'play'], default: 'both' } },
args: i => (i.store === 'apple' ? ['--apple'] : i.store === 'play' ? ['--play'] : []) },
{ name: 'apple_status', title: 'App Store status', command: ['apple', 'status'], write: false, network: true,
description: 'Read-only App Store Connect overview: versions and their states, recent builds, in-app purchases, review submissions.' },
{ name: 'apple_next_build', title: 'Next iOS build number', command: ['apple', 'next-build'], write: false, network: true,
description: 'Next safe CFBundleVersion: one above every build uploaded for the app.' },
{ name: 'play_status', title: 'Google Play status', command: ['play', 'status'], write: false, network: true,
description: 'Read-only Play overview: tracks and releases (with rollout fraction), listing languages, one-time products.' },
{ name: 'play_next_version_code', title: 'Next Play versionCode', command: ['play', 'next-version-code'], write: false, network: true,
description: 'Next Play versionCode: one above every uploaded bundle and track release.' },
{ name: 'shots_check', title: 'Check store renders', command: ['shots', 'check'], write: false, network: false,
description: 'Local store checks of the renders folder: pixel sizes per store type, alpha, Play JPEG / 24-bit PNG and 8 MB, counts per set, text overflow flags, app preview videos (H.264, 30 fps, 15-30 s, stereo AAC) and folder frames. Read-only.',
props: { lang, variants: { type: 'boolean', default: false, description: 'Also check the A/B variant folders' } },
args: i => [...opt('lang', i.lang), ...flag('variants', i.variants)] },
{ name: 'privacy_manifest', title: 'iOS privacy manifest scan', command: ['privacy-manifest'], write: false, network: false,
description: 'Local scan of an iOS project: PrivacyInfo.xcprivacy present, required-reason APIs declared, SDKs without manifests.',
props: { ios: { type: 'string', description: 'Path of the iOS project folder, e.g. ios/App' }, sdk_dirs: { type: 'string', description: 'Extra plugin / SDK folders, comma-separated' } },
required: ['ios'], args: i => [...opt('ios', i.ios), ...opt('sdk-dirs', i.sdk_dirs)] },
{ name: 'whats_new', title: 'Draft release notes', command: ['whats-new'], write: true, network: false, idempotent: true,
description: 'Draft player-facing release notes from the git log since a tag; with dry_run false writes the draft into the listing files (local text only, nothing is sent to a store).',
props: { since: { type: 'string', description: 'Git tag or ref (default: latest tag)' }, lang: { type: 'string' }, all_languages: { type: 'boolean', default: false } },
args: i => [...opt('since', i.since), ...opt('lang', i.lang), ...flag('all', i.all_languages)] },
{ name: 'play_listing', title: 'Push Play listing text', command: ['play', 'listing'], write: true, network: true, idempotent: true,
description: 'Google Play app details + title / short / full description per language from the listing file. Not public until the next review / publish.',
props: { only }, args: i => opt('only', i.only) },
{ name: 'play_images', title: 'Upload Play graphics', command: ['play', 'images'], write: true, destructive: true, network: true, idempotent: true,
description: 'Replace icon, feature graphic and screenshots per Play language from the renders folder (or an A/B variant folder). Slow (minutes): prefer the terminal with a log for many languages.',
props: { only, variant }, args: i => [...opt('only', i.only), ...opt('variant', i.variant)] },
{ name: 'play_products', title: 'Sync Play one-time products', command: ['play', 'products'], write: true, network: true, idempotent: true,
description: 'Create / update one-time products with regional prices and activate their purchase option.',
props: { only }, args: i => opt('only', i.only) },
{ name: 'play_data_safety', title: 'Push Play Data safety', command: ['play', 'data-safety'], write: true, destructive: true, network: true, idempotent: true,
description: 'Replace the whole Play Data safety form with the answers from the config (CSV import). dry_run prints the CSV.' },
{ name: 'play_release_testing', title: 'Release to a Play testing track', command: ['play', 'release'], write: true, network: true,
description: 'Upload an AAB (or reuse a versionCode) to a TESTING track (internal, alpha, beta) with release notes. Production is not available here.',
props: { aab: { type: 'string', description: 'Path to the .aab' }, version_code: { type: 'integer', minimum: 1 },
track: { type: 'string', enum: ['internal', 'alpha', 'beta'], default: 'internal' }, status: { type: 'string', enum: ['completed', 'draft'], default: 'completed' } },
args: i => [...(i.aab ? [String(i.aab)] : []), ...opt('version-code', i.version_code), `--${String(i.track ?? 'internal')}`, String(i.status ?? 'completed')] },
{ name: 'apple_bundle', title: 'Register bundle id', command: ['apple', 'bundle'], write: true, network: true, idempotent: true,
description: 'Register the bundle id if missing and look up the App Store Connect app record.' },
{ name: 'apple_iap', title: 'Sync App Store IAPs', command: ['apple', 'iap'], write: true, network: true, idempotent: true,
description: 'Create missing in-app purchases, localizations, price schedules and availability. Never submits.',
props: { only }, args: i => opt('only', i.only) },
{ name: 'apple_iap_review', title: 'IAP review screenshots', command: ['apple', 'iap-review'], write: true, destructive: true, network: true, idempotent: true,
description: 'Upload (replace when changed) the App Review screenshot of every in-app purchase. Never submits.' },
{ name: 'apple_listing', title: 'Push App Store version + text', command: ['apple', 'listing'], write: true, network: true, idempotent: true,
description: 'Create / update the editable version (manual release), attach a build by explicit number, and push name / subtitle / description / keywords / promo / what\'s new per locale.',
props: { version: { type: 'string', pattern: '^\\d+(\\.\\d+){0,2}$' }, build: { type: 'string', description: 'Exact build number to attach (use the number you just uploaded, never "latest")' }, only },
required: ['version'], args: i => [...opt('version', i.version), ...opt('build', i.build), ...opt('only', i.only)] },
{ name: 'apple_screenshots', title: 'Upload App Store screenshots', command: ['apple', 'screenshots'], write: true, destructive: true, network: true, idempotent: true,
description: 'Sync 6.9" and 6.5" (+ 13" iPad with apple.ipad) screenshots per locale from the renders folder (or an A/B variant folder; MD5-idempotent; changed sets are replaced). Slow: prefer the terminal with a log.',
props: { only, variant }, args: i => [...opt('only', i.only), ...opt('variant', i.variant)] },
{ name: 'apple_appinfo', title: 'App Store app info', command: ['apple', 'appinfo'], write: true, network: true, idempotent: true,
description: 'Categories, age rating declaration, content rights, Free price and availability (when missing).' },
{ name: 'apple_review_details', title: 'App Review information', command: ['apple', 'review-details'], write: true, network: true, idempotent: true,
description: 'App Review contact (from .storebound/credentials.json) and review notes from the config.' },
{ name: 'apple_encryption', title: 'Export compliance answer', command: ['apple', 'encryption'], write: true, network: true, idempotent: true,
description: 'Answer export compliance for builds from apple.usesNonExemptEncryption in the config (never guesses).',
props: { build: { type: 'string', description: 'Build number (default: every build without an answer)' } }, args: i => opt('build', i.build) },
{ name: 'apple_phased_release', title: 'Phased release on / pause', command: ['apple', 'release'], write: true, network: true, idempotent: true,
description: 'Turn on the 7-day phased release for the upcoming version, or pause an active one (pausing is not a rollback). Resume / complete / release are owner-only terminal commands.',
props: { action: { type: 'string', enum: ['on', 'pause'] }, version: { type: 'string' } }, required: ['action'],
args: i => ['--phased', String(i.action), ...opt('version', i.version)] },
{ name: 'shots_capture', title: 'Capture raw frames', command: ['shots', 'capture'], write: true, network: false, idempotent: true,
description: 'Raw game frames per language into shots.frames from a web build (Playwright), the iOS Simulator (simctl), an Android emulator / device (adb) or a folder check. Local files only; a simulator it boots is shut down again, an emulator is never booted. dry_run lists the plan and the simctl / adb commands.',
props: { lang, only: { type: 'string', description: 'Comma-separated shot names' }, device: { type: 'string', enum: ['phone', 'tablet'] }, source },
args: i => [...opt('lang', i.lang), ...opt('only', i.only), ...opt('device', i.device), ...opt('source', i.source)] },
{ name: 'shots_render', title: 'Render store screenshots', command: ['shots', 'render'], write: true, network: false, idempotent: true,
description: 'Store screenshots + Play feature graphic in every size and language from the frames and the copy file (local PNGs, needs Playwright + ffmpeg; slow for many languages). dry_run lists what would be rendered.',
props: { lang, size: { type: 'string', description: 'Comma-separated size keys: ios69, ios65, ipad13, play, tab7, tab10, feature' },
scenes: { type: 'string', description: 'Comma-separated scene ids' }, variant, all_variants: { type: 'boolean', default: false, description: 'Base + every variant' } },
args: i => [...opt('lang', i.lang), ...opt('size', i.size), ...opt('scenes', i.scenes), ...(i.all_variants === true ? ['--variants'] : opt('variant', i.variant))] },
{ name: 'shots_gallery', title: 'Review gallery', command: ['shots', 'gallery'], write: true, network: false, idempotent: true,
description: 'Write <renders>/index.html: one self-contained page with every language, size, scene, variant and app preview, store check issues highlighted. Open it in a browser to review before uploading.',
props: { lang }, args: i => opt('lang', i.lang) },
{ name: 'shots_record', title: 'Record gameplay clips', command: ['shots', 'record'], write: true, network: false, idempotent: true,
description: 'Gameplay clips for app previews from shots.video.record: web build (Chromium screencast), iOS Simulator (simctl recordVideo), Android emulator / device (screenrecord, never booted) or a folder listing. Local files only.',
props: { lang, only: { type: 'string', description: 'Comma-separated clip names' }, source },
args: i => [...opt('lang', i.lang), ...opt('only', i.only), ...opt('source', i.source)] },
{ name: 'shots_video', title: 'Cut app previews', command: ['shots', 'video'], write: true, network: false, idempotent: true,
description: 'App Store app previews (886x1920 iPhone, 1200x1600 iPad) and a YouTube promo video (Play) from the clips: captions from the screenshot copy, silent or music track, poster frame, store checks. Local files only; nothing is uploaded.',
props: { lang, target: { type: 'string', description: 'Comma-separated: iphone, ipad, youtube, youtube-landscape' },
seconds: { type: 'integer', minimum: 15, maximum: 30 }, captions: { type: 'boolean', default: true } },
args: i => [...opt('lang', i.lang), ...opt('target', i.target), ...opt('seconds', i.seconds), ...(i.captions === false ? ['--no-captions'] : [])] },
{ name: 'apple_previews', title: 'Upload App Store app previews', command: ['apple', 'previews'], write: true, destructive: true, network: true, idempotent: true,
description: 'Sync app preview videos per locale to the editable App Store version (checked locally first; MD5-idempotent, changed sets are replaced; poster frame time code). Not public until the version is submitted and released. Slow: prefer the terminal with a log.',
props: { only, poster: { type: 'integer', minimum: 0, maximum: 29, description: 'Poster frame second (default shots.video.poster or 5)' } },
args: i => [...opt('only', i.only), ...opt('poster', i.poster)] },
{ name: 'apple_testflight_status', title: 'TestFlight status', command: ['apple', 'testflight', 'status'], write: false, network: true,
description: 'Read-only TestFlight overview: beta groups (internal / external, tester and build counts, public link), recent builds with processing, internal and external beta states.' },
{ name: 'apple_testflight_groups', title: 'Create TestFlight groups', command: ['apple', 'testflight', 'groups'], write: true, network: true, idempotent: true,
description: 'Create the beta groups of apple.testflight.groups that are missing on App Store Connect (matched by name; existing groups are never changed or deleted). Sends nothing to testers.' },
{ name: 'apple_testflight_what_to_test', title: 'TestFlight What to Test', command: ['apple', 'testflight', 'what-to-test'], write: true, network: true, idempotent: true,
description: 'Set "What to Test" (betaBuildLocalizations) of one build, by its exact number, per locale from the App Store listing file (### whatToTest, else ### whatsNew) or from text.',
props: { build: { type: 'string', pattern: '^[0-9][0-9.]*$', description: 'Exact build number (CFBundleVersion) you uploaded' }, version: { type: 'string', pattern: '^\\d+(\\.\\d+){0,2}$', description: 'Marketing version when the build number repeats' },
locale: { type: 'string', description: 'Comma-separated App Store locales (default: every locale with text)' }, text: { type: 'string', description: 'Same text for the given locales instead of the listing file' } },
required: ['build'], args: i => [...opt('build', i.build), ...opt('version', i.version), ...opt('locale', i.locale), ...opt('text', i.text)] },
{ name: 'apple_testflight_info', title: 'TestFlight test information', command: ['apple', 'testflight', 'info'], write: true, network: true, idempotent: true,
description: 'Beta App Description per locale (apple.testflight.description), feedback email, privacy and marketing URLs, and the Beta App Review contact (.storebound/credentials.json) and notes. Needed before external testing.' },
{ name: 'apple_testflight_distribute', title: 'Build to internal TestFlight groups', command: ['apple', 'testflight', 'distribute'], write: true, network: true, idempotent: true,
description: 'Add one build (exact number) to INTERNAL beta groups (your App Store Connect team; they get the TestFlight notification). External groups and Beta App Review submissions are owner-only terminal commands.',
props: { build: { type: 'string', pattern: '^[0-9][0-9.]*$', description: 'Exact build number you uploaded' }, groups: { type: 'string', description: 'Comma-separated internal group names' },
version: { type: 'string', pattern: '^\\d+(\\.\\d+){0,2}$' } },
required: ['build', 'groups'], args: i => [...opt('build', i.build), ...opt('group', i.groups), ...opt('version', i.version), '--internal-only'] },
{ name: 'icons', title: 'Generate icons', command: ['icons'], write: true, network: false, idempotent: true,
description: 'Write every store / launcher / web icon from the artwork in the config (local files, needs ffmpeg).' },
];
/** CLI flags / commands that must never be reachable through MCP. Tests assert none of the tools can produce them. */
export const FORBIDDEN_ARGS = ['--yes', '--manual-release', '--cancel-submission', '--production', 'rollout', 'resume', 'complete',
'--submit-review', '--remove', '--invite', 'testers'];
export function inputSchema(t: ToolDef): Record<string, unknown> {
const props: Record<string, JsonSchema> = { ...(t.props ?? {}) };
if (t.write) props.dry_run = { type: 'boolean', default: true, description: 'Default true: only show what would change. Set false only after the owner agreed.' };
return { type: 'object', properties: props, ...(t.required?.length ? { required: t.required } : {}), additionalProperties: false };
}
export const OUTPUT_SCHEMA = {
type: 'object',
properties: { exitCode: { type: 'integer' }, dryRun: { type: 'boolean' }, command: { type: 'string' }, output: { type: 'string' } },
required: ['exitCode', 'command', 'output'],
} as const;
export function listTools(): Record<string, unknown>[] {
return TOOLS.map(t => ({
name: t.name, title: t.title, description: t.description,
inputSchema: inputSchema(t), outputSchema: OUTPUT_SCHEMA,
annotations: { title: t.title, readOnlyHint: !t.write, destructiveHint: t.write ? !!t.destructive : false, idempotentHint: !!t.idempotent || !t.write, openWorldHint: t.network },
}));
}
/** Checks an input against the tool schema; returns problems (empty = fine). */
export function validateInput(t: ToolDef, input: unknown): string[] {
const e: string[] = [];
if (input === undefined || input === null) input = {};
if (typeof input !== 'object' || Array.isArray(input)) return ['arguments must be an object'];
const s = inputSchema(t) as { properties: Record<string, JsonSchema>; required?: string[] };
const i = input as Record<string, unknown>;
for (const r of s.required ?? []) if (i[r] === undefined) e.push(`${r}: required`);
for (const [k, v] of Object.entries(i)) {
const p = s.properties[k];
if (!p) { e.push(`${k}: unknown argument`); continue; }
const ok = p.type === 'integer' ? Number.isInteger(v) : p.type === 'boolean' ? typeof v === 'boolean' : p.type === 'string' ? typeof v === 'string' : true;
if (!ok) { e.push(`${k}: must be ${p.type}`); continue; }
if (p.enum && !p.enum.includes(v as string)) e.push(`${k}: one of ${p.enum.join(', ')}`);
if (p.pattern && typeof v === 'string' && !new RegExp(p.pattern).test(v)) e.push(`${k}: does not match ${p.pattern}`);
if (p.minimum !== undefined && typeof v === 'number' && v < p.minimum) e.push(`${k}: >= ${p.minimum}`);
if (p.maximum !== undefined && typeof v === 'number' && v > p.maximum) e.push(`${k}: <= ${p.maximum}`);
if (typeof v === 'string' && /^-/.test(v)) e.push(`${k}: must not start with "-"`);
}
return e;
}
/** argv after `storebound` for a validated call. Write tools get --dry unless dry_run is explicitly false. */
export function toArgv(t: ToolDef, input: Record<string, unknown> = {}): { argv: string[]; dryRun: boolean } {
const dryRun = t.write ? input.dry_run !== false : false;
const argv = [...t.command, ...(t.args?.(input) ?? []), ...(dryRun ? ['--dry'] : [])];
return { argv, dryRun };
}