aisdk / mcp
Stateless Model Context Protocol (2026-07-28) client and server for the PHP AI SDK.
Fund package maintenance!
v0.11.0
2026-10-31 02:58 UTC
Requires
- php: ^8.3
- aisdk/core: ^0.11.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/http-server-handler: ^1.0
Requires (Dev)
- laravel/pint: ^1.18
- nyholm/psr7: ^1.8
- pestphp/pest: ^3.0 || ^4.0
- phpstan/phpstan: ^2.0
- rector/rector: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A Model Context Protocol client and server for PHP. Expose SDK tools and resources over HTTP or stdio, or use remote MCP tools with any PHP AI SDK provider.
Installation
composer require aisdk/mcp
Usage
<?php require __DIR__.'/vendor/autoload.php'; use AiSdk\Mcp\Server\Server; use AiSdk\Mcp\Server\StdioServer; use AiSdk\Tool; $server = Server::make('my-tools', '1.0.0') ->tool(Tool::make('hello', 'Return a greeting') ->run(fn (): string => 'Hello from PHP!')); (new StdioServer($server))->run();
Save the example as server.php and run it with php server.php. Supports modern MCP and explicit legacy client compatibility.
Documentation
Read the documentation for configuration, supported features, and more examples.
License
The MIT License (MIT). See LICENSE for details.