The quickest way to get an AI agent working on a WordPress site is also the quickest way to damage one: give it an administrator login and let it click around. Chat-based help is slow, because you copy and paste between a chat window and wp-admin. Browser-driving agents are brittle, because they guess at screens that change with every plugin update. Neither gives you a record of what ran, and neither lets you narrow what is allowed.
NibWP takes a different route. It is a WordPress plugin that exposes a site’s abilities over MCP, the Model Context Protocol, so an agent can read and change the site through a defined, authenticated interface instead of through screens. An ability is a named, typed action: get a post, create a post, update an option, write a file. The agent authenticates with a standard WordPress application password, so it acts as one specific WordPress user and nobody else.
Here is the single most important idea in this tutorial. The safety of an agent is decided by four things you control before it types a word: which WordPress user it acts as, which abilities exist, where it works (staging or live), and what you can restore afterwards. The prompt is the weakest control of the four. A well-worded instruction that says “be careful” does nothing against a credential that can do anything. Everything below is built around tightening those four things and then working in a rhythm that catches mistakes while they are still cheap.
A word on where this comes from. NibWP is made by the publisher of WPresident, so this is a builder’s account from the inside, not an independent verdict. wpresident.com itself was built in November 2026 by an AI agent (Claude Code) driving the site through NibWP: about 45 pages, a single-post template, shared header and footer components, SEO titles and descriptions, a colour palette and typography settings and several small sandbox plugins, mostly from scripts and without opening wp-admin for page building. Where we describe something that happened to us, we say so, and those notes are the only first-hand material here. Everything else comes from WordPress and vendor documentation and general practice, is labelled that way, and may differ in your version. The listing of the plugin and the Connect screen in your own install are the places to verify details.
The tutorial follows the order you should actually work in. First you build the safety rig: a staging copy, a dedicated least-privilege user and a restore point. Then you install the plugin, create the application password and run the MCP handshake by hand once, so you know what the connection really is. Then you connect your agent and give it read-only work, move to drafts, learn the dry-run and validation loop, and learn to read the plan an agent proposes before it runs. After that comes the abilities ladder from read-only up to executing arbitrary PHP, the file sandbox and its crash safe mode, sessions and timeouts, rollback, a repeatable prompt structure and a review routine for every run.
You do not need to be a developer, but you should be comfortable in wp-admin, comfortable pasting a command into a terminal, and willing to read what an agent proposes before approving it. WP-CLI is used for several checks because it gives you an independent view of the site that does not pass through the agent.
One expectation to set early. An agent that edits a site is not magic and it is not autonomous in any sense you should trust. It is a fast, literal operator that reads schemas, follows your instructions to the letter and makes errors a careful human would not, such as saving a price as a zero or leaving a stray apostrophe in a PHP string. We hit both. Good practice does not prevent the mistakes; it makes each one small, visible and reversible. By the end you will have a setup where a bad run costs you a few minutes and a restore, not an afternoon and a public apology.
Key points
- An agent acts as one WordPress user, through an application password, so that user and the abilities you expose set the real security boundary, not the prompt.
- Work on a staging copy with a dedicated least-privilege user and a tested restore point before the first connection, and only then go near production.
- Move through the same ladder every time: read, then draft, then validate or dry run, then review the plan, then publish, then read back and verify.
- A dry run proves a payload is acceptable, not that the saved result is correct, so always read the stored content back and compare the strings that matter.
- Treat execute-php as an emergency tool: nearly everything it is used for can be done with narrower abilities or a reviewable sandbox file.
- Sessions expire and hosts time out, so retry reads freely, retry writes only after reading back, and stop when the host keeps erroring.
- Put your standing rules in a repeatable prompt: scope, allowed abilities, procedure, stop conditions and a report format.
What actually happens when an agent edits your site
Before you configure anything, get the mechanism straight, because every later decision follows from it. There are four moving parts between an agent and your database, and each one is a place to apply a limit.
First, WordPress itself. Since version 6.9, core includes an Abilities API: a registry where plugins declare named actions with a description, an input schema, an output schema and a permission callback that decides whether the current user may run them. Second, the MCP Adapter, an official package that takes those registered abilities and publishes them as MCP tools, so any MCP-aware client can discover and call them. Third, NibWP, a plugin built on both of those, which registers a curated set of abilities for content, taxonomies, media, comments, menus, users, meta, allow-listed options and files, and serves them from a per-site endpoint. Fourth, your agent client, which speaks MCP over HTTP, sending JSON-RPC messages.
The endpoint in the build we used had the form /wp-json/mcp/nibwp. It is an ordinary WordPress REST route, which means WordPress authentication applies to it before NibWP sees the request. That is why the credential is a WordPress application password and why every call runs with that user’s capabilities. The plugin’s documentation says the same thing in another way: an agent can only do what the connected account can do.
The agent does not get a hundred separate tools. It gets three generic ones: discover abilities, get an ability’s schema, and execute an ability with parameters. That design keeps the agent’s tool list short, and it moves the real documentation into the schemas. In our build, the ability schemas were the documentation we relied on, so make sure your agent reads them before it calls anything.
This layering has three consequences worth stating plainly.
- The boundary is the user, not the instruction. If the application password belongs to an administrator, the agent can do administrator things, whatever your prompt says. If it belongs to an editor, option changes and plugin management are out of reach no matter how persuasively the agent argues for them.
- The ability list is the menu. If an ability is not registered, the agent cannot call it. Narrow abilities such as “update this post” are easy to review. Broad ones such as “run this PHP” are not.
- Everything is a request you can read. Each call is a small JSON message naming an ability and its parameters. That is far easier to review, log and replay than a browser session full of clicks.
What this does not give you is judgement. The agent will happily do exactly what you asked, including the wrong thing, quickly and at scale. The rest of this tutorial is about making the wrong thing small and noticeable.
The path from prompt to database
Build the safety rig before you connect anything
The first connection should never be to production. Spend an hour on three pieces of preparation and the rest of the tutorial becomes low-stakes: a staging copy, a dedicated user and a restore point you have proved works.
A staging copy. Use your host’s one-click staging if it has one, or clone the site to a second hostname with the same PHP version and the same plugins. The point is a place where a mistake costs nothing. Three details turn a staging copy from a convenience into a real safety net. Discourage search engines from indexing it. Stop it sending real email to real customers, which an agent running a form or membership test can trigger without anyone noticing. And if the site takes payments, put every gateway in test mode. You can also tell WordPress which kind of environment it is in, which is useful for plugins that behave differently on staging:
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
Staging also needs HTTPS. WordPress only offers application passwords over HTTPS, unless the environment type is set to local, so a plain-HTTP staging hostname will quietly show no application password section in the profile screen. If you cannot find the option, check this first.
A dedicated user. Do not connect the agent as yourself. Create a separate account whose only job is being the agent. The reasons are practical. Posts it creates are attributed to it, so you can filter by author. Its application password records when it was last used and from which IP address, which gives you a cheap audit signal. You can revoke its access without touching your own login. And you choose its role. Start with Editor, which can create, edit and publish posts and pages but cannot manage plugins, users or site options. You will find out quickly which tasks need more, and raising the role for a specific job is a decision you make, rather than a default you inherit.
$ wp user create agent-nibwp agent-nibwp@example.com --role=editor --porcelain
That command prints the new user’s ID and lets WP-CLI generate a password you will never use, because the agent authenticates with an application password instead.
A restore point you have proved works. A backup you have never restored is a hope, not a plan. Before the agent touches anything, take a database export and confirm that a full-site backup from your host exists and is recent. Then do the part most people skip: restore it once, on the staging copy, and note how long it took and what you had to click. You want to learn that on a quiet afternoon, not during an incident.
$ wp db export before-agent.sql
Keep that file somewhere that is not inside the web root. The later section on rollback covers what each kind of change allows you to undo; for now, the rule is simple. No restore point, no agent.
Finally, write down two lines before the first prompt: what finished looks like, and how you would undo it. If you cannot write the undo line, the task is not ready to hand over. This habit sounds bureaucratic and takes thirty seconds. It is also the single cheapest way to discover that a task needs a backup of something you had not thought about, such as an option that holds a theme’s settings.
Install NibWP and create the application password
With staging, a user and a backup in place, install the plugin on the staging site. According to the plugin’s directory listing, it needs WordPress 6.9 or later, because the Abilities API is required, and PHP 8.0 or later. Check those requirements on the listing for your version before you install, since they can change between releases.
Install it from the plugin directory or by uploading the plugin folder, then activate it. The documented flow after that runs through a screen called NIBWP Connect. There you turn on the AI Abilities switch, generate an application password and copy a ready-made connection prompt that your AI client uses to add the MCP server itself. The switch matters more than it looks: it is a master toggle, and the documentation says that when it is off no abilities are registered at all. Existing application passwords are left untouched, which means turning it off is a clean, instant way to stop an agent without revoking anything.
The listing also describes a sign-in flow with an approval screen that lists what you are allowing, as an alternative to copying a password. Use it if your client supports it. Which method each client supports is marked on the Connect page, so you do not need to guess.
What an application password actually is. It is a credential tied to one WordPress user, created in their profile or through the REST API or WP-CLI. It cannot be used to log in to wp-admin. It only authenticates API requests, sent as HTTP Basic authentication with the username and the password. WordPress shows it once, in groups of characters separated by spaces; the spaces are cosmetic and WordPress ignores them. You can create as many as you like per user, name each one, see when and from which IP address each was last used and revoke them one by one. That per-credential revocation is the feature that makes this approach sensible: give each client and each environment its own, named for what it is.
$ wp user application-password create agent-nibwp "claude-code-staging" --porcelain
Store the printed value in your client’s secret storage or an environment variable. Do not paste it into a chat message, a ticket or a file that is committed to a repository. If it ends up anywhere you do not control, revoke it, and make a new one.
When a correct password returns 401. These are the usual culprits, from most to least common. You used the display name instead of the login name. The connection is plain HTTP, so application passwords are unavailable. The host’s web server configuration strips the Authorization header before PHP sees it, which happens on some FastCGI setups. A security plugin or firewall rule blocks the REST API for non-browser clients or disables application passwords outright. A web application firewall treats a JSON-RPC POST as suspicious. When you hit one of these, the handshake you run by hand in the next section is the fastest way to tell which layer is at fault.
You can also check from the other side. Listing the user’s application passwords shows each one’s name and when it was last used, so after your first connection attempt you can confirm the credential was at least presented:
$ wp user application-password list agent-nibwp --fields=uuid,name,last_used,last_ip
A last-used value of empty after a failed attempt tells you the request never authenticated, which points at the server or a firewall rather than at the agent.

The endpoint, the three tools and a handshake you can run by hand
Run the connection by hand once, with curl, before you let an agent near it. It takes five minutes and it removes the client from the equation. If curl works but your agent client fails, the fault is in the client’s configuration. If curl fails, the fault is the host, the credential or a firewall. Without this split you will spend an hour blaming the wrong layer.
The endpoint takes JSON-RPC messages over HTTP POST. In the build we used, its path was /wp-json/mcp/nibwp on the site’s own hostname, and the Connect screen in your install shows the exact value. A conversation with an MCP server over HTTP has a fixed opening. The client sends an initialize request, the server answers with its capabilities and issues a session id in a response header, the client sends a notification that initialisation is complete, and from then on every request carries that session id. That header is the origin of two error messages you will meet later in this tutorial.
Set three environment variables first: the endpoint URL from the Connect screen, the agent user’s login name and the application password.
$ export MCP_URL="paste the endpoint from the Connect screen here"
$ export WP_USER="agent-nibwp"
$ export WP_APP_PASSWORD="paste the application password here"
Now send the initialize request. The -i flag prints the response headers, which is where the session id lives. The Accept header lists both content types because the transport allows the server to answer with either plain JSON or an event stream. The protocol version string should be one your server supports; if the response names a different version, use that one.
$ curl -i -u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"hand-check","version":"0.1"}}}' \
"$MCP_URL"
Look for a header called Mcp-Session-Id in the output and copy its value into a variable. Then confirm initialisation and ask for the tool list:
$ export SESSION_ID="paste the session id here"
$ curl -s -u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
"$MCP_URL"
$ curl -s -u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Mcp-Session-Id: $SESSION_ID" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
"$MCP_URL"
If you get a list back, the whole chain works: HTTPS, the REST route, the Authorization header, the application password, the user’s permissions and the MCP layer. Read the list. You should see the three generic tools of the MCP Adapter, which its documentation names as discover-abilities, get-ability-info and execute-ability. Some clients show them with the namespace separator replaced by a hyphen. What they do is straightforward: the first returns the names and descriptions of the abilities your user may call, the second returns one ability’s input and output schema, and the third runs an ability with parameters.
That is the whole rhythm an agent follows for every task: discover once per session, fetch the schema before the first use of each ability, then execute. When you review a transcript, check that the second step actually happens. An agent that executes an ability it has never fetched the schema for is guessing parameter names, and guessing is how you get a clean-looking call that quietly does nothing, or does something you did not mean.

Connect your client and start with read-only work
Now connect the agent client. The plugin’s documentation describes copy-paste setup for a long list of clients, and the pattern is the same everywhere. For Claude Code, you run an mcp add command that the Connect screen prints for you. For desktop and chat clients, you add the endpoint as a custom connector or MCP server. For editors such as Cursor or VS Code, you paste a configuration block. Copy these from the Connect screen rather than assembling them from memory. The screen knows your endpoint and your credential format, and a hand-built command is where typos and trailing slashes creep in.
Before the first real prompt, check your client’s approval settings. Most clients let you require confirmation per tool, per server or per call. Set the execute tool to ask every time and leave the discover and schema tools on automatic. Those two only read. The execute tool is the one that can write, so it is the one that deserves your attention. You will loosen this later for specific, well-understood tasks, never for the whole server at once.
Your first prompt should change nothing. Ask the agent to list the abilities it can see, describe each in one sentence and say which of them can write. This is a cheap, informative test of three things at once: the connection, the permission scope and the agent’s understanding. If the agent reports abilities you did not expect, such as anything touching users or files when you gave it an editor account, you have a misconfigured role or a different version of the plugin than you assumed. If it fails to list what you do expect, check that the master switch is on and that the account’s role covers the ability.
Then give it a read-only task that produces a result you can verify independently. Good first jobs:
- List every page with its ID, status, slug and last-modified date, and give the count. Compare the count with wp-admin or with
wp post list --post_type=page. - Read the home page and report the exact title and the exact first heading, quoting them. You check the quote against the live page.
- Read the SEO title and description for five named pages, if you run an SEO plugin whose abilities are exposed. In our build we set these for pages, posts and the home page through the Slim SEO abilities.
- Read one named option and report its current value, without changing it.
The method behind these jobs matters more than the jobs. Every claim the agent makes must come with an identifier you can check. “The About page needs a new description” is a claim with no evidence. “Post 52, last modified on this date, has an empty description field” is a claim you can verify in ten seconds. Agents will sometimes invent a plausible detail when a call returns less than they expected, and a rule of “quote the value and the ID” catches that early. If an agent cannot back a claim with a returned value, treat the claim as unproven.
Spend a session or two here. It feels slow, and it is the cheapest time you will ever spend. By the end you should know how fast calls return, how the agent handles pagination in long lists, whether it picks the right ability without being told, and which of its summaries you can trust. Only then move up the ladder.
The trust ramp for any new task
- ReadThe agent reads the objects involved and quotes IDs and values. You verify them independently.
- PlanIt lists each ability call, the target and the expected change, with a line on how to undo it.
- Draft or dry runCreate drafts, or validate a payload without writing, so nothing live changes yet.
- ReviewYou read the parameters and preview the result in wp-admin or on staging.
- PublishA separate, small instruction changes the status or pushes the change live.
- Read backThe agent reads the stored result and compares the strings that matter. You check the public page.
Draft first, publish last
Once reading works, let the agent write, and let it write only things that cannot hurt a visitor. In WordPress terms that means drafts. A draft is invisible to the public, previewable in wp-admin and cheap to delete. The habit to build is that a new post or page is created as a draft, reviewed, and then published by a separate, deliberate instruction. Look at the schema of the post-creation ability and see whether it accepts a status; if it does, make “status: draft” a standing rule in your prompt rather than hoping the default is what you want.
A note on honesty here. This is general WordPress practice and a recommendation, not a description of how we built our own site. What we can say from experience is narrower: the post abilities we used were create, update and get, plus meta and option abilities.
Updates to live content are the dangerous case. Creating a draft cannot damage anything. Updating a published page changes what visitors see the moment the call returns. Three habits reduce that risk. Read the current content first and keep a copy outside the site, for example in a file the agent writes to your project folder. Prefer working on a duplicate draft of the page and swapping it in, or run the whole change on staging and replay it on live after you have inspected the result. And change one page, look at it, then do the rest in a batch. The first page tells you whether the instruction was understood; the batch only repeats that understanding.
Meta and options deserve more suspicion than content. Post content has revisions. Meta values and options do not, by default. If an agent updates a custom field or a setting, the previous value is gone unless somebody read it first. Add a rule to your prompt: before any meta or option write, read the current value and report it in the plan. It costs one extra call and gives you the undo line. The plugin’s documentation says option reads and writes are limited to an allowlist of non-sensitive options, which is a useful backstop, but an allowlist stops dangerous options, not wrong values in allowed ones.
What “published” has to mean. Publishing is more than a status change. The page needs a correct title and slug, a description, a canonical URL that is not pointing at staging, internal links that resolve and an image if the template expects one. Build the check into the instruction: “publish post 52, then fetch the public URL and report the HTTP status, the title element and the canonical link”. The agent can do this with ordinary tools. You can do it yourself in a terminal, with the page address in a variable:
$ curl -sI "$PAGE_URL" | head -n 1
A 200 is the minimum. A redirect to another page, or a 404 for a page you just published, usually means a slug collision or a rewrite-rule problem. In our build one SEO plugin option made a page URL resolve as a category archive instead of the page we had created; the fix was switching that option off and flushing rewrites, and the lesson is that the live URL is the only proof that publishing worked.
Keep the publish instruction tiny and separate. “Set post 52 to published” is easy to review and easy to reverse. “Finish the page and put it live” smuggles three decisions into one approval. If you remember one rule from this section, make it this: the agent may prepare anything, but going live is a step you ask for by name.
Dry runs and validation: the loop that catches mistakes cheaply
A dry run asks one question: would this be accepted? It answers without writing anything. Wherever an ability takes a large structured payload, such as a page layout, an import or a batch of fields, validate before you write. The clearest example from our build was the Etch HTML-to-component converter that NibWP provides. You hand it a payload of Etch blocks plus styles, and a dry_run flag makes it validate without saving. The response lists passed and failed checks, warnings and what it calls orchestration suggestions. That flag belongs to that converter, not to every ability, but the rhythm it taught us applies everywhere.
The rhythm is a loop. Write the payload, run it dry, read the report, fix what failed, run it dry again, and only when nothing fails do the real push.
Validators encode a house style, so teach it up front. The rules we ran into were specific. Class names had to be BEM-like with a brand prefix. Colours had to be tokens with a fallback, and a hard-coded hex value was flagged; an rgba() inside a var() fallback failed outright. Font sizes had to use a token style, and clamp() or complex min() fallbacks were rejected. Every element needed a class, with SVG primitives exempt. None of these is unreasonable, but an agent that learns them one failed dry run at a time wastes laps. Put the rules you know about at the top of the prompt, and ask the agent to restate them before it writes the first payload.
Triage the report, do not obey it. Failed checks must be fixed. Warnings deserve a decision. The suggestions are advice. On one page we got 89 orchestration suggestions and found no way to silence them. If you let an agent treat every line as an instruction, it will start rewriting working markup to satisfy advice and can break what already passed. Tell it explicitly: fix failures, explain each warning, report the number of suggestions and do not act on them unless asked.
Bind approvals to a target. Before a push, the converter workflow in our build used a preflight step that issued a token. The token was tied to the target post and to a push mode, and we used replace_section. That is a pattern worth copying in your own habits even when a tool does not enforce it: an approval that names the exact object and the exact operation cannot quietly be reused for a different post or a broader overwrite. When you approve a call, check that the target ID in the parameters matches the one you meant.
Validation is not verification. This is the most expensive lesson in this section. In version 2.0.0 we found a defect in the converter’s save step: it treated a dollar sign followed by digits as a back-reference, so a price written as a dollar sign and a number was stored as a bare 0. A validate-only run cannot catch that, because the defect sat in the save step, which it never reaches. Every price on one page was lost until we noticed. The workaround was to put the dollar sign in its own text block. Whether that is fixed in your version is something to check, but the principle is permanent: a dry run proves the payload is acceptable, not that the saved result matches it.
So read back and compare, with a tool that is not the agent:
$ wp post get 52 --field=post_content > page-52.html
$ grep -n "Starter plan" page-52.html
Pick the strings that would hurt to lose: prices, phone numbers, legal lines, link targets, anything with unusual characters such as currency symbols, ampersands, percent signs or quotes. Ask the agent to list them before the push and to confirm each one after.
When an ability has no dry run, build the equivalent yourself. Write to a scratch draft and inspect it, or run the change on staging. The goal is the same: a stage where a wrong result is visible and harmless.
The dry-run loop
- Write the payloadApply the house rules you already know: class naming, colour tokens, font-size tokens.
- Dry runValidate without saving. Nothing on the site changes.
- Triage the reportFix failed checks, decide on warnings, count the suggestions and leave them alone.
- Repeat until cleanEach lap takes seconds. Stop and ask you if the same check fails three times.
- Real pushUse the preflight token tied to this post and this push mode.
- Read backFetch the stored content and compare prices, links and special characters against the source.
Read the plan before it runs
The most useful safeguard in this whole setup costs nothing: make the agent say what it intends to do before it does it, and read what it says. Approval prompts in your client are the second layer. They only work if you can read a call and know what you are agreeing to, and that skill is trainable.
Every execute call is small and structured. It names an ability and carries parameters. When you review one, run through five questions.
- Which ability? Is it the narrowest one that does the job? “Update this post” is narrower than “write this file”, which is narrower than “run this PHP”.
- Which target? Check the post ID, option name, file path or term. A correct call aimed at the wrong ID is the most common real error.
- Does it write? Reads are safe to approve in bulk. Writes are not.
- How many objects? One post, or a loop over every post? Anything that fans out needs a smaller first run.
- How would you undo it? If you cannot answer, stop and fix that before approving.
Better still, get the agent to write the plan first, as a numbered list: each step names the ability, the target, the expected change and the undo. Tell it plainly not to call the execute tool until you reply. A plan is far cheaper to correct than a half-run batch, and it exposes misunderstandings, such as the agent deciding that “tidy the About page” includes changing the slug.
Some patterns should raise your guard automatically:
- A request for broader access, such as “this would be easier if I could run PHP” or “I need an administrator account”. Treat that as a design problem to solve with a narrower ability or a sandbox file, not a permission to grant.
- Option changes to anything that controls URLs, active plugins, users or roles.
- File writes outside the sandbox directory, or any delete.
- Loops over all posts, all users or all terms.
- Parameters that include code the agent wrote, such as PHP or a SQL fragment. Read all of it, not a summary.
The plugin’s documentation describes some built-in help here. Destructive actions are gated behind a confirmation, there is an approval step in the Agent View for changes, and an audit log records every AI action locally. Features and defaults vary by version and edition, so confirm in your install what actually stops and what actually gets logged. Do not treat any of it as a substitute for reading the call yourself; the best audit log in the world records a mistake after it has happened.
Approval fatigue is real. After thirty approvals you stop reading. The cure is structural, not moral. Approve a plan once, then let reads run automatically, keep writes manual, and keep batches small enough that you can read every parameter. If you find yourself clicking through, stop the run, shrink the task and start again.
Finally, hold the agent to its own plan. If the calls it makes differ from the plan it gave you, even helpfully, stop and ask why. An agent that quietly improves on the plan will, sooner or later, improve on something you cared about.
Should you approve this call?
The abilities ladder: from read-only to execute-php
Not all abilities are equal, and the single biggest decision in your setup is how far up the ladder the agent may climb. Think of it as six rungs, each with a different worst case. The names below are the ones we used in our build; your version may expose more or fewer, so list what your site actually reports.
Rung one: read. Getting posts, meta and options. The worst case is that the agent learns things, and a poorly scoped user could expose private content to a model provider. This is where every new task starts.
Rung two: create drafts. Creating posts through the post-creation ability, as drafts. The worst case is clutter. It is the safest way to let an agent produce real output.
Rung three: change existing content and fields. Updating posts and meta. This can alter live pages and overwrite values that have no revision history. Gate it behind the read-first, keep-the-old-value habit.
Rung four: change settings. Updating options, which per the documentation is limited to an allowlist. A wrong value in an allowed option can still break layout, search visibility or caching behaviour for the whole site. It usually needs a higher-privileged user, which is itself a signal to slow down.
Rung five: files in a sandbox. Writing, reading, listing, deleting and disabling files. In our build PHP files could only be written under a dedicated sandbox directory inside wp-content, and they loaded as single-file plugins. The worst case is a site-wide fatal error, which is why a crash safe mode exists. The next section covers it.
Rung six: execute-php. Arbitrary PHP run inside WordPress. There is no ceiling on the worst case, because PHP in WordPress can read your configuration file, create administrators, write anywhere the web server can write and talk to your database directly. A mistake here is not a mistyped value; it is code.
The operating policy follows from this: start every task on the lowest rung that can do it, and step up only when the lower rungs genuinely cannot. Then step back down. Escalation should be a decision you make by changing the role of the agent’s user or creating a separate, short-lived application password for the job, not something the agent negotiates mid-conversation.
Our own experience shows why the top rung is worth fearing. execute-php was in our toolbox, and it is both powerful and risky. The site owner told us to stop using it, and we finished the build with the narrower abilities and sandbox files. The practical lesson is a conversion trick: whenever you feel the urge to run a one-off PHP snippet, ask whether it could be a small named file in the sandbox instead. A file can be read in full before it runs, diffed, kept under version control, disabled by renaming and deleted. A transient snippet leaves none of those handles.
If you do keep execute-php available, do it on a throwaway staging site with a fresh backup, a dedicated administrator account that exists only for that session, and a prompt that forbids it unless you grant it by name for a single named purpose. On production, leave it off. Whether you can switch it off per site depends on your version; check what the Connect screen and the abilities screen let you disable, and if there is a master switch, know where it is before you need it.
The abilities ladder
How to read this: each row is one option, and its dot shows where it sits between Reversible, narrow and Hard to reverse, broad. Placement is an editorial judgement, not a measurement.
- 1Read posts, meta, optionsNothing changes; exposure is the only risk.
- 2Create draftsClutter at worst; invisible to visitors.
- 3Update posts and metaLive pages change; meta has no revision history.
- 4Update optionsSite-wide effects from one value.
- 5Write sandbox filesA PHP fatal can switch off every sandbox plugin.
- 6Execute PHPArbitrary code with the reach of the web server.
Files, the sandbox and crash safe mode
The file abilities are where an agent can do the most useful work and the most visible damage. In our build they were write-file, read-file, list-directory, delete-file and disable-file, and they gave us a middle path between “no custom code” and “run arbitrary PHP”: the agent writes small PHP files, you can read them, and WordPress loads them.
The design has three rules worth knowing. PHP files can only be written under a dedicated sandbox directory inside wp-content, named nibwp-sandbox. Each file there loads as a single-file plugin, so it needs the standard plugin header comment at the top. And the system has a safety net called crash safe mode: if a PHP fatal error happens in any sandbox file, NibWP creates a marker file named .crashed, and that marker disables all sandbox plugins until it is removed. The disable-file ability is the manual version, renaming one file to end in .disabled so it stops loading.
We hit crash safe mode once, and it is a good illustration of why it exists. A file contained a stray apostrophe inside a PHP string. PHP stopped parsing at the apostrophe and threw a fatal error on the next page load. The marker appeared, every sandbox plugin switched off, and the custom front-end canvas that one of those plugins rendered disappeared from the site. The symptom looked like something mysterious had deleted our front end. It had not. One file had a typo, and the guard had done its job.
Here is the shape of the mistake and the fix, in a complete single-file plugin:
<?php
/**
* Plugin Name: Offer Label
* Description: Adds a short label before the main content.
*/
add_filter( 'the_content', function ( $content ) {
// Broken: the apostrophe ends the string early and PHP cannot parse the file.
// $label = 'Today's offer';
// Fixed: double quotes allow an apostrophe inside the string.
$label = "Today's offer";
return '<p class="offer-label">' . esc_html( $label ) . '</p>' . $content;
} );
Lint before you write. PHP can check syntax without running a file. If the agent has a shell, or you do, make a syntax check a required step before any write into the sandbox:
$ php -l offer-label.php
A clean file reports no syntax errors. A broken one reports a parse error with a line number, which is exactly what you want to see on your machine instead of on your site.
Recovery, in order. First, confirm the cause. If several things built through sandbox files vanish at once, look for the marker before you look anywhere else. The host’s PHP error log or the WordPress debug log will name the file and the line. Second, fix the file, using the same write ability that created it. Third, remove the .crashed marker, using the file tools or your host’s file manager. Fourth, reload the site and check that the sandbox plugins are back. If you remove the marker before fixing the file, you will simply crash again, and the loop will tell you nothing new.
Two habits make this cheap. Keep each sandbox plugin small and single-purpose, so a failure takes out one idea, even though the marker disables all of them. And have the agent keep the previous version of any file it overwrites, in your project folder, so a bad edit can be reverted in seconds. The delete ability is permanent, and renaming with disable-file is the gentler way to retire a file you might want back.
Remember what this protection is not. The sandbox limits where PHP files can be written. It does not review what they do. A syntactically perfect file can still redirect every visitor, expose data or slow every page, so the review-the-plan rule applies to file contents exactly as it does to any other call.
One stray apostrophe, start to finish
Sessions, timeouts and retries
Long agent runs fail in boring, mechanical ways, and the fix is a few rules about what to retry. Two of the ways are specific to how MCP over HTTP works; the third is just hosting.
Sessions. Every MCP call after the first must carry a session id from the initialize handshake. Sessions do not last forever. In our build they expired now and then, and the errors read “Session not found” or “Missing Mcp-Session-Id”. The fix is mechanical: initialise again, take the new session id, and repeat the call. Whether a chat client’s built-in connector re-initialises for you depends on the client. At times we used a small script client instead of the chat client, which gave us control over re-initialising and retrying. If your agent seems to have lost its tools mid-run, assume the session expired before you suspect anything deeper.
Timeouts. A full page push in our build took roughly 10 to 30 seconds. That is slow enough that default client or proxy timeouts can cut it short, and slow enough that a struggling host will push it over the edge. When the host was having trouble, calls timed out, and one run returned “Error establishing a database connection”. That was a host problem, not NibWP’s, but it shaped our workflow: we added retries.
The rules for retrying are not obvious, so write them into your tooling:
- Reads can be retried freely. Asking twice costs nothing.
- A session error is safe to retry for any call, because the request was rejected before anything ran. Re-initialise, then repeat it.
- A timeout on a write means the outcome is unknown, not failed. The server may have finished the write after the client gave up. Before repeating a create, read back to see whether the object exists, or you will end up with two of it.
- Cap the retries and back off. Three attempts with growing pauses is plenty. Hammering a host that is already returning database errors makes the outage longer.
Here is a compact Node client that follows those rules. It needs Node 18 or later for the built-in fetch, reads the three environment variables from the handshake section and handles both plain JSON and event-stream responses. Take the real tool and argument names from your own tools list and the ability schemas.
const url = process.env.MCP_URL;
const auth = 'Basic ' + Buffer.from(process.env.WP_USER + ':' + process.env.WP_APP_PASSWORD).toString('base64');
let sessionId = null;
let nextId = 1;
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function rpc(method, params, notify = false) {
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream',
'Authorization': auth
};
if (sessionId) headers['Mcp-Session-Id'] = sessionId;
const body = { jsonrpc: '2.0', method, params };
if (!notify) body.id = nextId++;
const res = await fetch(url, {
method: 'POST',
headers,
body: JSON.stringify(body),
signal: AbortSignal.timeout(60000)
});
const sid = res.headers.get('mcp-session-id');
if (sid) sessionId = sid;
const text = await res.text();
if (!res.ok) throw new Error(res.status + ' ' + text.slice(0, 300));
if (notify || !text) return null;
const type = res.headers.get('content-type') || '';
const json = type.includes('text/event-stream')
? JSON.parse(text.split('\n').find((line) => line.startsWith('data:')).slice(5))
: JSON.parse(text);
if (json.error) throw new Error(json.error.message);
return json.result;
}
async function start() {
sessionId = null;
await rpc('initialize', {
protocolVersion: '2025-03-26',
capabilities: {},
clientInfo: { name: 'build-script', version: '0.1' }
});
await rpc('notifications/initialized', {}, true);
}
const sessionLost = (e) => /Session not found|Missing Mcp-Session-Id/i.test(e.message);
async function call(tool, args, safeToRepeat = false) {
for (let attempt = 1; attempt <= 3; attempt++) {
try {
if (!sessionId) await start();
return await rpc('tools/call', { name: tool, arguments: args });
} catch (e) {
if (sessionLost(e)) sessionId = null;
else if (!safeToRepeat) throw e;
if (attempt === 3) throw e;
await sleep(attempt * 5000);
}
}
}
Pass safeToRepeat as true only for reads. For writes, the function retries after a lost session and otherwise gives up, leaving you to read back and decide.
Life of a session, and what to do when it ends
- InitializeThe client sends the opening request and the server returns a session id in a response header.
- ConfirmThe client sends the initialized notification so the server treats the session as ready.
- Call toolsEvery request carries the session id. A page push can take 10 to 30 seconds.
- Session lostAn error such as Session not found or Missing Mcp-Session-Id means the id is no longer valid.
- Re-initialiseStart again, take the new id, and repeat the call. It never ran, so this is safe.
- After a timeoutRead back before repeating any write. The first attempt may have landed.
Backups and rollback: know the undo path for each ability
Everything so far lowers the odds of a bad run. This section is about the day the odds fail, and the question to answer before that day is not “do I have a backup” but “how would I undo this specific change”. The answer differs by ability, and the differences are not obvious until you list them.
Start with the layers you can rely on. A full-site backup from your host covers files and database and is the last resort. A database export taken with WP-CLI immediately before a run covers every content and settings change but not files:
$ wp db export before-run.sql
Post revisions cover the content of posts and pages, so long as the post type supports them and revisions have not been disabled in the site’s configuration. Staging is a rollback environment too: a change that went wrong there costs you a restore of staging, not of the live site. Each of these has a different reach, so match the layer to the ability.
The big caveat on live sites. Restoring the database rolls back everything, including things that were not the agent’s doing. On a site that takes orders, receives comments or stores form entries, a database restore erases whatever arrived after the snapshot. This is the strongest argument for working on staging, and for choosing targeted reversals on live sites: restore one revision, write one old value back, rename one file. Reserve a full restore for emergencies, and expect to lose something when you use it.
The habit that makes targeted undo possible is read-before-write. Have the agent read each object before it changes it and save the original somewhere outside the site. The undo then becomes writing that value back, which is a single ordinary call. Meta values and options have no history of their own, so this habit is the only history they will ever get.
Practise the restore. On staging, break something small on purpose with the agent, then restore it from the backup, from a revision and from a saved original. Time each. You will discover which one you can actually do under pressure, and that knowledge is worth more than any amount of reading.
The emergency stop. If a run is going wrong, stop the agent first and investigate second. There are three levers, from lightest to heaviest. Turn off the master AI Abilities switch, which according to the documentation unregisters every ability and leaves credentials untouched. Revoke the agent’s application password, which ends its access at the WordPress layer regardless of what the plugin does. Or deactivate the plugin:
$ wp plugin deactivate nibwp
Know where the first two controls are before you need them. When a model is mid-run and your site is behaving oddly, you do not want to be hunting for a settings screen.
After any rollback, write down what failed and why. Most rollbacks trace back to one of a handful of causes: a missing read-first step, a task bigger than the plan, a loop that ran on too many objects, or a validator that passed a bad result. Each has a prompt rule that prevents it, and the next section turns those rules into a template.
Undo paths by kind of change
| How to undo it | What to do beforehand | |
|---|---|---|
| Post or page content | Restore a revision in the editor | Confirm the post type keeps revisions |
| Post meta and custom fields | Write the old value back | Read and record the value first |
| Options and settings | Write the old value back, or restore the database | Record the value and export the database |
| New posts and drafts | Trash and delete them | Create as drafts and list the IDs |
| Sandbox files | Rename to .disabled, or restore the old copy | Keep the previous file outside the site |
| Executed PHP | Only a full restore point | Fresh backup, and try a narrower ability first |
A repeatable prompt structure
A prompt cannot replace the controls in the earlier sections, but a good one makes each control easier to apply and each mistake easier to spot. The best prompt for an agent that manages a site is not clever. It is a template you reuse, with the same parts in the same order, so you notice immediately when one is missing. Seven parts cover almost everything.
- Context. Which site, which environment, which user. “Staging copy, acting as the agent user, production out of scope.”
- Goal. One sentence describing the finished state, not the method.
- Scope. The exact objects: IDs, a parent page, a post type. Plus what is explicitly out of scope.
- Allowed abilities. Name them. Name the forbidden ones too.
- Procedure. Fetch schemas, read, plan, wait for approval, write one, read back, then the rest, then verify all.
- Stop conditions. The situations where the agent must stop and ask instead of continuing.
- Report format. A table you can scan: object, field, old value, new value, status.
Here is the template filled in for an illustrative job. The numbers are an example, not a recommendation, and you should adapt the names to your abilities.
Context
Staging copy of a small business site. You act as the agent user. Production is out of scope.
Goal
Every service page has a meta description.
Scope
The 12 pages whose parent is the Services page. Do not touch any other page, option or file.
Allowed abilities
Discover, get-ability-info, get and update post, and the SEO meta abilities.
Never use execute-php or any file ability.
Procedure
1. Fetch each ability's schema before its first use.
2. Read the 12 pages. List ID, title and current description.
3. Give me the plan and the 12 proposed descriptions. Do not write anything until I approve.
4. After approval, write one page, read it back and show me. Then do the rest.
5. Read all 12 back and report any difference from the approved text.
Rules
Plain text, under 160 characters, no quotation marks. Record the old value of every field before changing it.
Stop and ask me if
a check fails twice, a session error repeats, the host returns a database error,
a page has content you did not expect, or a step needs a wider permission.
Report
A table with ID, field, old value, new value and status.
Each part exists because of a failure mode from this tutorial. Scope prevents the “tidy up everything” overreach. Naming forbidden abilities keeps the agent from reaching for execute-php when a call is awkward. The wait-for-approval line makes the plan a real checkpoint. Write one, then the rest, catches a misunderstanding on the first page instead of the twelfth. Stop conditions are what keeps a run from thrashing against a failing host or a validator rule it does not understand. And a fixed report format makes the agent’s own account comparable with the transcript.
Habits that make it work. Put the template in a file in your project, not in your head, and edit it after every incident so the lesson sticks. Give one task per prompt; a prompt that mixes content edits, settings and file changes mixes their risk too. Say “plan only” when you want the plan, because an agent that is eager to be helpful will otherwise start.
For long builds, assume the conversation will not last. Context windows fill up and sessions end. Keep a plain state file in the project, listing what is done, the IDs involved and what comes next, and have each new run read it first. Our own build, about 45 pages of it, was driven from scripts, and the same idea applies: keep the work in files you can re-run, not in a conversation. When the agent restarts, it re-reads the state and carries on, and so can you.
Review every run, and know when to stop
The run is not finished when the agent says it is. A short review routine, done every time, is what turns a risky tool into a dependable one. It takes ten minutes for a normal task, and it catches the problems that look fine in the agent’s own summary.
1. Compare the report with the transcript. The agent’s summary says what it believes it did. The transcript says which calls actually ran. Check that each write in the transcript appears in the report and that nothing ran that was not in the plan. If your install has an audit log, use it as a second source, bearing in mind what the documentation says it records may vary by version.
2. Read back what matters. Use WP-CLI, the database or wp-admin, not the agent, to look at prices, links, special characters and any field the validator cannot see. We learned this the expensive way when a defect in a save step turned stored prices into zeros.
3. Look at the public page as a visitor. Fetch it, check the status, check the title and canonical, and look at it in a browser at a phone width. Caches can show you the old version or hide a problem, so check the cache layer too. On our site, the cache plugin added a response header showing MISS on a first request and a hit on a repeat, and a request with a random, unknown query string bypassed the cache entirely, so it always returned MISS. That was a handy way to see the uncached result. Other caches behave differently, so find out how yours treats query strings first. To see the headers of a normal GET request:
$ curl -s -o /dev/null -D - "$PAGE_URL"
4. Check the logs. Look at the PHP error log or the WordPress debug log for notices and fatals that appeared during the run. A silent warning today is a white screen after the next plugin update.
5. Update your rules. Anything that surprised you belongs in the prompt template or the project notes. A review that does not change the template has wasted half its value.
Moving from staging to live. You have two real options. Replay the same scripted calls against production, after staging passed, so the change is reproducible and nothing else on the site is touched. Or use your host’s staging push, which is convenient but can overwrite live data that changed while you were on staging. Replay suits content and settings work. A host push suits a whole redesign on a site that takes no orders in the meantime. Whichever you pick, take a fresh restore point first and keep the first live run small.
When to stop. Some signals mean the run should end, however close it looks to done:
- The same validator check fails three times with the agent rewriting the payload each time. It is guessing, and you should supply the rule.
- The agent asks for a wider permission, a higher role or a way around a check.
- It makes claims about the site that it cannot back with a returned value.
- The host starts returning database errors or timeouts. Pause until it recovers.
- You catch yourself approving without reading.
Finally, remember what no setup can give you. The agent has no taste, no sense of your customers and no legal or accessibility judgement. NibWP exposes abilities; it does not decide what is good. Your review is the quality control, and the process above is there to give that review the time and the evidence to do its job.
Checklist
- Work on a staging copy that uses HTTPS, discourages indexing, sends no real email and has payment gateways in test mode.
- Create a dedicated user for the agent and start it on the Editor role.
- Take a database export and confirm that a recent full-site backup exists.
- Restore the backup once on staging and note how long it takes.
- Check the plugin listing for the current WordPress and PHP requirements before installing NibWP.
- Turn on AI Abilities and create a named application password for this client and this environment.
- Keep the application password in secret storage, never in chat, tickets or a repository.
- Run the initialize handshake by hand with curl and confirm that the tool list comes back.
- Set your client to ask before every call to the execute tool.
- Make the first prompt change nothing: list the abilities and say which ones can write.
- Verify the agent read-only claims against IDs and quoted values you check yourself.
- Create new content as drafts and publish with a separate, named instruction.
- Have the agent read and record the old value before any meta or option write.
- Run validators or dry runs until no check fails, and do not act on suggestions without asking.
- Ask for a numbered plan first and check the ability, target, write, object count and undo line for each step.
- After every write, read the stored content back and compare prices, links and special characters with a tool other than the agent.
- Lint PHP with php -l before writing into the sandbox and keep the previous version of every file you overwrite.
- Know the three stop levers: the master AI Abilities switch, revoking the application password and deactivating the plugin.
- Keep execute-php off, or enable it only on throwaway staging for one named purpose.
- After each run, check the public page, the cache layer and the error log, then update your prompt template.
Read this next
About this guide. Parts of this guide come from building and running wpresident.com; those parts are marked as such, and everything else is documentation-level guidance. Interfaces and plan limits change, so check the vendor’s current documentation before you act. Not legal, tax or financial advice. See our editorial policy.
Frequently asked questions
Do I need NibWP to connect an AI agent to WordPress?
No. WordPress 6.9 includes an Abilities API and an official MCP Adapter, and other plugins and approaches exist, including the REST API and WP-CLI. NibWP is one packaged option that registers a curated ability set, handles authentication with application passwords and adds controls around them. It is made by the publisher of WPresident, so weigh our view accordingly and compare alternatives before you commit.
Is it safe to give an agent an application password?
It is as safe as the user it belongs to. The password lets the agent do whatever that user can do, so give it a dedicated account with a narrow role, store the password in secret storage and name it per client and environment so you can revoke it alone. It cannot log in to wp-admin, but treat it like any credential: if it leaks, revoke it.
Which WordPress role should the agent user have?
Start with Editor. It can create, edit and publish content but cannot manage plugins, users or site options. If a task needs more, raise the role for that task and lower it afterwards, rather than leaving an administrator account attached to the agent. If a read-only audit is all you need, use the narrowest role that still lets the abilities you need return data.
Can the agent break my site?
Yes, in proportion to the abilities and role you give it. Content mistakes are the usual case and are recoverable through revisions or a saved original. Files and executed code are the serious ones: in our build a stray apostrophe in a sandbox PHP file triggered crash safe mode and switched off our custom front end until we fixed it. That is why staging and restore points come first.
What is the difference between a dry run and working on staging?
A dry run validates one payload without saving it, so it catches format and rule problems in seconds. Staging is a whole copy of the site where you can let a change actually happen and inspect it. They answer different questions. A dry run says "would this be accepted", and staging says "what does this do". Use both, and read back afterwards either way.
Why does my agent say Session not found?
Every MCP call after the first must carry the session id issued by the initialize request, and sessions expire. We saw "Session not found" and "Missing Mcp-Session-Id" now and then. Initialise again, take the new session id and repeat the call. Because the request was rejected before running, repeating it is safe. A small script client, like the one in the sessions section, lets you automate that step.
Should I ever enable execute-php?
Rarely, and never on production by default. It runs arbitrary PHP inside WordPress, so one mistake can reach files, users and the database. In our build the site owner told us to stop using it, and we finished with narrower abilities and sandbox files. If you must use it, do so on throwaway staging with a fresh backup and one named purpose.
Does this work with page builders and other plugins?
It depends on which abilities your install exposes. In our build we used NibWP tools for Etch components, Automatic.css variables and Slim SEO meta tags, alongside the generic post, meta, option and file abilities. The plugin documentation also describes broader integrations in its paid edition. Check the current list for your version, and treat any integration as another set of abilities to review.
How do I stop an agent that is mid-run?
Stop it in the client first, then cut access at the site. In order of strength: turn off the master AI Abilities switch, revoke the agent application password, or deactivate the plugin with WP-CLI. Then check what ran, using the transcript and any audit log, and restore what you need from revisions, saved originals or your backup. Know where these controls are before you start a run, because hunting for them mid-incident costs minutes you do not have.
What data does the agent see, and where does it go?
Whatever the connected user can read, and it passes through your AI client to the model provider you chose. Scope the user so private content the agent does not need is out of reach, and read your provider terms and any privacy obligations that apply to you. Customer data and personal data deserve extra thought before any agent reads them. This article is general orientation, not legal advice.
How long does a push take, and what should I do about timeouts?
In our build a full page push took roughly 10 to 30 seconds, and calls timed out when the host was struggling. Set client timeouts above that, retry reads freely, retry a write only after reading back to see whether the first attempt landed, and stop if the host keeps returning database errors. Your numbers will depend on your hosting.
Can I run this directly on production?
Not at first. Prove the workflow on staging, with a tested restore point, then either replay the same scripted calls on production or use your host push, with a fresh backup and a small first run. On production prefer targeted undo, such as one revision or one old value, over a full database restore that could erase orders and comments.



