primo-mcp is the official Model Context Protocol server for Primo. It gives AI coding agents — Claude Code, Claude Desktop, Cursor, VS Code / Copilot, Codex, OpenCode, and more — live access to Primo’s docs, schemas, and validators to help them create and check block and page files.
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). Without it, primo validate and primo build still work.What It Does
An agent can call the MCP server to:- Validate a change against Primo’s schema and report errors
- Return validated scaffolds for new blocks and page types; the agent saves the returned files
- Convert field values to the format Primo expects
- Read a relevant section of Primo’s documentation
- Build a preview using the running local dev server
Installation
primo-cli depends on primo-mcp, but a dependency installation does not always expose a global primo-mcp executable. The wiring command uses a detected executable or falls back to npx -y primo-mcp. For the direct command used in manual examples, install it explicitly with npm install -g primo-mcp.
Connect your agent
Each MCP client stores server configuration differently.primo mcp install detects the clients on your machine and merges the Primo entry into each one, so you don’t hand-edit JSON per client:
MCP servers are loaded when a client starts. Restart your client after wiring (and reload the window for editor extensions) so it picks up the new server.
Supported clients
Run
primo mcp list to see the exact resolved path for your machine, and primo mcp print --client <name> for any client’s snippet.
What install changes
install merges only the primo server entry. It never rewrites the rest of your config:
- Existing settings, sibling servers, tables, and comments are preserved.
- Every write is backed up (
<file>.bak-<timestamp>) and atomic. - Re-running is idempotent — an already-wired client is left untouched.
--dry-runwrites nothing. A conflictingprimoentry is left as-is unless you pass--force.- Files that can’t be edited safely (JSONC with comments, TOML defined inline or with dotted keys) are reported rather than guessed —
primo mcp printemits the snippet instead.
Wire clients during primo init
primo init detects your MCP clients and offers to wire them, so a new workspace has Primo tools available before the first agent session:
primo init prints a hint instead of prompting or writing.
Configure manually
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):
Other clients
For any other client,primo mcp print --client <name> emits the exact snippet and target path. Paste it into that client’s MCP configuration and restart the client. You can also browse the MCP client directory.
Available Tools
The server provides instructions asking agents to validate edits. It does not watch files or guarantee that every client follows those instructions; verify the tool results before accepting an edit.
Example workflow to request
Ask your agent to follow these steps. Connecting MCP makes the tools available; the agent must call them and use their results. Scaffolding tools return file contents for the agent to save.- 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. - Check import and preview. Agent calls
get_dev_statusafter saving, addresses dropped-field warnings, then callsbuild_previewagainst the already-running dev server and opens the returned URL. The tools do not startprimo devfor you.
Workspace layout and validation rules
The validators assume the standard workspace layout:- Folder names are stable keys. Renaming
blocks/hero/toblocks/banner/breaks every page that referenceshero. Changing a display name in the CMS keeps the stable folder key; update references if you rename the folder itself. site/head.svelteis injected into<svelte:head>. Do not wrap its contents in<svelte:head>yourself — the validator rejects this.- Each field type expects a particular value format. 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
Look up field types and the value formats the MCP validates