MCP and AI agents

Connect an AI agent to your site over MCP, decide which tools it sees, and let it make precise edits with the same abilities the admin uses.

What it is

CanAI runs a Model Context Protocol server at /wp-json/mcp/wpcanai. Every action in the CanAI admin has a matching wpcanai/* ability, so an agent can write templates, pages and posts, manage menus, sideload images, change settings, translate, back up and restore. There is no "run any PHP" escape hatch: if an agent cannot do something, it is a missing ability, not a missing permission.

Manage all of it under CanAI → AI Client, which has four tabs: Skills, Connections, Guardrails and Tools.

Connecting

On Connections:

Connections shows ready-to-paste client JSON for each option.

Skills

Skills teach an agent the right workflows. Install them with:

npx skills add usewp/canai

That opens a picker. Add --skill canai-mcp to take just one, or -g to install globally. The Skills tab also has copy-ready prompts you can paste into an AI client that can run shell commands.

Skill Use
canai-mcp Essential. Drive any CanAI site: templates, pages, posts, settings, media, translations.
canai-prepare Essential. Turn mockups or static sites into one self-contained HTML file per page.
canai-blocks Opt-in. Deploy pages as native blocks instead of Twig.
canai-replicate Opt-in. Clone or migrate a live site into CanAI.
canai-eeat Opt-in. Audit content for helpfulness and E-E-A-T.
canai-yolo Opt-in power tool. Publish FluentSnippets PHP. Skip it for routine work.

Choosing which tools an agent sees

Every tool costs the agent context on each turn, so CanAI hides tools your site cannot use. On Tools:

The same controls exist for agents as wpcanai/manage-tools: {"action":"list"} shows every tool including hidden ones, and {"action":"set","groups":{"Languages":"on"}} turns translation on.

Guardrails

The Guardrails tab limits what an agent can reach:

Example: a precise edit in two calls

You asked for tighter line height on one heading. Rather than reading and rewriting a 145 KB page, the agent edits in place:

wpcanai/grep-content   { "pattern": "conference", "post_id": 42 }
wpcanai/replace-in-meta {
  "post_id": 42,
  "field": "html",
  "replacements": [ { "from": "leading-tight", "to": "leading-[1.15]" } ],
  "scope": { "text": "conference" },
  "require_all": true
}

grep-content returns each hit with line, column and a snippet around the match, plus optional context_lines. replace-in-meta is literal by default. ignore_whitespace tolerates indentation differences, regex allows PCRE with $1 templates, scope.text limits the edit to the element around a visible phrase, and dry_run previews counts without writing. For longer documents, read-meta accepts lines: [from, to] with a single field to read a slice.

Pages in a hierarchy

wpcanai/list-pages   { "all_pages": true }
wpcanai/create-page  { "title": "Auditorium", "parent": 118 }
wpcanai/update-page  { "post_id": 245, "slug": "auditorium", "parent": 118 }

list-pages shows each page's slug, parent, path and url; all_pages includes drafts and plain pages, so the agent can find a parent instead of making a duplicate. update-page changes title, slug, status, parent or order without touching the body, and returns previous values you can re-send to undo. Moving a published page changes its URL and its subpages', so the response warns you to look for hard-coded links.

If something looks wrong

Related