Skip to content

Commit 3699323

Browse files
authored
align addLoaders with addRequestHandlers (#183)
1 parent 32757f6 commit 3699323

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to `mcp/sdk` will be documented in this file.
66
-----
77

88
* Make `Protocol` stateless by decouple if from `TransportInterface`. Removed `Protocol::getTransport()`.
9+
* Change signature of `Builder::addLoaders(...$loaders)` to `Builder::addLoaders(iterable $loaders)`.
910

1011
0.1.0
1112
-----

src/Server/Builder.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,23 @@ public function addPrompt(
434434
}
435435

436436
/**
437-
* @param LoaderInterface[] $loaders
437+
* Register a single custom loader.
438438
*/
439-
public function addLoaders(...$loaders): self
439+
public function addLoader(LoaderInterface $loader): self
440440
{
441-
$this->loaders = [...$this->loaders, ...$loaders];
441+
$this->loaders[] = $loader;
442+
443+
return $this;
444+
}
445+
446+
/**
447+
* @param iterable<LoaderInterface> $loaders
448+
*/
449+
public function addLoaders(iterable $loaders): self
450+
{
451+
foreach ($loaders as $loader) {
452+
$this->loaders = [$loader];
453+
}
442454

443455
return $this;
444456
}

0 commit comments

Comments
 (0)