Skip to main content
Glama
InitializeHandler.php1.93 kB
<?php //phpcs:ignore /** * Initialize method handler for MCP requests. * * @package WordPressMcp */ namespace Automattic\WordpressMcp\RequestMethodHandlers; use Automattic\WordpressMcp\Core\WpMcp; use stdClass; /** * Handles the initialize MCP method. */ class InitializeHandler { /** * The WordPress MCP instance. * * @var WpMcp */ private WpMcp $mcp; /** * Constructor. */ public function __construct() { } /** * Handle the initialize request. * * @return array */ public function handle(): array { $site_info = array( 'name' => get_bloginfo( 'name' ), 'url' => get_bloginfo( 'url' ), 'description' => get_bloginfo( 'description' ), 'language' => get_bloginfo( 'language' ), 'charset' => get_bloginfo( 'charset' ), ); $server_info = array( 'name' => 'WordPress MCP Server', 'version' => WORDPRESS_MCP_VERSION, 'siteInfo' => $site_info, ); // @todo: add capabilities based on your implementation $capabilities = array( 'tools' => array( 'list' => true, 'call' => true, ), 'resources' => array( 'list' => true, 'subscribe' => true, 'listChanged' => true, ), 'prompts' => array( 'list' => true, 'get' => true, 'listChanged' => true, ), 'logging' => new stdClass(), 'completion' => new stdClass(), 'roots' => array( 'list' => true, 'listChanged' => true, ), ); // Send the response according to JSON-RPC 2.0 and InitializeResult schema. return array( 'protocolVersion' => '2025-03-26', 'serverInfo' => $server_info, 'capabilities' => (object) $capabilities, 'instructions' => 'This is a WordPress MCP Server implementation that provides tools, resources, and prompts for interacting with the WordPress site ' . get_bloginfo( 'name' ) . ' (' . get_bloginfo( 'url' ) . ').', ); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Automattic/wordpress-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server