# AI Agent Hub MCP Adapter Setup

This plugin now ships with a first-class MCP server powered by the official [WordPress MCP Adapter](https://github.com/WordPress/mcp-adapter). Use it to expose your AI Agent Hub abilities to MCP-native clients (Claude Desktop, ChatGPT desktop, VS Code MCP extensions, etc.).

## Prerequisites

- Composer install has been run (this plugin already requires `wordpress/abilities-api` and `wordpress/mcp-adapter`)
- AI Agent Hub activated
- A WordPress Application Password **or** a static bearer token (set inside the MCP Adapter screen)

## Configure the server

1) In `WP Admin > AI Agent Hub > MCP Adapter`, set the server ID/namespace/route if you want to customize them.
2) Choose which abilities you want to expose as MCP tools (defaults to all enabled modules).
3) Optional: add OAuth client metadata for reference and set a static bearer token if you want HTTP requests to require `Authorization: Bearer {token}`. Otherwise, WordPress auth (cookies or Application Passwords) is used.
4) Click **Save MCP settings**.
5) Copy the HTTP endpoint and/or STDIO command from the same screen.

## Authentication options

- **WordPress Application Passwords** (recommended for remote HTTP): Create one for an admin account and pass it as Basic auth in the proxy/client.
- **Bearer token**: If you set a static token in the MCP Adapter screen, HTTP calls must include `Authorization: Bearer YOUR_TOKEN`.
- **Logged-in session**: Works for local STDIO (WP-CLI) when you use `--user=admin`.

## Client examples

### 1) Claude or ChatGPT desktop via HTTP proxy

Run the proxy in a terminal:

```bash
npx -y @automattic/mcp-wordpress-remote
```

Set environment variables:

```
WP_API_URL=https://your-site.com/wp-json/awfah_mcp/mcp
WP_API_USERNAME=your-wp-user
WP_API_PASSWORD=your-application-password
# Optional if you set one:
# WP_API_BEARER=your-static-bearer-token
```

Add to your MCP config (Claude Desktop `claude_desktop_config.json`, ChatGPT `~/.config/chatgpt/modelcontext.json`, etc.):

```json
{
  "mcpServers": {
    "ai-agent-hub": {
      "command": "npx",
      "args": [
        "-y",
        "@automattic/mcp-wordpress-remote"
      ],
      "env": {
        "WP_API_URL": "https://your-site.com/wp-json/awfah_mcp/mcp",
        "WP_API_USERNAME": "your-wp-user",
        "WP_API_PASSWORD": "your-application-password"
      }
    }
  }
}
```

### 2) Local STDIO (WP-CLI)

Paste the STDIO command from the MCP Adapter screen into your MCP config. Example:

```json
{
  "mcpServers": {
    "ai-agent-hub-stdio": {
      "command": "wp",
      "args": [
        "--path=/path/to/wordpress",
        "mcp-adapter",
        "serve",
        "--server=ai-agent-hub-mcp",
        "--user=admin"
      ]
    }
  }
}
```

### 3) Model selection (ChatGPT, Claude, Gemini)

The MCP server exposes tools; model selection happens in your client. Use any MCP-capable model (ChatGPT, Claude, Gemini, Cursor, VS Code MCP extensions). No special model-side configuration is required beyond adding the MCP server as shown above.

## Tips

- If you change the REST namespace/route, update both the HTTP URL and STDIO args in your client config.
- Logs: enable `WP_DEBUG_LOG` to catch permission or ability-registration errors.
- If you add a static bearer token, share it only with trusted clients—possession grants MCP access.
