How to Wire WordPress MCP for Grok, Claude, and Coding Terminals

Full-bleed architectural ink-and-gouache illustration of an evening timber boathouse doorway with interlocking brass lock gears overlooking rain-lit harbor water.

About Will

I run Tygart Media, an AI-first agency that gets businesses cited and recommended by AI assistants — and I write about what we do, including what breaks.

Connect on LinkedIn →

From the Workbench · November 28, 2026 · By Will Tygart

Practitioner How-To · Free Takeaway
Download the 2-Page Spec PDF & Markdown Twin
Save the 2-page PDF wiring spec or pull the .md twin containing mcp_config.json and a complete Python Streamable HTTP handshake and DELETE teardown test harness.

Before connecting an AI assistant to WordPress, most developers fall back on bulk REST scraping — pulling dozens of pages of paginated post JSON just to answer a single question. In our 24-hour origin audit in Grok Knocked on Our WordPress Door 86 Times Using MCP, bulk scrapers transferred 84.45 MB over /wp-json/wp/v2/posts while xAI-Grok-Connectors ran 86 clean MCP sessions at a fraction of the bandwidth.

Under the Streamable HTTP MCP transport spec, WordPress does not need long-lived background daemons or open WebSockets. Every step — authentication, capability discovery, JSON-RPC tool calls, optional SSE checks, and explicit teardown — rides standard stateless or session-header HTTP verbs you can test in twenty lines of Python.

The Five-Verb WordPress MCP Lifecycle

Inspecting real connector logs shows why partial client wrappers fail. Clients that skip the notifications/initialized step or forget DELETE leave orphaned state, while naive WAF rules break OAuth metadata discovery before authentication even begins. Expect these exact HTTP codes:

Session StageHTTP Method & EndpointExpected StatusProtocol Purpose
1. Auth / Token RefreshPOST OAuth token URL or Basic Auth headerHTTP 200 OKIssues scoped bearer token (or validates WordPress Application Password)
2. Initialize HandshakePOST /wp-json/mcp/v1/mcp (initialize)HTTP 200 OKReturns server capabilities plus Mcp-Session-Id response header
3. Client Ready NoticePOST /wp-json/mcp/v1/mcp (notifications/initialized)HTTP 202 AcceptedConfirms capability agreement before issuing tools/list or tools/call
4. Optional Stream ProbeGET /wp-json/mcp/v1/mcp (Accept: text/event-stream)HTTP 405 Method Not AllowedStateless WordPress handlers decline optional SSE cleanly per spec
5. Clean Session TeardownDELETE /wp-json/mcp/v1/mcp (Mcp-Session-Id)HTTP 204 No ContentFrees session state cleanly on exit inside try/finally blocks

When publishing an externally discoverable connector for xAI Grok or Claude Desktop, pair your MCP endpoint with an RFC 8414 OAuth metadata document and publish a plain Agent Handshake specification so visiting bots read your supported endpoints rather than brute-forcing guesswork paths.

Streamable HTTP WordPress MCP lifecycle chart showing POST OAuth 200, POST RPC 200, POST initialized 202, GET SSE 405, and DELETE 204 teardown across 86 observed live sessions.
Clean WordPress MCP connectors follow a strict 5-verb handshake capped by HTTP 204 DELETE teardown.

Client Configuration and OAuth Discovery Endpoints

Most modern agent hosts accept a compact Streamable HTTP block pointing directly at /wp-json/mcp/v1/mcp. Avoid older deprecated serverUrl or SSE-only paths unless routing through an explicit stdio bridge:

mcp_config.json + WordPress OAuth & Application Password Endpoints (json)
{
  "mcpServers": {
    "wordpress-production": {
      "url": "https://example.com/wp-json/mcp/v1/mcp",
      "headers": {
        "Accept": "application/json, text/event-stream",
        "User-Agent": "Mozilla/5.0 (compatible; Studio-MCP-Client/1.0)"
      }
    }
  }
}

Self-Testing Handshake Harness and Real-World Traps

Never assume an active WordPress MCP plugin works just because wp-admin says Active. Run an uncached end-to-end probe from your own terminal using standard MCP lifecycle calls and verify every common edge blocker listed below:

WordPress MCP BlockerWhat Breaks LiveWhy It Tricks BuildersClean Production Fix
Edge Firewall 403 / 1010Python-urllib or default Curl UAs rejected at edge proxyLocal curl works from allowlisted shell while remote agents get 403Send standard User-Agent and exempt signed /wp-json/mcp/v1/ calls
UTF-8 BOM in JSON Credential FilesWindows PowerShell prepends 0xEFBBBF BOM to JSON secretsjson.loads fails or base64 auth token includes corrupt leading bytesAlways read secret JSON files with encoding='utf-8-sig'
Blanket /wp-json/ Firewall BlockSecurity rule blocks entire REST prefix to stop user scansBreaks oEmbed, Application Passwords, and all MCP discovery togetherBlock only /wp/v2/users enumeration and query author=N scans cleanly
Orphaned Sessions Without DELETEClient scripts exit after tools/call without cleanupTest harness works 10 times before hitting server session limitsAlways wrap session calls in try/finally issuing HTTP DELETE
Stdlib Python Streamable HTTP MCP Probe With Clean HTTP 204 DELETE Teardown (python)
import base64, json, pathlib, urllib.request
 
def load_wp_basic_header(secret_file: pathlib.Path) -> tuple[str, str]:
    data = json.loads(secret_file.read_text(encoding="utf-8-sig"))
    token = base64.b64encode(f"{data['username']}:{data['application_password']}".encode()).decode()
    return data["site"].rstrip("/") + "/wp-json/mcp/v1/mcp", f"Basic {token}"
 
def mcp_post(url: str, auth: str, payload: dict, session_id: str | None = None):
    hdrs = {
        "Content-Type": "application/json",
        "Accept": "application/json, text/event-stream",
        "Authorization": auth,
        "User-Agent": "Mozilla/5.0 Chrome/131.0.0.0 Safari/537.36",
    }
    if session_id:
        hdrs["Mcp-Session-Id"] = session_id
    req = urllib.request.Request(url, data=json.dumps(payload).encode("utf-8"), headers=hdrs, method="POST")
    with urllib.request.urlopen(req, timeout=20) as resp:
        raw = resp.read().decode("utf-8", errors="replace")
        return resp.status, resp.headers.get("Mcp-Session-Id", session_id), (json.loads(raw) if raw else {})
 
def smoke_test_mcp(secret_file: pathlib.Path) -> None:
    url, auth = load_wp_basic_header(secret_file)
    st, sid, _ = mcp_post(url, auth, {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}})
    assert st == 200 and sid
    try:
        st2, _, _ = mcp_post(url, auth, {"jsonrpc": "2.0", "method": "notifications/initialized"}, sid)
        assert st2 in (200, 202)
        st3, _, tools = mcp_post(url, auth, {"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}, sid)
        assert st3 == 200 and "result" in tools
    finally:
        del_req = urllib.request.Request(url, headers={"Authorization": auth, "Mcp-Session-Id": sid}, method="DELETE")
        with urllib.request.urlopen(del_req, timeout=15) as r_del:
            assert r_del.status in (200, 204)

Remember WordPress REST authentication mechanics: Application Passwords work cleanly over HTTPS for operator workflows, while third-party multi-tenant connectors should use scoped OAuth 2.1 tokens with explicit expiry and rotation.

Treat Your API Door Like Your Storefront

As we explored in Skills vs. MCP vs. Connectors vs. Plugins, exposing clean, typed tools lets external AI systems verify facts and run workflows without downloading gigabytes of noisy HTML. Run the teardown probe regularly so your endpoint stays as clean on call ten thousand as on day one.

Frequently Asked Questions

Does WordPress MCP require an always-on Node or SSE daemon?

No. Under the Streamable HTTP 2025-03-26 transport specification, standard PHP handlers over /wp-json/mcp/v1/mcp return JSON-RPC responses via POST HTTP 200 and answer optional GET SSE checks with HTTP 405 Method Not Allowed.

Why do Python REST and MCP scripts fail with HTTP 403 behind edge firewalls?

Many edge security rules reject default Python-urllib User-Agent strings. Passing a standard desktop browser User-Agent or explicit service-account headers resolves transport rejections without lowering overall bot defenses.

Why send HTTP DELETE at the end of an MCP session?

Sending DELETE with the Mcp-Session-Id header signals explicit client teardown (returning HTTP 204 No Content), preventing abandoned session state from accumulating on the origin host.

Primary Documentation & References

Continue the Workbench Series
Next practitioner wiring guide: Wiring Voice Notes to Coding Agents: Metamuse, Notion, and Markdown. For agent-ready content architecture and citation diagnostics, see our AI Citation Service or Smokejumpers Pricing.
Printable Workbench Reference
Keep This Wiring Spec Inside Your Repo
Save the 2-page PDF wiring spec or pull the .md twin containing mcp_config.json and a complete Python Streamable HTTP handshake and DELETE teardown test harness.
Track the AI tools you actually use
Vendor-neutral prices & limits for ChatGPT, Claude, Gemini, Perplexity and more — tracked in AI Stack Watch.
See the live AI tracker →

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *