Skip to content

McpTester

Rasuvaeff\Yii3Mcp\Testing\McpTester

ClassRasuvaeff\Yii3McpSource

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 (initialize handshake, session id, JSON-RPC framing) and returns decoded results.

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

Methods

initialize()

php
initialize(): array

Performs the initialize handshake; called implicitly by the other methods when needed.

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