diff --git a/src/Server/Builder.php b/src/Server/Builder.php index 90bf53a..744e04b 100644 --- a/src/Server/Builder.php +++ b/src/Server/Builder.php @@ -16,6 +16,7 @@ use Mcp\Capability\Registry\ElementReference; use Mcp\Capability\Registry\Loader\ArrayLoader; use Mcp\Capability\Registry\Loader\DiscoveryLoader; +use Mcp\Capability\Registry\Loader\LoaderInterface; use Mcp\Capability\Registry\ReferenceHandler; use Mcp\JsonRpc\MessageFactory; use Mcp\Schema\Annotations; @@ -130,6 +131,11 @@ final class Builder private ?ServerCapabilities $serverCapabilities = null; + /** + * @var LoaderInterface[] + */ + private array $loaders = []; + /** * Sets the server's identity. Required. */ @@ -356,6 +362,16 @@ public function addPrompt(\Closure|array|string $handler, ?string $name = null, return $this; } + /** + * @param LoaderInterface[] $loaders + */ + public function addLoaders(...$loaders): self + { + $this->loaders = [...$this->loaders, ...$loaders]; + + return $this; + } + /** * Builds the fully configured Server instance. */ @@ -366,6 +382,7 @@ public function build(): Server $registry = new Registry($this->eventDispatcher, $logger); $loaders = [ + ...$this->loaders, new ArrayLoader($this->tools, $this->resources, $this->resourceTemplates, $this->prompts, $logger), ];