Skip to content
YII3-MCP(3)rasuvaeff PHP Library ManualYII3-MCP(3)

NAME ​

yii3-mcp — model Context Protocol server for Yii3 on the official mcp/sdk, over PSR-15

SYNOPSIS ​

$ composer require rasuvaeff/yii3-mcp

final readonly class OrderTools{    public function __construct(private OrderRepository $orders) {}     /**     * Returns the current status of an order.     */    #[McpTool(name: 'order.status')]    public function status(string $orderId): string    {        return $this->orders->get($orderId)->status->value;    }}

DESCRIPTION ​

A Model Context Protocol server for Yii3, built on the official mcp/sdk and served over PSR-15.

Exposing application operations to AI agents as tools, resources and prompts needs a Streamable HTTP endpoint, tools resolved through the container, and guardrails around agent loops and secrets.

  • #[McpTool], #[McpResource] and #[McpPrompt] methods resolved through the DI container.
  • Serves handshake revisions 2024-11-05 to 2025-11-25 and the stateless 2026-07-28 on one endpoint.
  • SharedSecretMiddleware is fail-closed; BearerTokenMiddleware makes it an OAuth 2.1 resource server.
  • tool_call_budget caps tools/call in a row to stop agent loops.
  • Interceptors for rate limits, response size limits and PSR-16 caching, plus an ArgumentMasker helper for secrets in arguments.
  • Per-session tool, prompt and resource visibility.
  • OpenApiServerConfigurator bridges allow-listed REST operations as tools.
  • McpTester, SchemaSnapshot, mcp:doctor, mcp:list and stdio mcp:serve.

EXAMPLES ​

Tells MCP clients that a tool is mutating and destructive, using the SDK's own annotations.

#[McpTool(    name: 'order.cancel',    annotations: new ToolAnnotations(        readOnlyHint: false,        destructiveHint: true,        idempotentHint: true,        openWorldHint: false,    ),)]public function cancel(string $orderId): string{    $this->orders->cancel($orderId);     return 'cancelled';}

Caps tools/call in a row so a looping agent gets a tool error instead of hammering the app.

'rasuvaeff/yii3-mcp' => [    'tool_call_budget' => [        'calls' => 50,0 = unlimited (default)        'window' => 3600,seconds, stateless era only    ],],

Tests tools in-process through the real Streamable HTTP path, with no server or stdio process.

$tester = new McpTester($server, $psr17, $psr17, $psr17); $result = $tester->callTool('order.status', ['orderId' => '42']);$this->assertSame('paid', $result['content'][0]['text']); $tester->listTools();every paginated tool definition$tester->listResources();every resource definition$tester->readResource('app://x');resource contents

SEE ALSO ​

PackageAdds
yii3-mcp-rbac-bridge(3)Per-user RBAC on tools
yii3-mcp-audit-log-bridge(3)Audit log for every call
yii3-mcp-telemetry-bridge(3)Traces for the same calls

BUGS ​

mcp/sdk is experimental until 1.0, hence the ~0.10.0 pin. The tool-call budget is loop protection, not a client quota. On the stateless era without SharedSecretMiddleware, all anonymous callers share one budget.

DEPENDENCIES

required by: yii3-mcp-audit-log-bridge(3), yii3-mcp-rbac-bridge(3), yii3-mcp-telemetry-bridge(3)

HISTORY

First released as v1.0.0 on 2026-07-04; 26 releases in all.

v5.0.02026-11-11
v4.1.12026-10-10
v4.1.02026-10-09
v4.0.12026-10-08
v4.0.02026-10-08
v3.1.12026-10-07
v3.1.02026-10-07
v3.0.12026-10-07
v3.0.02026-10-07
v2.3.02026-09-08

… and 16 earlier. All releases

rasuvaeff/yii3-mcp 5.0.0mutation gate 97%used by 3 packagesYII3-MCP(3)

/ search · n N next, previous · g G top, bottom · q back to the index