wordpress-mcp

wordpress-mcp

3.6

If you are the rightful owner of wordpress-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A WordPress plugin that implements the Model Context Protocol (MCP) to expose WordPress functionality through a standardized interface.

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:

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

Transport Protocols

ProtocolEndpointFormatAuthenticationUse Case
STDIO/wp/v2/wpmcpWordPress-styleJWT + App PasswordsLegacy compatibility
Streamable/wp/v2/wpmcp/streamableJSON-RPC 2.0JWT onlyModern AI clients

๐Ÿš€ Installation

Quick Install

  1. Download wordpress-mcp.zip from releases
  2. Upload to /wp-content/plugins/wordpress-mcp directory
  3. Activate through WordPress admin 'Plugins' menu
  4. Navigate to Settings > WordPress MCP to configure

Composer Install (Development)

cd wp-content/plugins/
git clone https://github.com/Automattic/wordpress-mcp.git
cd wordpress-mcp
composer install --no-dev
npm install && npm run build

๐Ÿ” Authentication Setup

JWT Token Generation

  1. Go to Settings > WordPress MCP > Authentication Tokens
  2. Select token duration (1-24 hours)
  3. Click "Generate New Token"
  4. Copy the token for use in your MCP client

MCP Client Configuration

Claude Desktop Configuration using mcp-wordpress-remote proxy

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"
			}
		}
	}
}
Using Application Passwords (Alternative)
{
	"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"
			}
		}
	}
}
VS Code MCP Extension (Direct Streamable Transport)

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"
			}
		}
	}
}
MCP Inspector (Development/Testing)
# 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
Local Development Configuration
{
	"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"
			}
		}
	}
}

๐ŸŽฏ Usage

With MCP Clients

This plugin works seamlessly with MCP-compatible clients in two ways:

Via Proxy:

  • mcp-wordpress-remote - Official MCP client with enhanced features
  • 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

MethodDescriptionTransport Support
initializeInitialize MCP sessionBoth
tools/listList available toolsBoth
tools/callExecute a toolBoth
resources/listList available resourcesBoth
resources/readRead resource contentBoth
prompts/listList available promptsBoth
prompts/getGet prompt templateBoth

๐Ÿงช 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 NameDescriptionType
list_api_functionsDiscover all available WordPress REST API endpointsRead
get_function_detailsGet detailed metadata for specific endpoint/methodRead
run_api_functionExecute any REST API function with CRUD operationsAction
Usage Workflow
  1. Discovery: Use list_api_functions to see all available endpoints
  2. Inspection: Use get_function_details to understand required parameters
  3. 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:
    • Enable Create Tools (POST operations)
    • Enable Update Tools (PATCH/PUT operations)
    • Enable Delete Tools (DELETE operations)
  • Automatic Filtering: Excludes sensitive endpoints (JWT auth, oembed, autosaves, revisions)
Benefits
  • Universal Access: Works with any WordPress REST API endpoint, including custom post types and third-party plugins
  • AI-Friendly: Provides discovery and introspection capabilities for AI agents
  • Standards Compliant: Uses standard HTTP methods (GET, POST, PATCH, DELETE)
  • Permission Safe: Inherits WordPress user capabilities and respects endpoint permissions

๐Ÿ”ง Development

Project Structure

wp-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

Adding Custom Tools

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:

# 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/

Building Frontend

# Development build
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
  • Performance Testing: Load and stress testing

View detailed testing documentation in .

๐Ÿ”ง Configuration

Environment Variables

// wp-config.php
define('WPMCP_JWT_SECRET_KEY', 'your-secret-key');
define('WPMCP_DEBUG', true); // Enable debug logging

Plugin Settings

Access via Settings > WordPress MCP:

  • Enable/Disable MCP: Toggle plugin functionality
  • Transport Configuration: Configure STDIO/Streamable transports
  • Feature Toggles: Enable/disable specific tools and resources
  • CRUD Operation Controls: Granular control over create, update, and delete operations
  • Experimental Features: Enable REST API CRUD Tools (experimental functionality)
  • Authentication Settings: JWT token management
CRUD Operation Settings

The plugin provides granular control over CRUD operations:

  • Enable Create Tools: Allow POST operations via MCP tools
  • Enable Update Tools: Allow PATCH/PUT operations via MCP tools
  • Enable Delete Tools: โš ๏ธ Allow DELETE operations via MCP tools (use with caution)
  • Enable REST API CRUD Tools: ๐Ÿงช Enable experimental generic REST API access tools

โš ๏ธ Security Note: Delete operations can permanently remove data. Only enable delete tools if you trust all users with MCP access.

๐Ÿค Contributing

We welcome contributions! Please see our .

Development Setup

  1. Clone the repository
  2. Run composer install for PHP dependencies
  3. Run npm install for JavaScript dependencies
  4. Set up WordPress test environment
  5. Run tests with vendor/bin/phpunit

๐Ÿ“š Documentation

  • API Reference:
  • Architecture Guide:
  • Security Guide:
  • Testing Guide:

๐Ÿ†˜ Support

For support and questions:

  • ๐Ÿ“– Documentation:
  • ๐Ÿ› Bug Reports: GitHub Issues
  • ๐Ÿ’ฌ Discussions: GitHub Discussions
  • โœ‰๏ธ Contact: Reach out to the maintainers

๐Ÿ“„ License

This project is licensed under the .


Built with โค๏ธ by Automattic for the WordPress and AI communities.