* [Tests] Introduce client-server integration tests * Add an in-process loopback that connects a real client transport to a real server transport, draining both Fiber loops in one synchronous pass instead of polling. A stalled exchange fails where it happened rather than hanging. * Cover protocol version negotiation across both implementations, where the unit tests only ever drive one side against a canned counter-offer. * Cover the server-to-client round-trips end to end: elicitation, sampling, roots, plus progress and logging notifications. * Add the `integration` test suite and a `make integration-tests` target. * [Tests] Run the integration suite in CI The unit job pins `--testsuite=unit`, so the new suite would never have run on GitHub. It goes in that job rather than its own: the loopback leans on Fibers, and the matrix is what covers them down to the PHP 8.1 floor. * [Tests] Run integration tests against a real server process Replaces the in-process loopback with the setup from examples/client: the client spawns a fixture server over the real StdioTransport, so the tests exercise the shipped transports and no longer nest both sides' Fibers. Moves the suite into its own CI job, matrixed over PHP 8.1-8.5.
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the official PHP MCP SDK.
|
|
*
|
|
* A collaboration between Symfony and the PHP Foundation.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
/*
|
|
* Server for {@see \Mcp\Tests\Integration\RootsTest}.
|
|
*/
|
|
|
|
use Mcp\Server;
|
|
use Mcp\Server\RequestContext;
|
|
use Mcp\Server\Transport\StdioTransport;
|
|
|
|
require_once dirname(__DIR__, 3).'/vendor/autoload.php';
|
|
|
|
Server::builder()
|
|
->setServerInfo('integration-server', '1.0.0')
|
|
->addTool(
|
|
static function (RequestContext $context): string {
|
|
$gateway = $context->getClientGateway();
|
|
|
|
if (!$gateway->supportsRoots()) {
|
|
return 'unsupported';
|
|
}
|
|
|
|
$described = [];
|
|
foreach ($gateway->listRoots()->roots as $root) {
|
|
$described[] = sprintf('%s (%s)', $root->uri, $root->name ?? '-');
|
|
}
|
|
|
|
return implode(', ', $described);
|
|
},
|
|
name: 'inspect_roots',
|
|
description: 'Reports the workspace roots the client exposes.',
|
|
)
|
|
->build()
|
|
->run(new StdioTransport());
|