primo-mcp is the official Model Context Protocol server for Primo. It gives AI coding agents (Claude Code, Cursor, Cline, etc.) live access to Primo’s docs, schemas, and validators so they can produce correct block and page files on the first try.
The MCP server is optional. It’s most useful when an agent is editing files in a Primo workspace export (a directory created by
primo new or primo pull).What It Does
When an agent edits acomponent.svelte, fields.yaml, or page YAML, the MCP server:
- Validates the change against Primo’s schema and reports specific errors
- Scaffolds new blocks and page types that are guaranteed to validate
- Resolves raw field values to the canonical shape Primo expects
- Surfaces the right docs section on demand instead of forcing the agent to grep
- Builds a preview so the agent can verify a change rendered before reporting done
Installation
Configure with Claude Code
Registerprimo-mcp with the Claude Code CLI:
--scope user to add it globally, or --scope project to commit the config to .mcp.json so your team picks it up.
Manual config (fallback): add to .mcp.json (project) or ~/.claude.json (user):
Available Tools
| Tool | When the agent calls it |
|---|---|
list_docs | Discover available docs sections |
get_docs | Read a specific docs section |
validate_block | After editing any file in a blocks/<name>/ folder |
validate_page | After editing a pages/*.yaml or page-types/*/config.yaml |
validate_site | After editing site/head.svelte or site/foot.svelte |
resolve_field_value | When given a raw value that needs canonical shape |
scaffold_block | Creating a new block from scratch |
scaffold_page_type | Creating a new page type from scratch |
build_preview | Verifying a change rendered visually |
Typical Agent Workflow
- Discover. Agent calls
list_docs, thenget_docsfor the section it needs. - Scaffold. Agent calls
scaffold_blockorscaffold_page_typeto produce a known-valid skeleton. - Edit. Agent edits files in the workspace.
- Validate. Agent calls
validate_block/validate_page/validate_siteafter each edit and addresses every error before moving on. - Preview. Agent calls
build_previewand loads the returned URL to verify visually.
Folder Conventions It Enforces
The validators assume the standard workspace layout:- Folder names are stable keys. Renaming
blocks/hero/toblocks/banner/breaks every page that referenceshero. Use a CMS rename or update references manually. site/head.svelteis injected into<svelte:head>. Do not wrap its contents in<svelte:head>yourself — the validator rejects this.- Field values have canonical shapes. Image fields are
{ url, alt }, links are{ url, label }, icons are SVG strings. Callresolve_field_valuewhen in doubt.
Without an Agent
You can also drive the same validators fromprimo validate:
Next Steps
Local Development
Run the CMS and sync files while you (or an agent) edit
Field Types
Reference for the canonical field shapes the MCP validates