GitHub - drewnyc/wp-mcp-adapter: An MCP adapter that bridges the Abilities API to the Model Context Protocol, enabling MCP clients to discover and invoke WordPress plugin, theme, and core abilities programmatically. · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Star1 (1)You must be signed in to star a repository
About
An MCP adapter that bridges the Abilities API to the Model Context Protocol, enabling MCP clients to discover and invoke WordPress plugin, theme, and core abilities programmatically.
The official WordPress package for MCP integration that exposes WordPress abilities as Model Context Protocol (MCP) tools, resources, and prompts for AI agents.
Overview
This adapter bridges WordPress's Abilities API with the MCP specification, providing a standardized way for AI agents to interact with WordPress functionality. It includes HTTP and STDIO transport support, comprehensive error handling, and an extensible architecture for custom integrations.
Features
Core Functionality
Ability-to-MCP Conversion: Automatically converts WordPress abilities into MCP tools, resources, and prompts
Multi-Server Management: Create and manage multiple MCP servers with unique configurations
This will automatically install both the WordPress Abilities API and MCP Adapter as dependencies in your project.
Using Jetpack Autoloader (Highly Recommended)
When multiple plugins use the MCP Adapter, it's highly recommended to use the Jetpack Autoloader to prevent version conflicts. The Jetpack Autoloader ensures that only the latest version of shared packages is loaded, eliminating conflicts when different plugins use different versions of the same dependency.
Add the Jetpack Autoloader to your project:
composer require automattic/jetpack-autoloader
Then load it in your main plugin file instead of the standard Composer autoloader:
<?php// Load the Jetpack autoloader instead of vendor/autoload.phprequire_onceplugin_dir_path( __FILE__ ) . 'vendor/autoload_packages.php';
Benefits of using Jetpack Autoloader:
Version Conflict Resolution: Automatically loads the latest version of shared packages
Plugin Compatibility: Prevents errors when multiple plugins use different versions of MCP Adapter
WordPress Optimized: Designed specifically for WordPress plugin development
Automatic Management: No manual intervention needed when plugins update their dependencies
As a Plugin (Alternative Method)
Alternatively, you can install the MCP Adapter as a traditional WordPress plugin, though the Composer package method is preferred for most use cases.
The MCP Adapter automatically creates a default server that exposes all registered WordPress abilities through a layered architecture. This provides immediate MCP functionality without requiring manual server configuration.
How it works:
All WordPress abilities registered via wp_register_ability() are automatically available
The default server supports both HTTP and STDIO transports with MCP 2025-06-18 compliance
Abilities are exposed as tools, resources, or prompts based on their characteristics
Built-in error handling and observability are included
Access via HTTP: /wp-json/mcp/mcp-adapter-default-server
Access via STDIO: wp mcp-adapter serve --server=mcp-adapter-default-server
The MCP Adapter supports multiple connection methods. Here are examples for connecting with MCP clients:
STDIO Transport (Testing Only)
For testing purposes only, you can interact directly with MCP servers using WP-CLI commands:
# List all available MCP servers
wp mcp-adapter list
# Test the discover abilities tool to see all available WordPress abilitiesecho'{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"mcp-adapter-discover-abilities","arguments":{}}}'| wp mcp-adapter serve --user=admin --server=mcp-adapter-default-server
# Test listing available toolsecho'{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'| wp mcp-adapter serve --user=admin --server=mcp-adapter-default-server
MCP Client Configuration
Configure MCP clients (Claude Desktop, Claude Code, VS Code, Cursor, etc.) to connect to your WordPress MCP servers:
STDIO Transport Configuration for local sites (click to expand)
For advanced use cases, you can create custom MCP servers with specific configurations:
add_action('mcp_adapter_init', function($adapter) {
$adapter->create_server(
'my-server-id', // Unique server identifier'my-namespace', // REST API namespace'mcp', // REST API route'My MCP Server', // Server name'Description of my server', // Server description'v1.0.0', // Server version
[ // Transport methods
\WP\MCP\Transport\HttpTransport::class, // Recommended: MCP 2025-06-18 compliant
],
\WP\MCP\Infrastructure\ErrorHandling\ErrorLogMcpErrorHandler::class, // Error handler
\WP\MCP\Infrastructure\Observability\NullMcpObservabilityHandler::class, // Observability handler
['my-plugin/my-ability'], // Abilities to expose as tools
[], // Resources (optional)
[], // Prompts (optional)
);
});
Custom Transport Implementation
The MCP Adapter includes production-ready HTTP transports. For specialized requirements like custom authentication, message queues, or enterprise integrations, you can create custom transport protocols.
The MCP Adapter supports custom authentication logic through transport permission callbacks. Instead of the default is_user_logged_in() check, you can implement custom authentication for your MCP servers.
The MCP Adapter includes a default WordPress-compatible error handler, but you can implement custom error handling to integrate with existing logging systems, monitoring tools, or meet specific requirements.
The MCP Adapter includes built-in observability for tracking metrics and events. You can implement custom observability handlers to integrate with monitoring systems, analytics platforms, or performance tracking tools.
See the Observability Guide for detailed metrics tracking and custom handler implementation.
An MCP adapter that bridges the Abilities API to the Model Context Protocol, enabling MCP clients to discover and invoke WordPress plugin, theme, and core abilities programmatically.