* [Tests] Bump MCP Inspector to 0.22.0 for 2025-11-25 protocol The pinned inspector 0.17.2 predates the protocol version bump to 2025-11-25 (v0.6.0) and rejects the handshake with "Server's protocol version is not supported", failing every inspector snapshot test. 0.22.0 negotiates the current protocol; the full inspector suite passes against it (95 tests, 7 pre-existing skips). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * [Examples] Demo pre-built instance handler in combined-registration Extends the combined-registration example with a third handler style: a pre-built object instance `[$instance, 'method']`, alongside the existing discovered and manual class-string handlers. PreconfiguredGreeter takes a scalar constructor argument neither the container-less `new $className()` fallback nor the auto-wiring container can build, so it can only be registered as an already-constructed instance — exercising the resolver path added in the parent branch. Adds an inspector snapshot case (tools/call instance_greeter) and updates the tools/list snapshot. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
#!/usr/bin/env 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.
|
|
*/
|
|
|
|
require_once dirname(__DIR__).'/bootstrap.php';
|
|
chdir(__DIR__);
|
|
|
|
use Mcp\Example\Server\CombinedRegistration\ManualHandlers;
|
|
use Mcp\Example\Server\CombinedRegistration\PreconfiguredGreeter;
|
|
use Mcp\Server;
|
|
use Mcp\Server\Session\FileSessionStore;
|
|
|
|
// Built here so its constructor dependencies (a scalar the container cannot
|
|
// auto-wire) are injected before registration; the SDK invokes this very
|
|
// instance instead of trying to construct one itself.
|
|
$preconfiguredGreeter = new PreconfiguredGreeter('Willkommen', logger());
|
|
|
|
$server = Server::builder()
|
|
->setServerInfo('Combined HTTP Server', '1.0.0')
|
|
->setLogger(logger())
|
|
->setContainer(container())
|
|
->setSession(new FileSessionStore(__DIR__.'/sessions'))
|
|
->setDiscovery(__DIR__)
|
|
->addTool([ManualHandlers::class, 'manualGreeter'])
|
|
->addTool([$preconfiguredGreeter, 'greet'], 'instance_greeter')
|
|
->addResource(
|
|
[ManualHandlers::class, 'getPriorityConfigManual'],
|
|
'config://priority',
|
|
'priority_config_manual',
|
|
)
|
|
->build();
|
|
|
|
$response = $server->run(transport());
|
|
|
|
shutdown($response);
|