# Connect Claude Code

> Add your WordPress site to Claude Code as an MCP server with one pasted message or one command, in the Code tab of the Claude app or in a terminal.

Claude Code is Anthropic's agent app. Despite the name you do not need to write code: you describe the job in plain words and it uses your site's tools. It runs in the Code tab of the Claude app and in a terminal. PowerWP AI recommends it for developers and power users: one pasted message or one command sets it up, and it can download your backups to your computer by itself. It connects with a key. If you prefer to sign in without a key, see [Claude](/docs/connect/claude/).

## Before you start

Create a connection first. Open **PowerWP AI › Connections**, choose **Create connection**, pick **Claude Code**, name it and choose what it may do. Read-only diagnostics is a good start. Choose **Create key and show steps**: the window shows the steps below with your address and key already in them. The key is shown once. Here it appears as `<your key>`.

## Option 1: let Claude Code connect itself

In the setup window, copy the message under **Let Claude Code connect itself** and paste it into a chat in Claude Code. It adds your site for your user account and tells you the next step. The message contains your key, so paste it only into your own account. Claude Code may ask you to allow the change.

## Option 2: run one command

This is the command for macOS and Linux. The plugin fills in your site's name, address and key.

```
PATH="$PATH:$HOME/.local/bin" claude mcp add --transport http --scope user your-store "https://your-store.com/wp-json/wpai/v1/mcp" --header "X-WPAI-Token: <your key>"
```

`--scope user` puts your site in every folder and every new session. The address is in quotes because some shells read a `?` in it as a wildcard.

On Windows, copy the PowerShell version from the setup window. It finds Claude Code by itself, also when only the Claude app is installed.

:::steps
1. Copy the command for your computer from the setup window.
2. Paste it into Terminal (macOS, Linux) or into PowerShell from the Start menu (Windows) and press Enter. It answers "Added HTTP MCP server". The Claude app can stay open.
3. Start a new Claude Code session, in the Code tab of the Claude app or with `claude` in a terminal.
4. Type `/mcp`. Your site (`your-store`) is listed as connected.
:::

### If the command is not found

Save this as `.mcp.json` in the folder you open in the Code tab, start a new session there and allow the server when Claude asks. The file holds your key: keep that folder private and don't share or commit it.

```json
{
  "mcpServers": {
    "your-store": {
      "type": "http",
      "url": "https://your-store.com/wp-json/wpai/v1/mcp",
      "headers": { "X-WPAI-Token": "<your key>" }
    }
  }
}
```

To keep the key out of the file, write `${POWERWP_TOKEN_YOUR_STORE}` in place of the key and set that environment variable to the key.

## Recipes as slash commands

Since PowerWP AI 1.6, your site's [recipes](/docs/concepts/recipes/) appear in Claude Code as slash commands. Type `/mcp__your-store__` and pick one, for example `/mcp__your-store__diagnose_site`. The part after `mcp__` is your server name. Recipes that change something look first, show the exact texts and set a checkpoint. See the [recipe list](/docs/reference/recipes/).

Example: type `/mcp__your-store__monthly_checkup` for a read-only pass over updates, security, backups, speed and errors, with a short report in plain words.

## Check it works

```
Give me an overview of my site.
```

Claude Code calls `site_overview` and answers with your WordPress version, theme and plugins.

## Troubleshooting

- **The `claude` command is not found.** Use the command from the setup window, which finds Claude Code itself, or the `.mcp.json` file above.
- **`/mcp` does not list your site.** Start a new session. A session that was already open does not pick up the change.
- **401 "Authentication required".** The key was copied incompletely, or a host removed the header (see [Troubleshooting](/docs/help/troubleshooting/#authorization-header)). Keys cannot be shown twice: revoke the connection and create a new one.
- **"All AI connections of your plan are in use."** Revoke a connection you no longer need, or upgrade your plan.

## Related

:::cards
- [Choose how to connect](/docs/connect/) — All supported apps.
- [Permissions and presets](/docs/concepts/permissions/) — Decide what Claude Code may do.
- [Your first safe session](/docs/get-started/first-session/) — What to ask first.
:::

Source: https://powerwp.ai/docs/connect/claude-code/
