WordPress MCP (Model Context Protocol) is a WordPress plugin developed by Automattic, designed to transform a WordPress site into a simple MCP server. It exposes site functionality through the WordPress REST API, enabling interaction with large language models (LLMs) and AI agents. This project allows developers to leverage AI tools for automating tasks such as content management, user operations, and site configuration, thereby enhancing development efficiency and integration capabilities.
MCP Server Support:
/wp/v2/wpmcp
and /wp/v2/wpmcp/streamable
), supporting interaction between AI agents and WordPress.McpStdioTransport
(standard input/output) and McpStreamableTransport
(streaming, suitable for SSE or other streaming protocols).Authentication Mechanism:
Method Handlers:
Admin Interface:
Compatibility with MCP Clients:
mcp-wordpress-remote
) without requiring persistent open connections.tests/README.md
) and contribution guidelines, encouraging community participation in development.The core architecture of the project includes the following modules:
Transport Layer:
McpStdioTransport
: Handles MCP requests through standard input/output, suitable for local development.McpStreamableTransport
: Supports streaming, ideal for real-time interaction scenarios (currently, some clients may not support it).Authentication System:
WPMCP_JWT_SECRET_KEY
in wp-config.php
.Method Handlers:
Admin Interface:
Clone the Repository:
cd wp-content/plugins/
git clone https://github.com/Automattic/wordpress-mcp.git
cd wordpress-mcp
Install Dependencies:
composer install --no-dev
npm install && npm run build
Activate the Plugin:
Configure MCP Features:
Configure JWT Key:
Add the following to wp-config.php
:
define('WPMCP_JWT_SECRET_KEY', 'your-secret-key');
define('WPMCP_DEBUG', true); // Enable debug logging
Install Remote Client (Optional):
mcp-wordpress-remote
, install using the following command:npx @modelcontextprotocol/inspector \
-e WP_API_URL=https://your-site.com/ \
-e JWT_TOKEN=your-jwt-token-here \
npx @automattic/mcp-wordpress-remote@latest
WPMCP_JWT_SECRET_KEY
is stored securely.WPMCP_DEBUG
records debug logs, facilitating troubleshooting.mcp-wordpress-remote
to achieve full functionality.The WordPress MCP project is suitable for the following scenarios:
Automated Content Management:
Development and Testing:
Site Management:
AI-Driven Customization:
Developers can extend plugin functionality through the following steps:
Create a Tool File:
wp-content/plugins/wordpress-mcp/includes/Tools/
directory.<?php
namespace WPMCP\Tools;
class CustomTool {
public function execute($params) {
// Implement custom logic
return ['success' => true, 'data' => 'Custom tool executed'];
}
}
Register the Tool:
Refer to Existing Implementations:
includes/Tools/
, includes/Resources/
, and includes/Prompts/
directories.tests/README.md
to understand the testing process and ensure code quality.