Make your WordPress site into a simple MCP server, exposing functionality to LLMs and AI agents.
A comprehensive WordPress plugin that implements the Model Context Protocol (MCP) to expose WordPress functionality through standardized interfaces. This plugin enables AI models and applications to interact with WordPress sites securely using multiple transport protocols and enterprise-grade authentication.
The plugin implements a dual transport architecture:
WordPress MCP Plugin
โโโ Transport Layer
โ โโโ McpStdioTransport (/wp/v2/wpmcp)
โ โโโ McpStreamableTransport (/wp/v2/wpmcp/streamable)
โโโ Authentication
โ โโโ JWT Authentication System
โโโ Method Handlers
โ โโโ Tools, Resources, Prompts
โ โโโ System & Initialization
โโโ Admin Interface
โโโ React-based Token Management
Protocol | Endpoint | Format | Authentication | Use Case |
---|---|---|---|---|
STDIO | /wp/v2/wpmcp |
WordPress-style | JWT + App Passwords | Legacy compatibility |
Streamable | /wp/v2/wpmcp/streamable |
JSON-RPC 2.0 | JWT only | Modern AI clients |
wordpress-mcp.zip
from releases/wp-content/plugins/wordpress-mcp
directorySettings > WordPress MCP
to configurecd wp-content/plugins/
git clone https://github.com/Automattic/wordpress-mcp.git
cd wordpress-mcp
composer install --no-dev
npm install && npm run build
Settings > WordPress MCP > Authentication Tokens
Add to your Claude Desktop claude_desktop_config.json
:
{
"mcpServers": {
"wordpress-mcp": {
"command": "npx",
"args": [ "-y", "@automattic/mcp-wordpress-remote@latest" ],
"env": {
"WP_API_URL": "https://your-site.com/",
"JWT_TOKEN": "your-jwt-token-here",
"LOG_FILE": "optional-path-to-log-file"
}
}
}
}
{
"mcpServers": {
"wordpress-mcp": {
"command": "npx",
"args": [ "-y", "@automattic/mcp-wordpress-remote@latest" ],
"env": {
"WP_API_URL": "https://your-site.com/",
"WP_API_USERNAME": "your-username",
"WP_API_PASSWORD": "your-application-password",
"LOG_FILE": "optional-path-to-log-file"
}
}
}
}
Add to your VS Code MCP settings:
{
"servers": {
"wordpress-mcp": {
"type": "http",
"url": "https://your-site.com/wp-json/wp/v2/wpmcp/streamable",
"headers": {
"Authorization": "Bearer your-jwt-token-here"
}
}
}
}
# Using JWT Token with proxy
npx @modelcontextprotocol/inspector \
-e WP_API_URL=https://your-site.com/ \
-e JWT_TOKEN=your-jwt-token-here \
npx @automattic/mcp-wordpress-remote@latest
# Using Application Password with proxy
npx @modelcontextprotocol/inspector \
-e WP_API_URL=https://your-site.com/ \
-e WP_API_USERNAME=your-username \
-e WP_API_PASSWORD=your-application-password \
npx @automattic/mcp-wordpress-remote@latest
{
"mcpServers": {
"wordpress-local": {
"command": "node",
"args": [ "/path/to/mcp-wordpress-remote/dist/proxy.js" ],
"env": {
"WP_API_URL": "http://localhost:8080/",
"JWT_TOKEN": "your-local-jwt-token",
"LOG_FILE": "optional-path-to-log-file"
}
}
}
}
This plugin works seamlessly with MCP-compatible clients in two ways:
Via Proxy:
Direct Streamable Transport:
/wp/v2/wpmcp/streamable
The streamable transport provides a direct JSON-RPC 2.0 compliant endpoint, while the proxy offers additional features like WooCommerce integration, enhanced logging, and compatibility with legacy authentication methods.
Method | Description | Transport Support |
---|---|---|
initialize |
Initialize MCP session | Both |
tools/list |
List available tools | Both |
tools/call |
Execute a tool | Both |
resources/list |
List available resources | Both |
resources/read |
Read resource content | Both |
prompts/list |
List available prompts | Both |
prompts/get |
Get prompt template | Both |
โ ๏ธ EXPERIMENTAL FEATURE: This functionality is experimental and may change or be removed in future versions.
When enabled via Settings > WordPress MCP > Enable REST API CRUD Tools
, the plugin provides three powerful generic tools that can interact with any WordPress REST API endpoint:
Tool Name | Description | Type |
---|---|---|
list_api_functions |
Discover all available WordPress REST API endpoints | Read |
get_function_details |
Get detailed metadata for specific endpoint/method | Read |
run_api_function |
Execute any REST API function with CRUD operations | Action |
list_api_functions
to see all available endpointsget_function_details
to understand required parametersrun_api_function
to perform CRUD operationswp-content/plugins/wordpress-mcp/
โโโ includes/ # PHP classes
โ โโโ Core/ # Transport and core logic
โ โโโ Auth/ # JWT authentication
โ โโโ Tools/ # MCP tools
โ โโโ Resources/ # MCP resources
โ โโโ Prompts/ # MCP prompts
โ โโโ Admin/ # Settings interface
โโโ src/ # React components
โ โโโ settings/ # Admin UI components
โโโ tests/ # Test suite
โ โโโ phpunit/ # PHPUnit tests
โโโ docs/ # Documentation
You can extend the MCP functionality by adding custom tools through your own plugins or themes. Create a new tool class in your plugin or theme:
<?php
declare(strict_types=1);
namespace Automattic\WordpressMcp\Tools;
class MyCustomTool {
public function register(): void {
add_action('wp_mcp_register_tools', [$this, 'register_tool']);
}
public function register_tool(): void {
WPMCP()->register_tool([
'name' => 'my_custom_tool',
'description' => 'My custom tool description',
'inputSchema' => [
'type' => 'object',
'properties' => [
'param1' => ['type' => 'string', 'description' => 'Parameter 1']
],
'required' => ['param1']
],
'callback' => [$this, 'execute'],
]);
}
public function execute(array $args): array {
// Your tool logic here
return ['result' => 'success'];
}
}
You can extend the MCP functionality by adding custom resources through your own plugins or themes. Create a new resource class in your plugin or theme:
<?php
declare(strict_types=1);
namespace Automattic\WordpressMcp\Resources;
class MyCustomResource {
public function register(): void {
add_action('wp_mcp_register_resources', [$this, 'register_resource']);
}
public function register_resource(): void {
WPMCP()->register_resource([
'uri' => 'custom://my-resource',
'name' => 'My Custom Resource',
'description' => 'Custom resource description',
'mimeType' => 'application/json',
'callback' => [$this, 'get_content'],
]);
}
public function get_content(): array {
return ['contents' => [/* resource data */]];
}
}
Run the comprehensive test suite:
# Run all tests
vendor/bin/phpunit
# Run specific test suites
vendor/bin/phpunit tests/phpunit/McpStdioTransportTest.php
vendor/bin/phpunit tests/phpunit/McpStreamableTransportTest.php
vendor/bin/phpunit tests/phpunit/JwtAuthTest.php
# Run with coverage
vendor/bin/phpunit --coverage-html coverage/
# Development build
npm run dev
# Production build
npm run build
# Watch mode
npm run start
The plugin includes extensive testing:
View detailed testing documentation in tests/README.md
.
// wp-config.php
define('WPMCP_JWT_SECRET_KEY', 'your-secret-key');
define('WPMCP_DEBUG', true); // Enable debug logging
Access via Settings > WordPress MCP
:
The plugin provides granular control over CRUD operations:
โ ๏ธ Security Note: Delete operations can permanently remove data. Only enable delete tools if you trust all users with MCP access.
We welcome contributions! Please see our Contributing Guidelines.
composer install
for PHP dependenciesnpm install
for JavaScript dependenciesvendor/bin/phpunit
For support and questions:
This project is licensed under the GPL v2 or later.
Built with โค๏ธ by Automattic for the WordPress and AI communities.