# MCP tools reference

> Every Specimo MCP tool and prompt, authentication with OAuth or tokens, and the typical agent loop.

Registry listing: [`mcp/server.json`](../mcp/server.json) (official MCP Registry format); launch and directory steps in
[docs/launch/launch-kit.md](launch/launch-kit.md).

Endpoint: `POST {API_PUBLIC_URL}/mcp` (Streamable HTTP, stateless, JSON responses).
Auth: `Authorization: Bearer adp_…`, project-scoped. Two ways to get one:

- **OAuth (recommended).** MCP clients that support the MCP authorization spec discover everything from the 401:
  `WWW-Authenticate: … resource_metadata="<API>/.well-known/oauth-protected-resource"` → AS metadata at
  `<API>/.well-known/oauth-authorization-server` → dynamic registration (`POST /oauth/register`, public client, https or
  loopback redirect URIs) → browser to `/oauth/authorize` (user signs in, picks the project and read / read-write) →
  `POST /oauth/token` with PKCE S256. Access tokens last 1 h; refresh tokens 30 days and rotate (reuse revokes the chain).
  `POST /oauth/revoke` (RFC 7009). Signed-in apps appear on the Connect page and can be revoked there.
- Organizations on Business can restrict agents (Org settings → Agent policy): disallow manual tokens or signed-in apps, force read-only, cap manual-token lifetime. Policy applies on every request.
- **Service account token** (Org → Service accounts, Pro): for CI and shared agents; explicit project grant, always expires, attributed to the service account and unaffected when people leave.
- **Manual token** created in **Project → Connect agent** (CI, scripts, clients without OAuth). Doesn't expire until revoked.

Tokens may alias other tokens with W3C DTCG syntax: `upsert_tokens` with `value: "{color.violet.500}"`. Use semantic
tokens in screens; `save_screen` analysis lists `primitiveTokens` used directly.

Modes: `set_token_modes { collections: [{ name: "theme", modes: ["light", "dark"] }] }`, then per-token values via
`upsert_tokens` `modes: { "theme:dark": "#0b0b10" }`.

Business states: mark markup with `data-state="default|loading|empty|error|success"`; `save_screen` analysis returns
`businessStates { present, missing[{state, why}] }`.

Implementing in an app: `export_tokens { format: "css" | "scss" | "tailwind" | "json" | "swift" | "compose" | "android" }`
returns ready-to-commit code.

Importing an existing app: run the `import_from_codebase` prompt in its repository. Pass `source` (file path) on
`upsert_tokens` / `upsert_component`; those items wait for human review in Design system → Imported.

## Read tools (any token)

| Tool | Purpose |
| --- | --- |
| `get_project_context` | **Start here.** Markdown: brand guidelines, all tokens as CSS vars, components and variants, screens with status, assets, authoring rules. Items from subscribed organization libraries are marked `(library <name> <version>)` and are read-only. |
| `get_design_system` | Full JSON: tokens, generated tokens CSS, components with variant HTML/CSS, assets with URLs. |
| `get_component` | One component with all variants, a usage snippet and its usage docs (guidelines, do/don't examples, accessibility notes, related components). |
| `get_component` | One component with all variants, a usage snippet and its approved code mappings per platform (`code.web` / `code.ios` / `code.android`). |
| `get_code_mappings` | Approved code mappings, open proposals and per-platform coverage (which components lack a mapping). Optional `platform`. |
| `list_screens` | Screens with `draft` / `approved` / `changes_pending` status. |
| `get_screen` | Source and analysis of a version (`latest`, `approved` or a number). |
| `get_approved_screen` | Approved version ready to implement: source, composed standalone HTML, tokens/components used (each with its code mappings), guidance. |
| `get_accessibility_report` | Latest axe-core (WCAG 2.2 AA) audit of a screen version per viewport, with affected elements and fixes. |
| `list_comments` | Review comments pinned to elements (anchor path/label/text, version, discussion). Open by default. |
| `list_change_requests` | Visual change requests (elements picked in Inspect + notes, component/token context, ready prompt). Filter by status/screen. |
| `get_design_drift` | Design-system drift: score (0 = everything from tokens and components), drifting screens with what to fix, unused tokens/components, weekly trend, and a ready fix prompt. |
| `get_visual_qa` | Latest visual QA runs of a screen version (default approved): mismatch %, regions with the design element under each, fix prompt. |
| `list_locales` | String catalogs: default (source) locale, coverage per locale, keys screens use. |
| `propose_token_changes` | Propose token values as a change set that people preview live (`?changes=<id>`) and apply after review; returns the impact (alias tokens, screens, components). |
| `get_journeys` | Documented journeys and flow notes; `name` returns one journey as markdown (steps, labels, notes, goals, edge cases, analytics events). |
| `list_mock_data` | Mock data sets: variants with item counts, screens using them, data keys without a set; `key` returns one set's JSON. Preview with `?data=<variant>`. |
| `list_markets` | Market variants: profiles (country, currency, locale), legal copy blocks, the `data-legal` keys screens use and which each market is missing. Preview with `?market=<key>`. |
| `get_strings` | One locale's strings plus the used keys it is missing (with source text and screens); `missingOnly` for translating. |
| `check_focus_order` | Keyboard focus order: every Tab stop in order plus issues — positive tabindex, interactive-looking elements not reachable with Tab, invisible focusables, Tab jumping back up the page, focus traps (found by pressing Tab headlessly). |
| `check_layout_stress` | Render a screen headlessly with pseudo-locale text (+40 %), RTL and/or a catalog locale; returns truncated/clipped/overflowing elements (with string key and component), horizontal page scroll and physical left/right CSS. Also `textScale` (100–200 %, like iOS Dynamic Type / Android font scale) and `reducedMotion` (reports `animationsIgnoringReducedMotion`). |
| `get_deprecations` | Deprecated tokens/components with replacement and sunset, screens (latest/approved) still using each, and a migration prompt. |
| `search_icons` | Search the icon library by name/tag/category; returns names, tags, where used and a `<ds-icon>` snippet (optional SVG). |
| `get_flow` | Prototype flow: screens with routes, links between them, start screen, and links to screens that don't exist yet. |
| `list_assets` | Assets with `asset:<name>` refs and URLs. |
| `get_authoring_guide` | Rules for writing screens/components. |

## Write tools (read/write tokens)

| Tool | Purpose |
| --- | --- |
| `upsert_tokens` / `delete_tokens` | Manage design tokens in bulk. |
| `upsert_component` / `delete_component` | Manage components (each update is a new component version). |
| `update_component_docs` | Replace a component's usage docs: guidelines and accessibility notes (markdown), do/don't examples (variant + label, or an html snippet, with a note), related component keys. No new component version. |
| `propose_code_mapping` | Propose where a component lives in code on `web` / `ios` / `android`: path, import, props per variant. A person with the approve permission accepts it in Design system → Code; re-proposing replaces your open proposal. |
| `upsert_strings` | Merge `{ key: text }` into a locale (null removes; creates the locale; the first one becomes the default). Screens reference keys with `data-i18n` / `data-i18n-attr`. |
| `upsert_journey` | Create or replace a named journey: ordered `steps` `{ screen, label, note }`. |
| `add_flow_note` | Sticky note on a screen (or the whole flow): `kind` note / goal / edge_case / analytics / question. |
| `upsert_mock_data` | Create or merge a mock data set `{ key, variants: { typical, empty, long, many } }`; `derive: true` fills missing variants from `typical`. Bound with `data-repeat` / `data-empty` / `data-bind`. |
| `upsert_market` | Create or update a market profile by key (country ISO 3166, currency ISO 4217, BCP 47 locale). Legal copy is written by legal reviewers in the app, never by agents. |
| `deprecate_item` | Deprecate a token or component (`kind`, `name`, optional `replacement`, `sunset` YYYY-MM-DD, `note`) or `restore: true`. Deleting items approved screens still use is refused (409 `in_use_by_approved`); only admins can force it in the UI. |
| `upsert_icons` | Add/update up to 200 SVG icons (name, svg, category, tags, keepColors). Sanitized and optimised; colours become currentColor unless kept. |
| `import_storybook` | Connect a published Storybook (`url`, public https) and import it in the background — a component per story title, a variant per story (static snapshot, linked back), pending review; `sync: true` re-syncs changed stories, `status: true` reports progress. |
| `create_tracker_issue` | Create a Jira / Linear / Plane ticket (or one per platform) for a screen's approved version, with design link, tokens, components, states and acceptance criteria. Needs a tracker connected in Project settings. |
| `update_brandbook` | Replace brand guidelines markdown. |
| `save_screen` | Create a screen or add a new version (never overwrites). Optional `route` (e.g. `/pricing`) for prototype navigation; `resolves: [changeRequestIds]` marks requests done. Returns analysis + review URL. |
| `request_review` | Ask people (emails) or teams (names) to review a version; approval follows the project policy. |
| `compare_versions` | What changed between two versions of a screen (default: latest vs previous): plain-language summary, element changes (added / removed / changed), design-system deltas, optional unified code diffs. |
| `reply_to_comment` | Reply in a comment thread (agents can't resolve threads). |
| `resolve_change_request` | Mark a change request done (optionally linking a version) or dismissed with a reason. |
| `run_visual_qa` | Capture a deployed preview (public https URL, optional auth headers sent only to that origin and never stored) and compare it with a screen version's design; returns regions and a fix prompt. |
| `mark_screen_implemented` | Record the commit/PR that implemented the approved version. |
| `upload_asset` | Upload an image/icon/font/video (base64). |

## Prompts

- `design_screen(brief)` — load context, design on the shared system, save, fix warnings.
- `implement_screen(screen)` — fetch the approved version, implement it, mark implemented.

## Typical loop

1. `get_project_context`
2. `upsert_tokens`, `upsert_component`, `update_brandbook` (first time)
3. `save_screen` → user reviews and approves in the web UI
4. `get_approved_screen` → implement in the codebase → `mark_screen_implemented`
