[Server] Keep injectable parameters out of the published inputSchema (#482)

This commit is contained in:
Christopher Hertel 2026-08-25 01:12:29 +02:00 • committed by GitHub
commit e173367c5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,8 +13,6 @@ namespace Mcp\Capability\Registry;
use Mcp\Exception\InvalidArgumentException;
use Mcp\Exception\RegistryException;
use Mcp\Server\ClientGateway;
use Mcp\Server\RequestContext;
use Mcp\Server\Session\SessionInterface;
use Psr\Container\ContainerInterface;
@ -106,15 +104,9 @@ final class ReferenceHandler implements ReferenceHandlerInterface
// Check if parameter is a special injectable type
$type = $parameter->getType();
if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
$typeName = $type->getName();
if (RequestContext::class === $typeName && isset($arguments['_session'], $arguments['_request'])) {
$finalArgs[$paramPosition] = new RequestContext($arguments['_session'], $arguments['_request']);
continue;
}
if (ClientGateway::class === $typeName && isset($arguments['_session'])) {
$finalArgs[$paramPosition] = new ClientGateway($arguments['_session']);
$injected = InjectableParameters::resolve($type->getName(), $arguments);
if (null !== $injected) {
$finalArgs[$paramPosition] = $injected;
continue;
}
}