ability to append loaders to server builder (#132)
This commit is contained in:
parent
ff26b4ff61
commit
9be9e38815
1 changed files with 17 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ use Mcp\Capability\Registry\Container;
|
||||||
use Mcp\Capability\Registry\ElementReference;
|
use Mcp\Capability\Registry\ElementReference;
|
||||||
use Mcp\Capability\Registry\Loader\ArrayLoader;
|
use Mcp\Capability\Registry\Loader\ArrayLoader;
|
||||||
use Mcp\Capability\Registry\Loader\DiscoveryLoader;
|
use Mcp\Capability\Registry\Loader\DiscoveryLoader;
|
||||||
|
use Mcp\Capability\Registry\Loader\LoaderInterface;
|
||||||
use Mcp\Capability\Registry\ReferenceHandler;
|
use Mcp\Capability\Registry\ReferenceHandler;
|
||||||
use Mcp\JsonRpc\MessageFactory;
|
use Mcp\JsonRpc\MessageFactory;
|
||||||
use Mcp\Schema\Annotations;
|
use Mcp\Schema\Annotations;
|
||||||
|
|
@ -130,6 +131,11 @@ final class Builder
|
||||||
|
|
||||||
private ?ServerCapabilities $serverCapabilities = null;
|
private ?ServerCapabilities $serverCapabilities = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var LoaderInterface[]
|
||||||
|
*/
|
||||||
|
private array $loaders = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the server's identity. Required.
|
* Sets the server's identity. Required.
|
||||||
*/
|
*/
|
||||||
|
|
@ -356,6 +362,16 @@ final class Builder
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param LoaderInterface[] $loaders
|
||||||
|
*/
|
||||||
|
public function addLoaders(...$loaders): self
|
||||||
|
{
|
||||||
|
$this->loaders = [...$this->loaders, ...$loaders];
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the fully configured Server instance.
|
* Builds the fully configured Server instance.
|
||||||
*/
|
*/
|
||||||
|
|
@ -366,6 +382,7 @@ final class Builder
|
||||||
$registry = new Registry($this->eventDispatcher, $logger);
|
$registry = new Registry($this->eventDispatcher, $logger);
|
||||||
|
|
||||||
$loaders = [
|
$loaders = [
|
||||||
|
...$this->loaders,
|
||||||
new ArrayLoader($this->tools, $this->resources, $this->resourceTemplates, $this->prompts, $logger),
|
new ArrayLoader($this->tools, $this->resources, $this->resourceTemplates, $this->prompts, $logger),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue