Skip to content

WordPress/php-mcp-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP MCP Schema

A PHP representation of the Model Context Protocol (MCP) schema types.

This package provides Data Transfer Objects (DTOs), Enums, and Unions that mirror the official MCP TypeScript schema. It is not an SDK, client, or server implementation; just the type definitions for building your own MCP-compatible applications in PHP.

Installation

composer require wordpress/php-mcp-schema

Requires PHP 7.4 or higher.

Usage

use WP\McpSchema\Server\Tools\Tool;
use WP\McpSchema\Server\Tools\CallToolRequest;
use WP\McpSchema\Common\Content\TextContent;

// Create a tool definition
$tool = Tool::fromArray([
    'name' => 'get_weather',
    'description' => 'Get current weather for a location',
    'inputSchema' => [
        'type' => 'object',
        'properties' => [
            'location' => ['type' => 'string', 'description' => 'City name'],
        ],
        'required' => ['location'],
    ],
]);

Available Types

Server Types (WP\McpSchema\Server\)

  • Tools - Tool, CallToolRequest, CallToolResult, ListToolsRequest, ListToolsResult
  • Resources - Resource, ResourceTemplate, ReadResourceRequest, ReadResourceResult
  • Prompts - Prompt, PromptMessage, GetPromptRequest, GetPromptResult
  • Logging - LoggingMessageNotification, SetLevelRequest

Client Types (WP\McpSchema\Client\)

  • Sampling - CreateMessageRequest, CreateMessageResult, SamplingMessage
  • Elicitation - ElicitRequest, ElicitResult
  • Roots - ListRootsRequest, ListRootsResult, Root

Common Types (WP\McpSchema\Common\)

  • Protocol - InitializeRequest, InitializeResult, PingRequest
  • Content - TextContent, ImageContent, AudioContent
  • JSON-RPC - JSONRPCRequest, JSONRPCNotification, JSONRPCResultResponse, JSONRPCErrorResponse

Generator

The PHP code in src/ is auto-generated from the official MCP TypeScript schema. The generator is located in the generator/ directory and is not included in the Composer package.

See generator/README.md for setup and usage instructions.

License

MIT License - see LICENSE for details.

Links

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published