adachsoft / mcp-contracts
Contracts, DTOs, Value Objects, Enums and exceptions for Model Context Protocol (MCP) clients.
Requires
- php: >=8.3
- adachsoft/collection: ^3.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.4
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.4
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
MCP Contracts provides the shared PHP types used by Model Context Protocol (MCP) clients. It defines the client interface and the data structures exchanged between applications and MCP servers, without tying consumers to a particular transport implementation.
Features
- A client interface for listing and invoking MCP tools.
- Immutable DTOs for MCP servers, tool definitions, tool results, and content items.
- Value objects for server identifiers and URLs.
- Typed immutable collections and MCP-specific exceptions.
Requirements
- PHP 8.3 or later.
- Composer.
Installation
Install the package with Composer:
composer require adachsoft/mcp-contracts
Usage
Use the shared client contract to keep application services independent of the concrete transport. See the client integration example for a typed service example.
Integration
Implement AdachSoft\McpContracts\Client\McpClientInterface in an MCP client or transport adapter, then inject that implementation into application services. The interface accepts an McpServerDto and returns typed collections and result DTOs. See the client integration example.