# MCP and AI tools

URL: https://rustpress.witsberry.com/mcp-and-ai-tools/

> Use your RustPress site as an MCP server for Claude Desktop, Claude Code or any AI app, add plugin AI tools, and connect other services' MCP tools.

RustPress speaks MCP (Model Context Protocol) both ways. AI apps can work on your site through its guarded tools, plugins can add tools of their own, and the site’s agents can use tools from other services. This page covers all three.

## Your site as an MCP server

The tools the built-in [AI agents](/ai-agents/) use are also an MCP server, in two ways.

### stdio, on the server

```
rp mcp --user ID [--abilities site,content,code,deploy]
```

### HTTP, for AI apps anywhere

```
POST /rp-json/rp/v1/ai/mcp?abilities=content
```

Connect an AI app under **AI › Connections** with a scoped key or OAuth, or give a script an administrator’s application password:

```
rp user app-password LOGIN NAME
```

## Abilities

The `abilities` setting limits which tools a connection gets: `site`, `content`, `code` and `deploy`. Give a client only the abilities it needs. Changes to the live site still wait for approval, whoever asks.

## Plugins can register AI tools

Plugins add their own tools. A shop plugin registers `create_product`, and the site’s agents, Claude Desktop or your own AI app can fill the catalogue:

```
wp.registerAiTool('create_product', { description: 'Create a product as a draft', risk: 'draft',
  inputSchema: { type: 'object', properties: { title: { type: 'string' }, price: { type: 'number' } }, required: ['title'] } },
  async (a) => ({ id: (await wp.db.insert('products', { title: a.title, price: a.price })).id }));
```

*   In PHP, use `rp_register_ai_tool( $name, $args, $cb )`.
*   Tools are offered as `<plugin_slug>__<name>` (names use a-z, 0-9 and \_).
*   `ability` is `content` (default) or `site`.
*   The callback gets the input and `{ user, agent }`. Validate the input like any request, and return only what the agent needs: results go to an AI model.

## Risk levels

| Risk            | What happens                                                                                                        |
| --------------- | ------------------------------------------------------------------------------------------------------------------- |
| `read`          | Looks only. Runs at once.                                                                                           |
| `draft`         | Drafts or plugin data, nothing live. Runs at once.                                                                  |
| `ask` (default) | For anything that changes the live site. The call becomes a proposal that a person approves under **AI › Changes**. |

## Other services’ tools

Under **AI › External tools**, connect MCP servers from other services: HeyGen for video, design tools, automations or your own systems. Give the server’s address and sign in with OAuth (RustPress registers itself, with PKCE) or a key in a header. Their tools reach your agents as `mcp__<server>__<tool>`.

*   Every tool asks before it runs until you mark it “runs at once”, or turn it off.
*   You choose which agents may use each server.
*   Keys and tokens are stored encrypted, and only https servers on the public internet are reached.
*   Images a tool returns stay with the chat. Files it links to, such as a rendered video, go to the media library when an agent calls `save_media_from_url`, which only accepts addresses a tool returned or you gave.

## Owner controls

*   The owner can turn any plugin tool off under **AI › Agents › Tools from plugins**.
*   Plugins can’t call the AI API themselves.
*   Tool results are treated as data, not instructions.
*   Every call is audited.

## Command-line AI agents

Claude Code and other MCP clients reach the same guarded tools through `rp mcp`. CLI agents get none of the server’s environment.

*   **Claude Code:** supported. Chats started with Claude Code run with its built-in shell and file tools turned off, and without the server owner’s personal Claude Code setup.
*   **Gemini CLI:** works the same way, but Google replaced it with Antigravity CLI and it now only serves paid API keys. Use the Gemini API provider instead.
*   **Antigravity CLI:** not offered yet, because its built-in tools can’t be switched off when it runs headless.
*   **Codex CLI:** not offered, because it always keeps a shell that could read the site’s secrets. Use the OpenAI provider instead.

More on what agents may and may not do is in [Safety and limits](/safety-and-limits/).
