Skip to content

McpTester ​

Rasuvaeff\Yii3Mcp\Testing\McpTester

Class — Rasuvaeff\Yii3Mcp — Source

In-process MCP client for testing application tools without HTTP or a transport process: drives the same Streamable HTTP code path the real endpoint uses and returns decoded results.

By default it speaks the handshake era (initialize, session id); given a modern revision (2026-07-28) it speaks the stateless era instead — no initialize, every request carries its own _meta envelope and the standard Mcp-Method/Mcp-Name/Mcp-Param-* headers, built by the SDK's own client classes so the tester cannot drift from a conformant client.

php
$tester = new McpTester($server, $requestFactory, $responseFactory, $streamFactory);
$tester->callTool('order.status', ['orderId' => '42']);

$modern = new McpTester($server, $requestFactory, $responseFactory, $streamFactory, ProtocolVersion::V2026_07_28);

Methods ​

initialize() ​

php
initialize(): array

Performs the initialize handshake; called implicitly by the other methods when needed. The modern era has no handshake: there it asks server/discover instead, which answers the same questions.

listTools() ​

php
listTools(): array

listResources() ​

php
listResources(): array

listResourceTemplates() ​

php
listResourceTemplates(): array

listPrompts() ​

php
listPrompts(): array

callTool() ​

php
callTool(string $name, array $arguments): array

Calls a tool and returns the decoded result envelope (content, isError, structuredContent, …).

readResource() ​

php
readResource(string $uri): array

request() ​

php
request(string $method, ?array $params): array