Connect an AI agent

Vibe coding with WordPress starts here: connect Claude Code, Codex, Cursor, claude.ai or ChatGPT to the MCP server of Leitvia Studio. Pick the way that fits your AI tool and follow the numbered steps.

For site owners, agencies and developers · Leitvia Studio · Administrator · Checked with Leitvia Studio 1.3.65

Your AI toolWayYou need
claude.ai, Claude Desktop, ChatGPTA: sign in with OAuthHTTPS on the site
Claude Code, Codex, Cursor and other coding toolsB: an AI agent user with a passwordA terminal in your project folder

Way A: claude.ai or ChatGPT with OAuth

  1. In WordPress open Leitvia Studio › Agents. In the row Direct connection for AI apps choose Copy address.
  2. Add the address as a connector. In claude.ai and Claude Desktop: Customize › Connectors › Add custom connector. In ChatGPT: add a custom MCP connector with OAuth; its menus change often, so follow the help of OpenAI.
  3. The AI app opens the page Connect agent of your site. Sign in there as an administrator.
  4. Under Work as choose Myself to work with your own account, or an AI agent user. Myself reads and, with Leitvia Pro, decides on change packages in the chat, but never writes. An AI agent user may also change the site if you tick Write.
  5. Choose Connect. The connection now shows under Leitvia Studio › Agents, section Connections.
The status row Direct connection for AI apps on the screen Agents of Leitvia Studio, with the address of the MCP server of the site and the button Copy address.
Copy address puts the address of the MCP server on the clipboard.
The page Connect agent for the client Example chat app: a warning that the client registered itself and is not verified, the rows Client, Comes from and Returns to, the choice Work as with the AI agent users and Myself, the box Write and the buttons Connect and Cancel.
On the page Connect agent you choose who the AI app works as. Nothing is chosen in advance.
An AI client connects over OAuth on the site Tidepost, and the connection is closed again. The video has no sound; the transcript below has the text of every step.
Transcript of the video
  1. Under Leitvia Studio, Agents, the status names the MCP server for AI apps and its address.
  2. Connections lists every AI client connected over OAuth and the agent user it works as.
  3. An AI client opens the page Connect agent. A self-registered client is marked not verified.
  4. Under Work as, choose the agent user the AI client works as.
  5. Reading is always included. Tick Write only if the AI agent may change the site.
  6. Connect sends the client back with a code, which it exchanges for its tokens.
  7. The new connection appears under Connections with its rights, read and write.
  8. Close connection asks once more, then stops the tokens of that client at once.

Way B: Claude Code or Codex with an AI agent user

  1. In WordPress open Leitvia Studio › Agents. Under New agent enter a name, such as Claude Code, and choose Create agent.
  2. The box Application password for Claude Code shows the user name, the password and a ready Command for Claude Code. Choose Copy command. The box is shown only once.
  3. Open a terminal in your project folder, paste the command and press Enter. Claude Code keeps the password in its settings for this folder on your computer.
  4. Start claude and type /mcp. The server leitvia shows as connected.
  5. Ask the AI agent: Call leitvia/get-contract and tell me the name of the site. The answer names your site, so you know the connection points to the right one.
The box Application password for Claude Code on the screen Agents: user name, password, the command claude mcp add with the address of the site, and the buttons Copy password, Copy command and Done.
After Create agent the box has the finished command for Claude Code.

Codex reads the password from a variable of your terminal. Take the part after Basic from the copied command, then:

export LEITVIA_AUTH_HEADER="Basic <the part after Basic>"

Add the server to ~/.codex/config.toml, or to .codex/config.toml of a trusted project. The file holds only the name of the variable, never the password:

[mcp_servers.leitvia]
url = "https://example.org/wp-json/leitvia-studio/v1/mcp"
env_http_headers = { "Authorization" = "LEITVIA_AUTH_HEADER" }
An AI agent for Claude Code on the site Tidepost. The video has no sound; the transcript below has the text of every step.
Transcript of the video
  1. Under Leitvia Studio, Agents, name the new agent after the tool that uses it.
  2. Create agent makes a user with the role Leitvia Agent and an application password.
  3. Copy the password now; it is shown once. Revoke access removes it at any time.
Other AI tools: Cursor, VS Code, Gemini CLI

These tools take the password as a Base64 value of user name:password. Make it once in the terminal, with the user name and password from the box of step 2:

export LEITVIA_AUTH="$(printf '%s' 'agent-claude-code:xxxx xxxx xxxx xxxx xxxx xxxx' | base64 | tr -d '\n')"

Cursor, in .cursor/mcp.json of the project or ~/.cursor/mcp.json:

{
  "mcpServers": {
    "leitvia": {
      "url": "https://example.org/wp-json/leitvia-studio/v1/mcp",
      "headers": { "Authorization": "Basic ${env:LEITVIA_AUTH}" }
    }
  }
}

VS Code signs in with OAuth instead, so it needs no password. Put this into .vscode/mcp.json; VS Code asks you to sign in when the server starts:

{
  "servers": {
    "leitvia": { "type": "http", "url": "https://example.org/wp-json/leitvia-studio/v1/mcp" }
  }
}

The README of Leitvia Skills has the same for Gemini CLI, and a .mcp.json for Claude Code that keeps the password in the environment. Claude Code also works with OAuth: add the server without --header, then sign in with /mcp.

End a connection

  • Revoke access deletes the password of an AI agent user at once.
  • New password replaces it, for example after a laptop was lost.
  • Close connection under Connections ends an OAuth connection of an AI app.
The screen Agents after creating the AI agent Claude Code: the agent in the list with its access and the buttons New password and Revoke access.
Every AI agent user with New password and Revoke access.
The section Connections of the screen Agents: the client Example client working as Content agent with the rights read and write, the button Close connection, and the switches Connect over OAuth and Allow dynamic client registration.
Each OAuth connection with the user it works as and its rights.
If the connection fails
  • 401 although the password is right: the server drops the Authorization header before WordPress sees it. On Apache add CGIPassAuth On to .htaccess above the rules of WordPress, or ask your host.
  • The AI app offers no sign-in: the site needs HTTPS, the switch Connect over OAuth under Connections must be on, and the address must be the whole path ending in /mcp.
  • OAuth discovery: Blocked on the screen Agents: the web server answers 403 at /.well-known/ before WordPress runs. Choose Copy directives and add them to the nginx configuration of the site, wherever your host takes extra nginx directives, or send them to your host.
  • The AI tool hangs or gets everything at the end: a proxy holds the stream back. nginx follows the header X-Accel-Buffering: no, which the server sends. On Apache with PHP-FPM turn on flushpackets and turn off compression for the address.
  • 403 insufficient_scope: the connection may only read. Connect again and tick Write, or give the task to an AI agent user.
  • Claude Code fails under the protocol 2026-07-28: start it once with MCP_PROTOCOL_NEGOTIATION=legacy claude to use 2025-11-25.
For developers
  • Server: Leitvia Studio runs its own MCP server leitvia at /wp-json/leitvia-studio/v1/mcp, over streamable HTTP, with no other plugin. On a site of a multisite network in a subdirectory the path starts at the site, such as https://example.org/club/wp-json/leitvia-studio/v1/mcp.
  • Protocol revisions: 2026-07-28 without a session, and 2025-11-25 after initialize, which also serves clients that ask for 2025-06-18 or 2025-03-26. Another revision gets the error -32022 with the list of supported ones.
  • Tools: one per ability, named with a hyphen, such as leitvia-get-contract for leitvia/get-contract.
  • Prompts: every skill and workflow of Leitvia Skills, such as leitvia-page, in Claude Code /mcp__leitvia__leitvia-page.
  • Resources: the design contract, the tokens, the patterns, the open change packages and the outline of a page, readable without a tool call.
  • Elicitation: under 2026-07-28, a client with form elicitation asks the person before a tool that deletes, removes, rejects or rolls back. A yes is no approval; changes that need one still wait in the Inbox.
  • Tasks: leitvia-apply-recipe, leitvia-audit-site and leitvia-export run in the background for a client with the tasks extension. If a task stays at working, WP-Cron does not reach the site: run the system cron or activate Action Scheduler, which comes with WooCommerce.
  • Dynamic client registration: on by default (Allow dynamic client registration), for older clients that register themselves. Such a client is marked as not verified on the page Connect agent.
  • REST: without an MCP client every ability runs over the Abilities API of WordPress, such as curl -u "agent-claude-code:xxxx xxxx xxxx xxxx xxxx xxxx" https://example.org/wp-json/wp-abilities/v1/abilities/leitvia/get-site-health/run. The default server of the plugin MCP Adapter offers the same abilities with the same checks.

Data protection

The AI agent reads what its abilities return, such as page content and settings. Where your AI tool sends that depends on the tool; check its terms before you connect a site with personal data. Leitvia sends nothing to an AI service by itself. The only exception is the ability leitvia/plan-page, which uses the AI connector of WordPress that the site owner set up.