What is 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. It features dual transport protocols, JWT authentication, an admin interface, AI-friendly APIs, extensible architecture, and comprehensive testing.
Documentation
WordPress MCP
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.
Features
Dual Transport Protocols: STDIO and HTTP-based (Streamable) transports
JWT Authentication: Secure token-based authentication with management UI
Admin Interface: React-based token management and settings dashboard
AI-Friendly APIs: JSON-RPC 2.0 compliant endpoints for AI integration
Extensible Architecture: Custom tools, resources, and prompts support
WordPress Feature API: Adapter for standardized WordPress functionality
Experimental REST API CRUD Tools: Generic tools for any WordPress REST API endpoint
Comprehensive Testing: 200+ test cases covering all protocols and authentication
High Performance: Optimized routing and caching mechanisms
Enterprise Security: Multi-layer authentication and audit logging
Architecture
The plugin implements a dual transport architecture:
Claude Desktop with proxy configuration for full WordPress and WooCommerce support
Any MCP client using the STDIO transport protocol
Direct Streamable Transport:
VS Code MCP Extension connecting directly to /wp/v2/wpmcp/streamable
Custom HTTP-based MCP implementations using JSON-RPC 2.0
Any client supporting HTTP transport with JWT authentication
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.
Available MCP 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 REST API CRUD Tools
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:
Available Tools
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
Usage Workflow
Discovery: Use list_api_functions to see all available endpoints
Inspection: Use get_function_details to understand required parameters
Execution: Use run_api_function to perform CRUD operations
Security & Permissions
User Capabilities: All operations respect current user permissions
Settings Control: Individual CRUD operations can be disabled in settings:
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'];
}
}
Adding Custom Resources
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 */]];
}
}
Testing
Run the comprehensive test suite:
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/
Building Frontend
npm run dev
# Production build
npm run build
# Watch mode
npm run start
Security# Best Practices
Token Management: Use shortest expiration time needed (1-24 hours)
User Permissions: Tokens inherit user capabilities
Secure Storage: Never commit tokens to repositories
Regular Cleanup: Revoke unused tokens promptly
Access Control: Streamable transport requires admin privileges
CRUD Operations: Only enable create/update/delete tools when necessary
Experimental Features: Use REST API CRUD tools with caution in production environments
Security Features
JWT signature validation
Token expiration and revocation
User capability inheritance
Secure secret key generation
Audit logging for security events
Protection against malformed requests
Testing Coverage
The plugin includes extensive testing:
Transport Testing: Both STDIO and Streamable protocols
Authentication Testing: JWT generation, validation, and revocation
Integration Testing: Cross-transport comparison
Security Testing: Edge cases and malformed requests