=== Agent Guard ===
Contributors: rileycraig
Tags: ai, mcp, audit log, undo, abilities api
Requires at least: 6.9
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

See every action an AI agent takes on your site through the Abilities API and MCP, and undo its content changes with one click.

== Description ==

WordPress 6.9 added the Abilities API, and the official MCP Adapter lets AI assistants such as Claude, ChatGPT, Cursor and others use those abilities to read and change your site. Agent Guard records what they do and lets you take it back.

**Activity log**

Every ability execution is recorded under **Tools → Agent Guard**:

* who ran it (the WordPress user) and through which client (the MCP client name and version, the Application Password name, or the browser/User-Agent),
* the channel: MCP, REST API, WP-CLI, cron, wp-admin or PHP,
* the ability, the input it was given and the result it returned,
* when it ran and how long it took,
* attempts that were refused because the user lacked permission.

Filter the log by ability, user, channel, status and date, or search it. Values whose keys look like passwords, tokens or API keys are stored as `[redacted]`.

**One-click undo**

Before an ability changes anything, Agent Guard takes a snapshot of what it is about to touch:

* posts and pages (title, content, status and other fields), including newly created and permanently deleted ones,
* post, user, term and comment meta,
* tags, categories and other terms assigned to a post,
* site options.

Press **Undo** on a log entry and everything goes back to how it was before that action. If someone edited the same item after the AI did, Agent Guard warns you first and asks before overwriting the later edit. Undo needs the `manage_options` capability and is protected by a nonce.

**Connect Claude / ChatGPT**

A help screen walks you through connecting an AI client to your site with the official [MCP Adapter](https://github.com/WordPress/mcp-adapter) and an Application Password. It has copy-ready settings for desktop and command-line clients, explains what the browser versions of Claude and ChatGPT need, and lists fixes for common errors.

**What it does not do**

Agent Guard does not run abilities itself, does not add any abilities, and does not block or hold AI actions for approval. It records and undoes.

== Installation ==

1. Make sure your site runs WordPress 6.9 or newer.
2. Install and activate Agent Guard from **Plugins → Add New**, or upload the zip.
3. Install the [MCP Adapter](https://github.com/WordPress/mcp-adapter) if you want AI clients such as Claude or ChatGPT to connect. **Tools → Agent Guard → Connect Claude / ChatGPT** explains the steps.
4. Use your AI assistant as usual. Its actions appear under **Tools → Agent Guard**.

== Frequently Asked Questions ==

= Which AI tools does this work with? =

Any client that runs WordPress abilities: MCP clients connected through the MCP Adapter (Claude Desktop, Claude Code, Cursor, VS Code and others, plus the claude.ai and ChatGPT web apps when your site offers them an OAuth sign-in), direct calls to the Abilities REST API (`/wp-json/wp-abilities/v1/`), WP-CLI, and PHP code calling `wp_get_ability()->execute()`.

= Does it log AI changes made outside the Abilities API? =

No. If a tool edits your site through the regular REST API (for example `/wp/v2/posts`) or by logging in as a user, it is not an ability execution and is not recorded.

= What can't be undone? =

Undo covers posts, pages, meta, post terms and options. Changes to files, uploaded media files, users, comments themselves, and data in custom tables are recorded in the log but cannot be restored automatically. Each entry shows which items it can restore.

= Who can see the log and undo actions? =

Only users with the `manage_options` capability (administrators by default).

= How long are entries kept? =

30 days by default. You can change it from 1 to 365 days under **Settings** on the Agent Guard screen. Old entries are removed once a day.

= Does it slow my site down? =

It only does work while an ability is running, which is when an AI agent or other caller asks for it. Normal page views are not affected.

== Privacy ==

Agent Guard does not send any data anywhere. It makes no external requests, loads no remote scripts or fonts, and has no tracking.

The log is stored in your own database (table `{prefix}agent_guard_log`). Each entry contains the WordPress user ID, the client name it reported (MCP client name, Application Password name or User-Agent), the ability input and result, and snapshots of the content it changed, which may include personal data that was in that content. Entries are deleted after the retention period. Deleting the plugin removes the table and its settings.

== Screenshots ==

1. The activity log with filters and undo buttons.
2. A log entry with the input, result and the items that can be restored.
3. The Connect Claude / ChatGPT help screen.

== Changelog ==

= 0.1.0 =
* First release: activity log for ability executions (MCP, REST, WP-CLI, PHP), one-click undo for posts, pages, meta, terms and options, and a guide for connecting AI clients through the MCP Adapter.

== Upgrade Notice ==

= 0.1.0 =
First release.
