Skip to main content
Glama
README.md
# WordPress MCP Server

An [MCP](https://modelcontextprotocol.io) server that lets Claude (and other AI assistants) work with a WordPress site: read and edit pages, ACF fields, image alt text and SEO meta, and run AI audits with the [AI Site Auditor](https://github.com/) plugin.

Instead of copying content between WordPress and a chat window, you can ask:

> "Find pages without a meta description and suggest one for each."
>
> "Which images on the Pricing page have no alt text? Write alt text and apply it after I approve."
>
> "Create a draft landing page for our Zero Trust service, using the same block structure as the Cloud Security page."

## Tools

| Tool | What it does | Changes the site |
|---|---|---|
| `wp_site_info` | Site name, connected user and roles, content types, AI Site Auditor status, server mode | No |
| `wp_list_content` | Lists pages, posts or custom post types, with search and status filters | No |
| `wp_get_content` | Reads a page as plain text or Gutenberg block markup, with ACF fields and SEO meta | No |
| `wp_list_media` | Lists images and their alt text, can show only images without alt | No |
| `wp_get_seo` | SEO title and meta description (Yoast, Rank Math or AI Site Auditor) | No |
| `wp_get_audit_report` | Last AI Site Auditor report for a page | No |
| `wp_audit_page` | Runs AI Site Auditor on a page: scores, issues, suggested title, meta description and alt text | Saves a report only |
| `wp_create_draft` | Creates a page or post, **always as a draft** | Yes |
| `wp_update_content` | Updates title, content, excerpt or ACF fields | Yes, drafts only by default |
| `wp_update_seo` | Saves the SEO title and meta description where the SEO plugin reads them | Yes |
| `wp_update_alt_text` | Saves alt text to the Media Library and to the `<img>` tags in the post | Yes |

There is also a prompt, `seo_accessibility_review`, that walks the assistant through reviewing recent pages and proposing fixes for approval.

## Safety by design

AI makes mistakes, so the server limits what it can do:

- **No delete tools.** The server cannot delete posts, media or users.
- **New content is always a draft.** A person publishes it in WordPress.
- **Published content is protected.** `wp_update_content` refuses to change published, scheduled or private posts unless `WP_MCP_ALLOW_PUBLISHED_EDITS=true`.
- **Read-only mode.** With `WP_MCP_READ_ONLY=true`, write tools are not registered at all.
- **WordPress permissions apply.** The server uses an Application Password of a real user, so it can do only what that user's role allows. An Editor account is enough for content work.
- **Revisions.** WordPress keeps a revision of every content change, so it can be undone from the editor.
- Tools carry MCP annotations (`readOnlyHint`, `destructiveHint`), so clients can ask for confirmation before changes.

## Requirements

- Node.js 18 or newer
- WordPress 5.6 or newer (Application Passwords)
- Optional: [AI Site Auditor](https://github.com/) 1.1 or newer for the audit, SEO and alt text tools

## Setup

### 1. Install

```bash
git clone https://github.com/YOUR-USERNAME/wordpress-mcp-server.git
cd wordpress-mcp-server
npm install
```

`npm install` also builds the server into `dist/`.

### 2. Create an Application Password

In WordPress go to **Users → Profile → Application Passwords**, enter a name (for example "Claude MCP") and click **Add New Application Password**. Copy the password; it is shown only once.

Use a user with the lowest role that fits the job (Editor for content). If the Application Passwords section is missing on a local site without HTTPS, add this to `wp-config.php`:

```php
define( 'WP_ENVIRONMENT_TYPE', 'local' );
```

### 3. Connect it to your AI client

**Claude Desktop:** open **Settings → Developer → Edit Config** and add:

```json
{
  "mcpServers": {
    "wordpress": {
      "command": "node",
      "args": ["/full/path/to/wordpress-mcp-server/dist/index.js"],
      "env": {
        "WP_URL": "http://my-site.local",
        "WP_USER": "admin",
        "WP_APP_PASSWORD": "xxxx xxxx xxxx xxxx xxxx xxxx"
      }
    }
  }
}
```

Restart Claude Desktop. If it cannot find `node`, put the full path from `which node` in `"command"`.

**Claude Code:**

```bash
claude mcp add wordpress \
  -e WP_URL=http://my-site.local \
  -e WP_USER=admin \
  -e WP_APP_PASSWORD="xxxx xxxx xxxx xxxx xxxx xxxx" \
  -- node /full/path/to/wordpress-mcp-server/dist/index.js
```

**Cursor and other MCP clients:** use the same command, arguments and environment variables.

## Configuration

| Variable | Default | Description |
|---|---|---|
| `WP_URL` | required | Site URL, e.g. `https://example.com` |
| `WP_USER` | required | WordPress username |
| `WP_APP_PASSWORD` | required | Application Password (spaces are fine) |
| `WP_MCP_READ_ONLY` | `false` | Only register read tools |
| `WP_MCP_ALLOW_PUBLISHED_EDITS` | `false` | Allow `wp_update_content` on published content |
| `WP_MCP_TIMEOUT_MS` | `120000` | Request timeout. Audits can take up to a minute |

Never commit real credentials. `.env` is in `.gitignore`; `.env.example` shows the format.

## How it works

- **Transport:** stdio. The AI client starts the server as a child process and talks JSON-RPC over stdin/stdout. Logs go to stderr so they never break the protocol.
- **WordPress API:** the core REST API (`/wp/v2/...`) for content and media, and the AI Site Auditor REST API (`/aisa/v1/...`) for audits, SEO meta and alt text. Requests use the `?rest_route=` URL form, so they work even with plain permalinks.
- **Auth:** HTTP Basic auth with an Application Password.
- **Input validation:** every tool has a Zod schema; the MCP SDK turns it into JSON Schema for the model and validates the arguments before the handler runs.
- **Model-friendly output:** content comes back as readable text (or raw blocks when the model is going to edit it), long content is cut at `max_chars`, and audit reports are trimmed to what is useful.
- **Errors the model can act on:** a wrong password, a missing plugin, a protected published page or an unknown post type come back as clear messages that say what to do next, not stack traces.

## Project structure

```
src/
├── index.ts       Starts the MCP server over stdio, registers the review prompt
├── config.ts      Reads and validates environment variables
├── wp-client.ts   WordPress REST client: auth, errors, post type lookup
├── tools.ts       Tool definitions and handlers
└── format.ts      HTML to text, truncation, SEO length hints
test/
├── mock-wp.mjs        Fake WordPress REST API
├── server.test.mjs    End-to-end tests through a real MCP client over stdio
└── format.test.mjs    Unit tests
```

## Tests

```bash
npm test
```

The end-to-end tests start the built server exactly as Claude Desktop does (a child process over stdio), connect with the official MCP client, and run every tool against a fake WordPress REST API. They cover the safety rules (drafts only, protected published content, read-only mode), wrong credentials, a site that is down, and a site without AI Site Auditor.

## Limitations and next steps

- Gutenberg block markup is edited as a string. Elementor pages store content in `_elementor_data`, which this server does not edit.
- ACF fields are available only when the field group has **Show in REST API** turned on.
- Next: WooCommerce products, WPML/Polylang translations, a Streamable HTTP transport for remote use.

## License

MIT

TDQS

A3.8/5.0

Scored across 11 tools

Disambiguation4/5

Each tool maps to a distinct resource+action, and the description explicitly separates similar pairs (wp_get_audit_report reads a saved report vs wp_audit_page runs a new one). The only real friction is SEO overlap: wp_get_seo's output is also returned by wp_get_content, and wp_update_seo partially overlaps wp_update_content, though the descriptions clarify the split.

Naming Consistency4/5

Strong, predictable wp_verb_noun convention throughout (wp_list_content, wp_get_content, wp_update_content, wp_list_media, wp_create_draft, etc.) in consistent snake_case. The lone deviation is wp_site_info, which is noun-only rather than verb-led, but it is still readable and self-evident.

Tool Count5/5

Eleven tools sit squarely in the well-scoped range, and each covers a distinct slice of the content/SEO/audit workflow with no redundant entries. Read/write pairs are balanced rather than bloated.

Completeness4/5

The surface covers discovery, read, create, update, SEO metadata, media alt text, and auditing, which is solid lifecycle coverage for a review-then-publish workflow. Gaps remain (no delete/trash, no media upload, no taxonomy or publish operation), but publishing and deleting in WP admin appears intentional and agents can work around it.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues