align addLoaders with addRequestHandlers (#183)

This commit is contained in:
Antoine Bluchet 2025-12-09 09:47:31 +01:00 • committed by GitHub
commit 369932378f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View file

@ -6,6 +6,7 @@ All notable changes to `mcp/sdk` will be documented in this file.
----- -----
* Make `Protocol` stateless by decouple if from `TransportInterface`. Removed `Protocol::getTransport()`. * Make `Protocol` stateless by decouple if from `TransportInterface`. Removed `Protocol::getTransport()`.
* Change signature of `Builder::addLoaders(...$loaders)` to `Builder::addLoaders(iterable $loaders)`.
0.1.0 0.1.0
----- -----

View file

@ -434,11 +434,23 @@ final class Builder
} }
/** /**
* @param LoaderInterface[] $loaders * Register a single custom loader.
*/ */
public function addLoaders(...$loaders): self public function addLoader(LoaderInterface $loader): self
{ {
$this->loaders = [...$this->loaders, ...$loaders]; $this->loaders[] = $loader;
return $this;
}
/**
* @param iterable<LoaderInterface> $loaders
*/
public function addLoaders(iterable $loaders): self
{
foreach ($loaders as $loader) {
$this->loaders = [$loader];
}
return $this; return $this;
} }