Turn WordPress into an MCP server

Turn WordPress into an MCP server

Large language models are great at talking about your website. They are useless at working with it — until you give them a door. Here is how NIBWP turns WordPress into a Model Context Protocol server, how to connect Claude, and the sharp edges worth knowing.

TL;DR

Install NIBWP, mint a scoped token, and your site becomes one HTTPS endpoint that exposes typed tools. Point Claude or Cursor at it and an agent can read, search and write content safely.

What is MCP, in a minute

The Model Context Protocol is an open standard for connecting AI applications to tools and data. A client speaks one protocol to a server that advertises tools with typed inputs and outputs — USB for AI context: one shape, many devices.

NIBWP is an MCP server that lives inside WordPress. It introspects your post types, taxonomies, fields and active integrations, then exposes them as tools an agent can call over HTTPS.

Why not just use the REST API?The REST API is for developers writing code. MCP is for agents deciding what to do at runtime — tools are self-describing, so the model knows the shape of every call.

The architecture

Three layers, one connection. Clients connect to the NIBWP endpoint; NIBWP translates tool calls into WordPress operations and returns structured results.

AI clientsClaude / Cursor
NIBWPMCP endpoint
WordPressPosts & data
Figure 1. One endpoint maps your whole site into typed tools.

Exposing a tool

Out of the box you get tools for posts, pages, media and any public custom type. Adding your own is a one-filter affair:

functions.phpphp
<?php
// Expose a custom tool to your MCP server
add_filter( 'nibwp/tools', function ( array $tools ) {
    $tools[] = [
        'name'        => 'publish_changelog',
        'description' => 'Create and publish a changelog entry.',
    ];
    return $tools;
} );
Write descriptions for the modelThe description is the only thing the agent sees when choosing a tool. Clear beats clever every time.

Connecting Claude

Same endpoint, three clients. Pick your tool:

terminalbash
# Connect Claude Code over HTTP
claude mcp add --transport http nibwp \
  https://yoursite.com/wp-json/nibwp/v1/mcp \
  --header "Authorization: Bearer nwp_live_xxx"
~/.cursor/mcp.jsonjson
{
  "mcpServers": { "nibwp": { "url": "https://yoursite.com/wp-json/nibwp/v1/mcp" } }
}
claude_desktop_config.jsonjson
{
  "nibwp": { "command": "npx", "args": ["mcp-remote", "https://yoursite.com/wp-json/nibwp/v1/mcp"] }
}
Public reachability for hosted clientsThe Claude and Cursor connector UIs reach your site from the cloud, so the endpoint must be public over HTTPS. Claude Code runs locally and can hit staging.

A request, end to end

  1. The model reads the tool schemas and picks search_posts.
  2. NIBWP validates the arguments and runs a scoped query.
  3. Typed results return; the model decides to call create_post.
  4. The write is checked against your token scope, then committed.
claude > nibwp
$ claude "Draft a post from our last 3 changelog entries"
calling nibwp.search_posts({ type: "changelog", limit: 3 })
Draft created → /wp-admin/post.php?post=482
The endpoint never trusts the model. Every call is validated, scoped, and logged before it touches the database.— NIBWP security model

Security & scopes

Agents are powerful, so least-privilege is the default. Tokens carry scopes and you decide what each can touch:

ScopeCan doGood for
readSearch & fetch contentResearch, audits
writeCreate & update draftsContent workflows
publishSet content liveTrusted automations
  • Issue a separate token per client so you can revoke one without the others.
  • Keep tokens out of committed files — reference an env var instead.
  • Review the audit log; every tool call is recorded.
Never give an admin token to a chat clientIf an agent can change settings or users, a single bad prompt can do real damage. Scope down and gate publishing behind review.

Gotchas & tips

Use HTTP, not SSE

The legacy SSE transport still works but is deprecated. New connections should use the HTTP transport.

Mind your object cache

If reads look stale, a persistent object cache may be serving old data. Flush after bulk writes.

wp-cli
$ wp cache flush
Success: The cache was flushed.

Wrapping up

MCP collapses the distance between an assistant that knows about your site and one that can change it. With NIBWP that is one plugin, one endpoint, and a token you fully control.

Give the model a door, not a copy of your house.

Key takeaways

  • NIBWP exposes WordPress as typed MCP tools over one HTTPS endpoint.
  • Custom tools are a single add_filter with a schema and a handler.
  • Claude, Cursor and your own code all connect to the same URL.
  • Scoped tokens plus an audit log keep agents on a short leash.

Frequently asked questions

Do I need to write PHP to use NIBWP?
No. The built-in tools cover posts, pages, media and custom types. PHP is only for bespoke tools.
Does this work on shared hosting?
Yes, as long as the site is reachable over HTTPS for hosted clients.
Is it safe to let an AI write to my site?
With read or write scopes the blast radius is small, and every call is logged.
N
The NIBWP Team
Engineering

We build the bridge between WordPress and AI agents — securely.

More reading

From the blog

See it run on a live site.

Book a demo and watch an agent work through these abilities.