# Connect Gemini CLI

> Add your site to Google's Gemini command-line app with one command or a settings file, and use its tools from your terminal.

Gemini CLI is Google's Gemini in your terminal. One command adds your site to it, and the site then works in every folder.

## Before you start

Create a connection for Gemini CLI. Open **PowerWP AI › Connections**, choose **Create connection**, pick **Gemini CLI**, name it and choose what it may do. Start with Read-only diagnostics until you know how Gemini plans its steps. 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 Gemini connect itself

Copy the message under **Let Gemini CLI connect itself** and paste it into a chat in Gemini CLI. It runs the command below for your user account and tells you the next step. The message contains your key, so paste it only into your own account. Gemini may ask you to allow the change.

## Option 2: run one command

```
gemini mcp add --scope user --transport http --header "X-WPAI-Token: <your key>" your-store "https://your-store.com/wp-json/wpai/v1/mcp"
```

:::steps
1. Copy the command from the setup window.
2. Paste it into your terminal (Terminal on macOS and Linux, PowerShell on Windows) and press Enter. It saves your site in your user settings, so it works in every folder.
3. Start Gemini CLI with `gemini`.
4. Type `/mcp`. Your site is listed with its tools.
:::

### Or edit the settings file

Open `settings.json` in the `.gemini` folder of your user folder (`~/.gemini/settings.json`). Create it if it isn't there. Gemini CLI calls the address `httpUrl`:

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

If the file already lists other servers, paste only the `your-store` entry inside `mcpServers`, after the last entry, with a comma between the two.

## Check it works

Start `gemini` and ask:

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

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

## Troubleshooting

- **`/mcp` does not list your site.** Start Gemini CLI again. If you edited the file by hand, check for a missing comma or bracket.
- **401 "Authentication required".** The key was copied incompletely. Keys cannot be shown twice: revoke the connection and create a new one.
- **403 or 429.** 403 means your IP address is not on the connection's allow-list, or a firewall blocks `/wp-json/wpai/v1/`. 429 means too many requests: wait a few minutes.

## Related

:::cards
- [Choose how to connect](/docs/connect/) — All supported apps.
- [Kimi Code](/docs/connect/kimi-code/) — Another terminal agent.
- [Your first safe session](/docs/get-started/first-session/) — What to ask first.
:::

Source: https://powerwp.ai/docs/connect/gemini-cli/
