This repository was archived by the owner on Jan 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathwordpress-mcp.php
More file actions
86 lines (71 loc) · 2.42 KB
/
wordpress-mcp.php
File metadata and controls
86 lines (71 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Plugin name: WordPress MCP
* Description: A plugin to integrate WordPress with Model Context Protocol (MCP), providing AI-accessible interfaces to WordPress data and functionality through standardized tools, resources, and prompts. Enables AI assistants to interact with posts, users, site settings, and WooCommerce data.
* Version: 0.2.5
* Requires at least: 6.4
* Requires PHP: 8.0
* Author: Automattic AI, Ovidiu Galatan <ovidiu.galatan@a8c.com>
* Author URI: https://automattic.com
* License: GPL-2.0-or-later
* License URI: https://spdx.org/licenses/GPL-2.0-or-later.html
* Text Domain: wordpress-mcp
* Domain Path: /languages
*
* @package WordPress MCP
*/
declare(strict_types=1);
use Automattic\WordpressMcp\Core\McpStreamableTransport;
use Automattic\WordpressMcp\Core\WpMcp;
use Automattic\WordpressMcp\Core\McpStdioTransport;
use Automattic\WordpressMcp\Admin\Settings;
use Automattic\WordpressMcp\Auth\JwtAuth;
use Automattic\WordpressMcp\Cli\ValidateToolsCommand;
define( 'WORDPRESS_MCP_VERSION', '0.2.5' );
define( 'WORDPRESS_MCP_PATH', plugin_dir_path( __FILE__ ) );
define( 'WORDPRESS_MCP_URL', plugin_dir_url( __FILE__ ) );
// Check if Composer autoloader exists.
if ( ! file_exists( WORDPRESS_MCP_PATH . 'vendor/autoload.php' ) ) {
wp_die(
sprintf(
'Please run <code>composer install</code> in the plugin directory: <code>%s</code>',
esc_html( WORDPRESS_MCP_PATH )
)
);
}
require_once WORDPRESS_MCP_PATH . 'vendor/autoload.php';
/**
* Get the WordPress MCP instance.
*
* @return WpMcp
*/
function WPMCP() { // phpcs:ignore
return WpMcp::instance();
}
/**
* Initialize the plugin.
*/
function wordpress_mcp_init() {
$mcp = WPMCP();
// Initialize the STDIO transport.
new McpStdioTransport( $mcp );
// Initialize the Streamable transport.
new McpStreamableTransport( $mcp );
// Initialize the settings page.
new Settings();
// Initialize the JWT authentication.
new JwtAuth();
}
// Initialize the plugin.
add_action( 'init', 'wordpress_mcp_init' );
/**
* Register WP-CLI commands when WP-CLI is available.
*/
function wordpress_mcp_register_cli_commands() {
if ( ! class_exists( '\WP_CLI' ) ) {
return;
}
\WP_CLI::add_command( 'mcp validate-tools', ValidateToolsCommand::class ); // phpcs:ignore
}
// Register WP-CLI commands when CLI is loaded.
add_action( 'cli_init', 'wordpress_mcp_register_cli_commands' );