Skip to content

ContainerAdapter

Wraps Quiote’s DI Container as the PSR-11 container mcp/sdk uses (Mcp\Server\Builder::setContainer()) to resolve string/array tool handlers (Mcp\Capability\Registry\ReferenceHandler::getClassInstance()).

Quiote’s own Container::has() deliberately reflects only explicit registrations/aliases, not autowireable classes (see its docblock) — so ordinary callers can’t observe autowiring through a PSR-11 has() check. But MCP tool/resource/prompt handler classes are typically plain autowireable classes that are never explicitly bound. If has() returned false for those, ReferenceHandler falls back to new $class(), bypassing DI (and any constructor dependencies) entirely. This adapter reports any loadable class as present so get()’s autowiring path resolves it instead.

final class ContainerAdapter implements ContainerInterface

ImplementsContainerInterface
SourceBridge/ContainerAdapter.php

public function __construct(Container $container): mixed

ParameterTypeDescription
$containerContainer

Returns mixed

MethodDescription
get(string $id): mixedResolves $id through the wrapped Quiote container, autowiring it when it has no explicit registration.
has(string $id): boolReports whether $id can be resolved.

public function get(string $id): mixed

Resolves $id through the wrapped Quiote container, autowiring it when it has no explicit registration.

ParameterTypeDescription
$idstring

Returns mixed

public function has(string $id): bool

Reports whether $id can be resolved.

True for anything the wrapped Quiote container has an explicit registration or alias for, and additionally for any loadable class name, so mcp/sdk routes autowireable handler classes through ContainerAdapter::get() instead of instantiating them itself.

ParameterTypeDescription
$idstring

Returns bool