承接 php-mcp/schema 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

php-mcp/schema

Composer 安装命令:

composer require php-mcp/schema

包简介

PHP Data Transfer Objects (DTOs) and Enums for the Model Context Protocol (MCP) schema.

README 文档

README

Latest Version on Packagist Total Downloads License

Type-safe PHP DTOs for the Model Context Protocol (MCP) specification.

This package provides comprehensive Data Transfer Objects and Enums that ensure full compliance with the official MCP schema, enabling robust server and client implementations with complete type safety.

🎯 MCP Schema Version: 2025-03-26 (Latest)

Installation

composer require php-mcp/schema

Requirements: PHP 8.1+ • No dependencies

Quick Start

use PhpMcp\Schema\Tool;
use PhpMcp\Schema\Resource;
use PhpMcp\Schema\Request\CallToolRequest;

// Create a tool definition
$tool = Tool::make(
    name: 'calculator',
    inputSchema: [
        'type' => 'object',
        'properties' => [
            'operation' => ['type' => 'string'],
            'a' => ['type' => 'number'],
            'b' => ['type' => 'number']
        ],
        'required' => ['operation', 'a', 'b']
    ],
    description: 'Performs basic arithmetic operations'
);

// Serialize to JSON
$json = json_encode($tool);

// Deserialize from array
$tool = Tool::fromArray($decodedData);

Core Features

🏗️ Complete Schema Coverage

Every MCP protocol type is represented with full validation and type safety.

🔒 Immutable Design

All DTOs use readonly properties to prevent accidental mutations.

🚀 Developer Experience

  • Factory Methods: Convenient make() methods for fluent object creation
  • Array Conversion: Seamless toArray() and fromArray() methods
  • JSON Ready: Built-in JsonSerializable interface support
  • Validation: Comprehensive input validation with clear error messages

📦 Schema Components

Component Description
Tools Tool definitions with JSON Schema validation
Resources Static and template-based resource representations
Prompts Interactive prompt definitions with arguments
Content Text, image, audio, and blob content types
JSON-RPC Complete JSON-RPC 2.0 protocol implementation
Requests/Results All 15 request types and corresponding responses
Notifications Real-time event notification messages
Capabilities Client and server capability declarations

Usage Patterns

Creating Protocol Messages

// Initialize request
$request = InitializeRequest::make(
    protocolVersion: '2025-03-26',
    capabilities: ClientCapabilities::make(),
    clientInfo: Implementation::make('MyClient', '1.0.0')
);

// Call tool request  
$callRequest = CallToolRequest::make(
    name: 'calculator',
    arguments: ['operation' => 'add', 'a' => 5, 'b' => 3]
);

Working with Resources

// Static resource
$resource = Resource::make(
    uri: '/data/users.json',
    name: 'User Database',
    description: 'Complete user registry'
);

// Resource template
$template = ResourceTemplate::make(
    uriTemplate: '/users/{id}',
    name: 'User Profile',
    description: 'Individual user data'
);

Content Handling

// Text content
$text = TextContent::make('Hello, world!');

// Image content
$image = ImageContent::make(
    data: base64_encode($imageData),
    mimeType: 'image/png'
);

Package Structure

src/
├── Content/         # Content types (Text, Image, Audio, Blob, etc.)
├── Enum/           # Protocol enums (LoggingLevel, Role)
├── JsonRpc/        # JSON-RPC 2.0 implementation
├── Notification/   # Event notification types
├── Request/        # Protocol request messages
├── Result/         # Protocol response messages
├── Tool.php        # Tool definitions
├── Resource.php    # Resource representations
├── Prompt.php      # Prompt definitions
└── ...            # Core protocol types

Why Use This Package?

  • 100% MCP Compliance - Matches official specification exactly
  • Type Safety - Catch errors at development time, not runtime
  • Zero Dependencies - Lightweight and self-contained
  • Production Ready - Immutable, validated, and thoroughly tested
  • Future Proof - Updated with latest MCP specification versions

License

MIT License. See LICENSE for details.

Part of the PHP MCP ecosystem • Build type-safe MCP applications with confidence

php-mcp/schema 适用场景与选型建议

php-mcp/schema 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 496.28k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2025 年 06 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 php-mcp/schema 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 php-mcp/schema 我们能提供哪些服务?
定制开发 / 二次开发

基于 php-mcp/schema 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 496.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 30
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 2
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-19