switon / mcp
Model Context Protocol tool catalog for Switon Framework
v1.0.0
2026-08-22 14:32 UTC
Requires
- php: >=8.3
- psr/event-dispatcher: ^1.0
- psr/log: ^2.0
- switon/command: ^1.0
- switon/core: ^1.0
- switon/event: ^1.0
- switon/http: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
Suggests
- switon/http: Streamable HTTP via HttpTransport; wire your own controller to POST /mcp (or any path)
Provides
None
Conflicts
None
Replaces
None
README
Switon's Model Context Protocol layer: one tool catalog served over stdio or streamable HTTP.
Highlights
- Tool contract:
schema()describes arguments andcall()runs them. - One catalog: explicit names and discovered
app/Mcp/Tool/*Tool.phpclasses share the same map. - Light binding: defaults, required fields, and string/integer coercion.
- Tool failures stay in the result so the client can read and correct them.
- Two transports: stdio, or streamable HTTP behind an app controller.
Installation
composer require switon/mcp
Quick Start
use App\Service\OrderService; use Switon\Core\Attribute\Autowired; use Switon\Mcp\AbstractTool; use Switon\Mcp\ToolSchema; class OrderStatusTool extends AbstractTool { #[Autowired] protected OrderService $orders; public function schema(string $name): ToolSchema { return $this->schema ??= new ToolSchema( description: 'Return order status by order ID', properties: [ 'orderId' => ['type' => 'integer'], ], required: ['orderId'], ); } public function call(string $name, array $arguments): mixed { return $this->orders->statusOf($arguments['orderId']); } }
Docs: https://github.com/switon-php/mcp/blob/main/docs/README.md
License
MIT.