How to Connect Claude Code to WordPress
Claude Code can work with WordPress through more than one architecture. It can operate on a local WordPress codebase, call WordPress REST endpoints through a trusted tool, or connect to an MCP server that exposes WordPress tools. The correct path depends on whether the task concerns code, site data or actions inside the WordPress administration layer.
Do not begin by giving Claude Code a human administrator account. Create a dedicated WordPress identity, start with Read Only access and verify both a permitted read and a rejected write.
In one sentence: Choose the connection architecture for the task, then attach Claude Code to a separate WordPress identity with the smallest possible authority.
What this guide helps you accomplish
This guide defines a provider-neutral WordPress side and a Claude-specific client side.
A useful AI workflow is not defined only by the quality of the answer. It is also defined by the data the assistant can reach, the actions it is permitted to take, the evidence you can inspect afterward and the ease with which access can be withdrawn.
Why this matters
“Connect Claude to WordPress” can mean at least three different things. A developer may open a local plugin repository in Claude Code. A marketer may want Claude to read posts from a live site. An agency may want an MCP workflow that can create drafts. Treating these scenarios as one integration produces confusing instructions and excessive access.
Claude Code’s MCP support makes tool connections possible, but the MCP server remains a separate trust boundary. Anthropic advises users to verify that they trust the server, especially when it can retrieve external content that may contain prompt-injection attempts.
Expected output
A successful run should produce:
- A selected architecture: local code, REST-backed tool or MCP server.
- A dedicated WordPress identity and revocable credential.
- A Claude Code configuration that contains no committed secret.
- A successful read-only test and an expected refusal test.
- A reproducible record of client, connector and plugin versions.
Choose the correct connection path
Use local repository access when Claude Code is reviewing or changing plugin or theme code. Use a REST-backed tool when the task needs WordPress records and a narrow API wrapper is available. Use MCP when a trusted server exposes WordPress resources and tools in a format Claude Code can discover and call.
A local code workflow does not automatically provide access to the live WordPress database. An MCP workflow does not automatically provide access to the site’s files. State the boundary explicitly.
Prepare the WordPress side
Create a dedicated identity for the assistant. If the connection uses WordPress Application Passwords, generate a credential for that identity and transmit it only over HTTPS. Record the credential owner, purpose and planned revocation date. Do not place the credential in .mcp.json, documentation, screenshots or version control.
Confirm the exact WordPress capabilities attached to the identity. A connection that authenticates successfully can still be correctly refused when the identity lacks permission for an action.
Configure Claude Code
Claude Code supports local and remote MCP server configurations. Current official documentation uses claude mcp add for setup and provides local, project and user scopes. Project-scoped configuration can live in .mcp.json, but credentials should be supplied through environment-variable expansion or another approved secret mechanism.
Exact flags and transport names are version-sensitive. The implementation must re-check Anthropic’s current documentation and capture claude --version before publishing a copyable command.
Run two acceptance tests
First, ask Claude Code to retrieve a small, known set of WordPress records and compare the result with WordPress. Second, ask it to perform a write that the identity should not be allowed to perform. The first test proves utility; the second proves the boundary.
A connection guide is not complete until both outcomes are documented.
A safe workflow
- Define whether the task concerns local code, WordPress data or WordPress actions.
- Choose a trusted REST or MCP connector appropriate to that task.
- Create a dedicated Read Only WordPress identity and revocable credential.
- Store secrets outside the repository and reference them through the approved environment mechanism.
- Configure Claude Code using the current official MCP instructions when MCP is selected.
- Run a small read test and compare the returned data with WordPress.
- Attempt a prohibited write and confirm that WordPress refuses it.
- Record versions, configuration scope, evidence and revocation procedure.
Prompt recipe
Before copying this prompt, replace every value in square brackets. Do not paste credentials, customer data or private information into the instruction.
You are connected to a WordPress demonstration site through an identity that should be read-only.
Task:
1. Retrieve the 10 most recently modified published posts.
2. Return title, canonical URL, publication date and last-modified date.
3. Do not create, edit, delete or publish anything.
4. If a field is unavailable, report it as unavailable rather than inferring it.
5. After returning the table, explain which WordPress tool or endpoint supplied each field.
Then stop.
Why the prompt is structured this way
The prompt limits the record count, names the fields, prohibits every write class and asks Claude to identify the data source. This makes the output easier to compare with WordPress and reveals whether the connector hides important provenance.
Recommended access boundary
Use a Read Only identity. The assistant may inspect the WordPress data included in its scope, but any attempt to create, edit, delete or publish content should be refused.
This workflow can influence editorial decisions or create unpublished changes. Keep the scope narrow and review every proposed change.
The access level is a starting recommendation, not a universal entitlement. The exact WordPress capabilities available to an identity must come from the installed product version and its published coverage, not from this article alone.
What must remain outside the task
- Do not commit
.mcp.jsonvalues that contain credentials. - Do not use a human administrator account as the agent identity.
- Do not claim Claude Code compatibility until the exact path is reproduced against the distributed WP Agent Control baseline.
- Do not let an MCP server retrieve untrusted content and immediately execute writes in the same unsupervised workflow.
How WP Agent Control fits
The guided private folder for Claude Code or Codex uses WordPress REST and an Application Password with a dedicated read-only profile. Existing Read Only, Draft, Content Editor and Publisher profiles remain under Advanced. They are not automatically converted to OAuth and do not inherit the remote task and exact-approval model.
Get structured site information and inspect selected published pages after connecting. No temporary task is needed for this public reading. You can also browse public pages without the plugin; Agent Control adds structured access and a path toward authorized WordPress work.
Connect your AI: docs first profile · See features and compatibility: coverage
Verification checklist
- Claude Code and connector versions are recorded.
- The WordPress identity is dedicated and Read Only.
- No credential appears in Git, logs, screenshots or prompts.
- The read result matches a known WordPress sample.
- The prohibited write is refused.
- Revocation prevents a subsequent connection.
Common failure modes
- Using one guide for every architecture: Local code work, REST data access and MCP tool use have different prerequisites and risks.
- Committing the secret: Project configuration may be shareable while the credential must remain outside version control.
- Blaming Claude for a permission refusal: A 401 or 403 may show that WordPress is enforcing the intended boundary.
- Publishing unverified commands: Claude Code flags and connector packages can change; capture current versions and rerun the guide.
Advanced note
For a high-assurance setup, treat the MCP server as its own component with an allowlist of exposed tools, a version pin, a threat model and a prompt-injection boundary. The WordPress identity should remain the final authority even if the client or server requests a broader action.
Related guides
- WordPress MCP Explained in Plain Language
- How the Official WordPress MCP Adapter Works
- WordPress Application Passwords for AI Connections
- Which WordPress Access Level Should You Give an AI?
Continue
Next step: open Which WordPress Access Level Should You Give an AI?, choose the smallest suitable access level, then follow the relevant connection guide. When you are ready to create a separate and revocable identity, review Product or begin the 7-day Solo trial.
Sources and verification
This page was checked against the following primary sources. Last source review: .
- Connect Claude Code to Tools via MCP · Anthropic
- Claude Code Security · Anthropic
- Authentication — REST API Handbook · WordPress.org
- Application Passwords: Integration Guide · WordPress.org
- From Abilities to AI Agents: Introducing the WordPress MCP Adapter · WordPress.org