Skip to main content
Glama
README.md
# Nxt WP-MCP

[![Version](https://img.shields.io/badge/version-1.0.0-blue)](https://github.com/pbmagnet4/nxt-wp-mcp)
[![License](https://img.shields.io/badge/license-GPLv2%20or%20later-green)](https://www.gnu.org/licenses/gpl-2.0.html)
[![WordPress](https://img.shields-78?style=flat&logo=wordpress&label=WP&color=005272&logoColor=white)](https://wordpress.org/)
[![WebMCP](https://img.shields.io/badge/WebMCP-Enabled-purple)](https://webmachinelearning.github.io/webmcp/)

WordPress plugin implementing **WebMCP** (Web Model Context Protocol) — allows AI agents running in the browser to interact with your WordPress site through `document.modelContext.registerTool()` browser-native MCP tools.

## What is WebMCP?

WebMCP is a W3C Community Group specification that brings MCP (Model Context Protocol) to the browser. It allows web pages to register **JavaScript-based tools** that AI agents can invoke — all running client-side with the visitor's own context. Tools are registered via `document.modelContext.registerTool()` and can interact with the WordPress REST API, page DOM, and other browser APIs.

**Spec:** https://webmachinelearning.github.io/webmcp/  
**Chrome docs:** https://developer.chrome.com/docs/ai/webmcp

## How It Works

1. **Install** the plugin on any WordPress site
2. **Visitors** with a WebMCP-enabled browser (Chrome origin trial, Claude desktop, ChatGPT browser) can engage with the site via AI agents
3. The plugin registers MCP tools that let agents:
   - Read and search your posts, pages, and media
   - Get complete site structure and navigation
   - (Optionally) create, edit, or delete content
   - Access user data, taxonomies, comments
4. Agents can **navigate** between posts/pages using permalinks
5. Agents can **engage** by creating comments or (if enabled) editing content

## Features

- **23+ MCP tools** covering posts, pages, media, taxonomies, users, comments, categories, tags, site info, navigation, and search
- **Permission-gated**: each capability (create, edit, delete, users) can be toggled independently
- **WordPress-native**: uses the WordPress REST API v2 with nonce authentication
- **Gutenberg block**: add the WebMCP Visitor Widget to any page
- **Responsive UI**: floating chat container with dark/light mode support
- **WP-CLI support**: manage settings from the command line
- **Origin isolation**: automatically sends COOP/COEP headers required by WebMCP

## Installation

### From GitHub
```bash
# Clone and build the plugin
git clone https://github.com/pbmagnet4/nxt-wp-mcp.git
cd nxt-wp-mcp

# Install JS dependencies and build assets
npm install && npm run build

# Zip for WordPress upload
npm run zip
```

### WordPress Upload
1. Download `nxt-wp-mcp.zip`
2. Go to **Plugins → Add New → Upload Plugin** in WordPress
3. Upload and activate
4. Go to **Settings → WebMCP** to configure permissions and UI
5. Add the "WebMCP Visitor Widget" block to any page, or enable the global widget

## Tools Available (23+)

| Category | Tools |
|---|---|
| Site Info | `wp_get_site_info`, `wp_get_navigation`, `wp_get_sitemap` |
| Search | `wp_search`, `wp_get_related_posts` |
| Posts | `wp_list_posts`, `wp_get_post`, `wp_create_post`, `wp_update_post`, `wp_delete_post` |
| Pages | `wp_list_pages`, `wp_get_page`, `wp_create_page`, `wp_update_page`, `wp_delete_page` |
| Media | `wp_list_media`, `wp_get_media`, `wp_delete_media` |
| Taxonomies | `wp_list_categories`, `wp_get_category`, `wp_create_category`, `wp_update_category`, `wp_delete_category` |
| Tags | `wp_list_tags`, `wp_get_tag`, `wp_create_tag`, `wp_update_tag`, `wp_delete_tag` |
| Users | `wp_list_users`, `wp_get_user` |
| Comments | `wp_list_comments`, `wp_get_comment`, `wp_create_comment`, `wp_update_comment`, `wp_delete_comment` |

## Configuration

Visit **Settings → WebMCP** to configure:

- **Enable/Disable** the plugin globally
- **Permission toggles** for each capability (create, edit, delete, users, tax, comments, plugins, themes, settings)
- **Widget UI** settings (position, width, collapsibility, default open state)
- **Content limits** (max posts, pages, media exposed)

## WP-CLI Commands

```bash
wp webmcp status              # Show plugin status and settings
wp webmcp enable              # Enable the plugin
wp webmcp disable             # Disable the plugin
wp webmcp set allow_create 1  # Enable post creation
wp webmcp set allow_users 0   # Disable user access
```

## Development

```bash
# Install dependencies
npm install

# Build assets
npm run build

# Watch mode for development
npm run dev
```

### Build output
- `dist/webmcp.js` — frontend tool registration and chat widget
- `dist/blocks.js` — Gutenberg block editor script
- `dist/manifest.php` — PHP asset manifest for cache-busting

## Requirements

- WordPress 6.5+
- PHP 8.1+
- HTTPS recommended (WebMCP requires SecureContext)
- Chrome 149+ or origin trial support for `document.modelContext`

## License

GPLv2 or later — see [LICENSE](LICENSE).