1. Go to this page and download the library: Download wordpress/php-mcp-schema library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wordpress / php-mcp-schema example snippets
use WP\McpSchema\Server\Tools\DTO\Tool;
$tool = Tool::fromArray([
'name' => 'get_weather',
'description' => 'Get current weather for a location',
'inputSchema' => [
'type' => 'object',
'properties' => [
'location' => ['type' => 'string', 'description' => 'City name'],
],
'
use WP\McpSchema\Server\Tools\DTO\Tool;
$tool = Tool::fromArray([
'name' => 'get_weather',
'description' => 'Get current weather for a location',
'inputSchema' => ['type' => 'object', 'properties' => []],
]);
$array = $tool->toArray();
$json = json_encode($array); // Ready to send over the wire
use WP\McpSchema\Common\Protocol\Factory\ContentBlockFactory;
use WP\McpSchema\Common\Content\DTO\TextContent;
$block = ContentBlockFactory::fromArray(['type' => 'text', 'text' => 'Hello, world!']);
// $block implements ContentBlockInterface; cast when you need the concrete API
if ($block instanceof TextContent) {
echo $block->getText(); // "Hello, world!"
}