Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Server/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -130,6 +131,11 @@ final class Builder

private ?ServerCapabilities $serverCapabilities = null;

/**
* @var LoaderInterface[]
*/
private array $loaders = [];

/**
* Sets the server's identity. Required.
*/
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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),
];

Expand Down