Rework registry to combine provider and registry interface, move capabilities out and enable Registry injection in Builder (#150)
This commit is contained in:
parent
7a58ab3f5a
commit
7cd281d0c7
1 changed files with 567 additions and 736 deletions
|
|
@ -12,7 +12,7 @@
|
|||
namespace Mcp\Server\Handler\Request;
|
||||
|
||||
use Mcp\Capability\Completion\ProviderInterface;
|
||||
use Mcp\Capability\Registry\ReferenceProviderInterface;
|
||||
use Mcp\Capability\RegistryInterface;
|
||||
use Mcp\Exception\PromptNotFoundException;
|
||||
use Mcp\Exception\ResourceNotFoundException;
|
||||
use Mcp\Schema\JsonRpc\Error;
|
||||
|
|
@ -35,7 +35,7 @@ use Psr\Container\ContainerInterface;
|
|||
final class CompletionCompleteHandler implements RequestHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ReferenceProviderInterface $referenceProvider,
|
||||
private readonly RegistryInterface $registry,
|
||||
private readonly ?ContainerInterface $container = null,
|
||||
) {
|
||||
}
|
||||
|
|
@ -57,8 +57,8 @@ final class CompletionCompleteHandler implements RequestHandlerInterface
|
|||
|
||||
try {
|
||||
$reference = match (true) {
|
||||
$request->ref instanceof PromptReference => $this->referenceProvider->getPrompt($request->ref->name),
|
||||
$request->ref instanceof ResourceReference => $this->referenceProvider->getResource($request->ref->uri),
|
||||
$request->ref instanceof PromptReference => $this->registry->getPrompt($request->ref->name),
|
||||
$request->ref instanceof ResourceReference => $this->registry->getResource($request->ref->uri),
|
||||
};
|
||||
|
||||
$providers = $reference->completionProviders;
|
||||
|
|
|
|||
Loading…
Reference in a new issue