phonebook
The Phonebook MCP server lets a coding agent set up, audit, render, and publish a static preview gallery from an Android or iOS project's existing Compose @Preview / SwiftUI #Preview code.
check_setup — diagnose whether a project is correctly wired for
phonebook generate(libraries, snapshot test target, JDK/Xcode/simulator), same checks asphonebook doctor.analyze_coverage — read-only scan of UI components vs. their previews, reporting gaps: states implied by parameters, unsupplied environment objects, dark theme, large text, and localization. Can scope reporting to
pathsorchanged(git-modified files), though the whole project is always scanned; it reports gaps but never writes previews.get_preview_guidance — return the preview naming convention plus a ready-to-paste preview code template for a component, given a
platform(android/ios) and optional component name and state list.run_generate — run the platform engine (Roborazzi on the JVM for Android, SnapshotPreviews on a simulator for iOS) to render previews into a bundle (manifest + images); supports
changed/filesfor a faster partial loop and reports which previews crashed, by file and line.run_build — turn a generated bundle into the static HTML gallery site, optionally writing to a separate output directory instead of into the bundle itself.
Analyzes Android projects that use Compose @Preview, checks setup compatibility, assesses preview coverage, and generates a static HTML gallery of component screenshots from the existing previews.
Runs on iOS projects with SwiftUI #Preview, checks setup, identifies missing previews, and generates a static HTML gallery of component screenshots from the existing previews.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@phonebook Run doctor and generate the gallery for this repo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Phonebook turns screenshots your team already has into a Storybook-style component gallery. No new test code, no design tokens to maintain by hand — it renders what's already in your codebase into a static site designers can open without installing anything. Each repo runs Phonebook independently; v1 is single-platform, so one Android repo (or one iOS repo) produces one bundle and one site.
Features
Zero new test code — reuses
@Preview/#Previewyou've already writtenNo SaaS account — self-hosted, runs entirely in your CI or locally
MCP-first — a coding agent can check setup, analyze coverage, add missing previews, and build the gallery for you
Smart component grouping —
component / statecards inferred from preview names, no required annotationCross-platform — Android (Roborazzi + ComposablePreviewScanner, runs on the JVM, no emulator) and iOS (SnapshotPreviews, runs on a simulator)
Version-aware setup —
init/doctorresolve library versions against your project's Kotlin version and catch Kotlin/Roborazzi metadata mismatches before they cause opaque compiler crashes
Related MCP server: ios-agent
Demo


A gallery generated from samples/ios — component / state cards grouped from the app's own #Previews, no extra annotation.
How it works
phonebook generateruns your platform's preview-rendering engine and harvests the output into a bundle (manifest.json+images/).Android: Roborazzi + ComposablePreviewScanner, run on the JVM via Robolectric. No emulator, works on Linux CI.
iOS: SnapshotPreviews, run via
xcodebuild teston a simulator. Requires macOS.
phonebook buildturns that bundle into a static site — by default it writesindex.htmldirectly into the bundle directory (reusing the images already there, no copying), so the site lands at<bundle>/index.html. Pass-o <dir>to instead copy everything into a standalone site directory (for publishing elsewhere, or later merging multiple bundles). Plain HTML/CSS/JS, works fromfile://or any static host.
Installation
npm install -g @stag-build/phonebookbrew install stag-build/phonebook/phonebookOr tap first, then install:
brew tap stag-build/phonebook
brew install phonebookFormula source: stag-build/homebrew-phonebook.
npx @stag-build/phonebook <cmd>Using it with a coding agent (recommended)
Most people won't run the CLI directly — Phonebook is built to be driven by a coding agent (Claude Code, Codex, etc.) through its MCP server. The agent adds previews, runs setup checks, and generates the gallery for you; the CLI underneath is the engine it calls.
The server runs via npx @stag-build/phonebook mcp — no install step needed. Pick your client below.
claude mcp add phonebook -- npx -y @stag-build/phonebook mcpAdd to ~/.codex/config.toml:
[mcp_servers.phonebook]
command = "npx"
args = ["-y", "@stag-build/phonebook", "mcp"]Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"phonebook": {
"command": "npx",
"args": ["-y", "@stag-build/phonebook", "mcp"]
}
}
}Add to .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
{
"mcpServers": {
"phonebook": {
"command": "npx",
"args": ["-y", "@stag-build/phonebook", "mcp"]
}
}
}Add to .codex/config.toml at your project's workspace root. Xcode's agent runs with a minimal PATH, so the command wraps npx in a shell that adds the usual Homebrew/nvm locations first:
[mcp_servers.phonebook]
command = "/bin/zsh"
args = [
"-lc",
"PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin; npx -y @stag-build/phonebook mcp"
]
enabled = trueAdd the mcpServers block to ~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig/.claude.json:
{
"mcpServers": {
"phonebook": {
"command": "/bin/zsh",
"args": [
"-lc",
"PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin; npx -y @stag-build/phonebook mcp"
]
}
}
}Android Studio (Gemini Agent Mode): not supported yet — its MCP integration only connects to remote httpUrl servers, not local stdio processes like Phonebook's. Use one of the terminal-based clients above (Claude Code, Codex CLI) from the Android repo instead.
Then, from a chat in your Android or iOS repo, just ask:
"Use the phonebook MCP and create a catalog for my designer."
The agent figures out the rest — checking setup, filling in missing previews, generating, and building the site. For more targeted asks, it also exposes: check_setup (setup diagnosis, same as phonebook doctor), analyze_coverage (components missing previews or dark variants), get_preview_guidance, run_generate, and run_build.
Quickstart: Android
Run phonebook init first — it detects your project's Kotlin version and prints these instructions with library versions resolved to be compatible with it (e.g. Kotlin 2.0 projects get Roborazzi 1.60.0; Kotlin 2.2+ gets the latest). The versions below are what a current-Kotlin project gets (see samples/android/app/build.gradle.kts for a full working example):
// app/build.gradle.kts
plugins {
id("io.github.takahirom.roborazzi") // root build.gradle.kts: version "1.72.0" apply false
}
roborazzi {
generateComposePreviewRobolectricTests {
enable = true
packages = listOf("dev.stag.phonebook.sample") // your app's package
}
}
dependencies {
testImplementation("org.robolectric:robolectric:4.14.1")
testImplementation("io.github.takahirom.roborazzi:roborazzi:1.72.0")
testImplementation("io.github.takahirom.roborazzi:roborazzi-compose:1.72.0")
testImplementation("io.github.sergio-sastre.ComposablePreviewScanner:android:0.9.3")
testImplementation("io.github.takahirom.roborazzi:roborazzi-compose-preview-scanner-support:1.72.0")
testImplementation("androidx.compose.ui:ui-test-junit4") // version from your Compose BOM, or pin one
}Add a phonebook.config.json next to settings.gradle.kts:
{
"appName": "My Android App",
"platform": "android",
"android": { "modules": [":app"], "variant": "debug" }
}Then, from the repo containing Phonebook:
npx @stag-build/phonebook generate -C /path/to/your/android/repo
npx @stag-build/phonebook build -C /path/to/your/android/repoOpen phonebook-out/index.html.
generate --changed (or --files A.kt,B.kt) renders only the previews declared in those files, with no extra
setup. For that run only, Phonebook passes Gradle an init script that swaps in a preview tester which keeps the
requested previews and scans only their packages. Both files are written under build/phonebook/, never into
your sources. If your project configures its own testerQualifiedClassName, yours wins and the run renders
every preview in the module.
Quickstart: iOS
Add the SnapshotPreviews SPM package to your project and a small XCTest target that subclasses SnapshotTest (see samples/ios for a full working example):
// PhonebookSnapshotTests.swift
import Foundation
import SnapshottingTests
final class PhonebookSnapshotTests: SnapshotTest {
override class func snapshotPreviews() -> [String]? {
guard let raw = ProcessInfo.processInfo.environment["SNAPSHOTS_ONLY_FILTER"], !raw.isEmpty else {
return nil // record every #Preview
}
return raw.components(separatedBy: "\n")
}
}Reading SNAPSHOTS_ONLY_FILTER is what lets phonebook generate --changed (or --files A.swift,B.swift)
render only the previews in the files you just edited; with the variable unset, every #Preview is recorded
as before.
Add phonebook.config.json next to your .xcodeproj:
{
"appName": "My iOS App",
"platform": "ios",
"ios": {
"project": "MyApp.xcodeproj",
"scheme": "MyApp",
"simulator": "iPhone 17 Pro"
}
}Your scheme must build and test the snapshot test target (see PhonebookSample.xcscheme in the sample). Then:
npx @stag-build/phonebook generate -C /path/to/your/ios/repo
npx @stag-build/phonebook build -C /path/to/your/ios/repoOpen phonebook-out/index.html.
Naming convention
Phonebook groups screenshots into component / state cards from your existing preview names — no required annotation. See docs/naming-convention.md for the full rules and examples.
Configuration
phonebook.config.json:
Key | Type | Default | Notes |
| string | — | Required. Shown in the gallery header. |
|
| — | Required. |
| string |
| Bundle output directory, relative to the config file. |
| string[] |
| Gradle modules to record. |
| string |
| Build variant; Phonebook runs |
| string | — | Path to |
| string | — | Path to |
| string | — | Required. Scheme that includes the SnapshotPreviews test target. |
| string |
| Simulator device name used for |
| string | auto-detected |
|
Android previews render like Android Studio: a @Preview without its own size wraps its content, and full-screen (fillMaxSize) content fills the Robolectric screen, which Roborazzi defaults to a Pixel 4a. Setting robolectricConfig in the generateComposePreviewRobolectricTests block replaces that default, so include "qualifiers" to "RobolectricDeviceQualifiers.Pixel4a" (or "\"w411dp-h891dp-port\"" for Android Studio's phone). Otherwise full-screen previews render on a 320×470dp screen. phonebook doctor points this out.
Both generate and build accept -C <dir> (project directory containing phonebook.config.json). generate takes -o <dir> to override the bundle output and --allow-empty to tolerate a run that records no previews. build takes an optional bundle path — with none, it uses the project's bundle directory — and -o <dir> for the site output; without -o, build writes index.html straight into the bundle directory and reuses its images/ in place (no copying), which is what the quickstarts above do. Pass -o <dir> to instead copy the bundle's images into a separate, standalone site directory.
phonebook init and phonebook doctor
phonebook init detects your platform and scaffolds phonebook.config.json plus the dependency/setup snippets — with library versions resolved against your project's Kotlin version and your app package filled in. It never edits your build files for you.
For iOS, check installed devices with xcrun simctl list devices available, then run phonebook init --simulator "<device name>" to record the simulator you chose. The same command updates only ios.simulator when phonebook.config.json already exists, so it also works when setup is retried. --simulator is not used for Android.
phonebook doctor checks that everything generate needs is wired up: plugin and test dependencies (resolved through Gradle version catalogs when you use them), the scanner's packages value, Kotlin/Roborazzi compatibility, and the toolchain (JDK/Xcode/simulator). Add --deep to also compile the test sources — slower, but authoritative when a static check and reality disagree. On iOS, if SnapshotPreviews is linked but no SnapshotTest subclass exists yet, doctor names the exact target and folder to add it to (parsed from the .pbxproj), so you're never just told to "add the class" with no location.
phonebook init --write-snapshot-class is the one exception to init's hands-off rule: when doctor's iOS check identifies the linking target and that target's source folder is one of Xcode's filesystem-synchronized groups, it writes <folder>/PhonebookSnapshots.swift directly — safe because a synchronized folder is picked up by Xcode automatically, so no project.pbxproj edit is made. It refuses (with the reason) in every other case: no SnapshotPreviews wiring yet, a non-synchronized-group project, or a subclass that already exists.
phonebook mcp runs the MCP server — see "Using it with a coding agent" above for setup and example prompts.
Requirements
Android: JDK 17+. No emulator needed — Roborazzi renders on the JVM via Robolectric, so generate runs on Linux CI.
iOS: macOS with Xcode installed, plus a booted or bootable simulator (generate runs xcodebuild test against a named simulator destination). Requires a macOS runner in CI.
See docs/ci.md for CI recipes and docs/naming-convention.md for the naming rules.
Roadmap
Post-v1 (M5), not yet built:
Search and filters in the generated gallery
Multi-bundle merge with a side-by-side view (cross-platform sites)
Version diffing between two runs (the manifest already carries commit + image hashes to enable this)
Additional CI recipe docs
License
MIT — see LICENSE.
Available Tools
5 toolsanalyze_coverageA
Scan the codebase for UI components and the previews that cover them, and report what each component is missing: states implied by its parameters, environment objects no preview supplies, dark theme, large text, and localization when the project ships one. Read-only — it reports the gaps, it does not write previews. After editing, pass changed: true (or paths) to hear only about what you touched; the whole project is always scanned either way, so the answers stay correct.
Inputs: dir, paths, changed.
check_setupA
Check that the project is correctly set up for phonebook generate (same checks as phonebook doctor): libraries wired, test target present, JDK/Xcode/simulator available.
Inputs: dir.
get_preview_guidanceA
Return the preview naming convention plus a ready-to-paste preview code template for a component, so any agent writes consistent previews.
Inputs: platform (required), states, component.
run_buildA
Build the static gallery site from a bundle, same as phonebook build <bundle>.
Inputs: bundle (required), output.
run_generateA
Run the platform engine to render all previews and produce a bundle (manifest + images), same as phonebook generate. When previews crash, keeps what rendered and says which previews did not, by file and line. Pass changed or files to render only the previews declared in those files, for a faster loop while iterating.
Inputs: dir, files, changed.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool addresses a distinct step in the preview workflow: guidance, setup, coverage analysis, generation, and building. The only adjacent pair (run_generate and run_build) is clearly separated by bundle output versus static-site output.
Most names are imperative snake_case with a clear object (get_preview_guidance, analyze_coverage, check_setup). run_build and run_generate are a minor deviation because they use a run_ prefix around CLI command names rather than a pure verb_noun structure.
Five tools is well-scoped for a focused preview-generation workflow. Each tool earns its place by covering a separate phase from setup to final build, with no redundant or padding tools.
The tool set covers the full core loop: check setup, get authoring guidance, analyze coverage gaps, generate previews, and build the gallery site. The absence of a write-preview tool is fine because editing code happens outside the server, and the guidance plus coverage tools support that workflow.
Maintenance
Related MCP Connectors
Serves your design system and coding standards to coding agents, so they stop guessing.
A design agent in your coding agent's loop: briefs each screen, reviews UX and visual quality.
Design your mobile app UI with AI, then have your coding agent build the real app from it.
Make narrated, on-brand product videos of your real app from your coding agent or AI assistant.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables AI agents to render and screenshot isolated UI components instantly across multiple browsers without a dev server or Storybook.22660 npm1MIT
- AlicenseAqualityBmaintenanceEnables AI coding agents to review Swift code, scaffold new iOS apps, and build, test, and preview them in the Xcode Simulator using local Apple guides and source references.3642MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI coding assistants to inspect frontend projects, search a curated design and motion recipe catalog, prepare and preview structured design plans, apply changes with backups and rollback, capture previews, audit UI accessibility and performance, and monitor activity via a web dashboard.-
- FlicenseNot gradedqualityAmaintenanceEnables coding agents to ground UI work in real product screens by finding concrete references, materials, and design-system details through a catalogue. It also provides bundled workflow resources, command prompts, and local diagnostics so agents can build and verify interfaces.-