Releases: php-mcp/schema
v1.0.2
What's Changed
- Normalize stdClass to array in Request::fromArray() for param type sa… by @judus in #4
- Fix missing parameters in ClientCapabilities::fromArray() constructor call by @CodeWithKyrian in #5
New Contributors
Full Changelog: 1.0.1...1.0.2
1.0.1
What's Changed
- Fix Tool deserialization to preserve empty properties as stdClass by @CodeWithKyrian in #1
Full Changelog: 1.0.0...1.0.1
v1.0.0
🎉 Initial Stable Release
I'm excited to announce the first stable release of php-mcp/schema, a comprehensive PHP implementation of Data Transfer Objects (DTOs) and Enums for the Model Context Protocol (MCP).
📋 Overview
This package provides type-safe PHP representations of the complete MCP specification, enabling robust server and client implementations with full schema compliance.
MCP Schema Version Support: 2025-03-26 (Latest)
🚀 Key Features
Core DTOs and Schema Support
- Complete MCP Schema Coverage: Full implementation of all MCP protocol types
- Type Safety: Strongly-typed PHP classes with readonly properties for immutability
- JSON Serialization: Built-in
JsonSerializablesupport for seamless API communication - Validation: Comprehensive input validation with meaningful error messages
Protocol Components
🛠️ Tools & Resources
Tool- Tool definitions with JSON Schema validationResource- Static resource representationsResourceTemplate- Dynamic resource templates with URI patternsToolAnnotations- Rich metadata for tool descriptions
📝 Content Types
TextContent- Plain text content handlingImageContent- Image content with MIME type supportAudioContent- Audio content representationBlobResourceContents- Binary resource handlingEmbeddedResource- Embedded resource content
🔄 Communication Layer
- JSON-RPC 2.0: Complete implementation (
Request,Response,Error,Notification) - Batch Operations: Support for batch requests and responses
- Message Parsing: Robust JSON-RPC message parsing utilities
📨 Request & Response Types
- 15 Request Types: From
InitializeRequesttoCreateSamplingMessageRequest - 12 Result Types: Corresponding response objects for all operations
- 9 Notification Types: Real-time event notifications
🎯 Prompts & Capabilities
Prompt- Interactive prompt definitionsPromptArgument- Structured prompt parametersClientCapabilities&ServerCapabilities- Capability negotiationModelPreferences- LLM model preference specifications
Developer Experience Features
🏭 Factory Methods
Every DTO includes convenient static factory methods:
$tool = Tool::make('calculator', $schema, 'A calculator tool');
$resource = Resource::make('/api/data', 'Dataset', 'Sample dataset');🔄 Array Conversion
Seamless conversion between PHP objects and arrays:
// To array (for JSON encoding)
$toolArray = $tool->toArray();
// From array (from JSON decoding)
$tool = Tool::fromArray($decodedData);✅ Input Validation
Comprehensive validation with descriptive error messages:
- Required field validation
- Type checking
- Schema compliance verification
- JSON Schema validation for tool inputs
📦 Installation
composer require php-mcp/schemaRequirements:
- PHP 8.1 or higher
- No additional dependencies
🎯 Use Cases
- MCP Server Development: Build compliant MCP servers with type safety
- MCP Client Development: Create robust clients with validated schemas
- API Integration: Seamless JSON serialization for MCP communication
- Testing: Mock MCP protocol interactions with real schema objects
- Documentation: Self-documenting code with comprehensive type hints
🔧 Architecture Highlights
- Immutable Design: Readonly properties prevent accidental mutations
- PSR Compliance: Follows PHP standards and best practices
- Zero Dependencies: Lightweight with no external requirements
- Full Coverage: Every MCP protocol type is represented
📁 Package Structure
src/
├── Content/ # Content type DTOs (Text, Image, Audio, etc.)
├── Enum/ # Protocol enums (LoggingLevel, Role)
├── JsonRpc/ # JSON-RPC protocol implementation
├── Notification/ # Notification message types
├── Request/ # Request message types
├── Result/ # Response result types
├── Tool.php # Core tool definitions
├── Resource.php # Resource representations
├── Prompt.php # Prompt definitions
└── ... # Additional core types
🛣️ What's Next
This stable release provides the foundation for the broader PHP MCP ecosystem:
- php-mcp/server: SDK for MCP server implementation
- php-mcp/client: SDK for MCP client implementation
- php-mcp/laravel: Laravel integration package
📖 Documentation
🤝 Contributing
Contributions are welcome! This package aims to maintain 100% compatibility with the official MCP specification.
📄 License
MIT License - see LICENSE file for details.