Rework registry to combine provider and registry interface, move capabilities out and enable Registry injection in Builder (#150)

This commit is contained in:
Christopher Hertel 2025-11-20 19:36:57 +01:00 • committed by GitHub
commit 7cd281d0c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 567 additions and 736 deletions

View file

@ -13,8 +13,6 @@ namespace Mcp\Capability;
use Mcp\Capability\Discovery\DiscoveryState;
use Mcp\Capability\Registry\PromptReference;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\Registry\ReferenceRegistryInterface;
use Mcp\Capability\Registry\ResourceReference;
use Mcp\Capability\Registry\ResourceTemplateReference;
use Mcp\Capability\Registry\ToolReference;
@ -31,7 +29,6 @@ use Mcp\Schema\Page;
use Mcp\Schema\Prompt;
use Mcp\Schema\Resource;
use Mcp\Schema\ResourceTemplate;
use Mcp\Schema\ServerCapabilities;
use Mcp\Schema\Tool;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface;
@ -39,13 +36,10 @@ use Psr\Log\NullLogger;
/**
* Registry implementation that manages MCP element registration and access.
* Implements both ReferenceProvider (for access) and ReferenceRegistry (for registration)
* following the Interface Segregation Principle.
*
* @author Kyrian Obikwelu <koshnawaza@gmail.com>
* @author Pavel Buchnev <butschster@gmail.com>
*/
final class Registry implements ReferenceProviderInterface, ReferenceRegistryInterface
final class Registry implements RegistryInterface
{
/**
* @var array<string, ToolReference>
@ -67,8 +61,6 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
*/
private array $resourceTemplates = [];
private ServerCapabilities $serverCapabilities;
public function __construct(
private readonly ?EventDispatcherInterface $eventDispatcher = null,
private readonly LoggerInterface $logger = new NullLogger(),
@ -76,25 +68,6 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
) {
}
public function getCapabilities(): ServerCapabilities
{
if (!$this->hasElements()) {
$this->logger->info('No capabilities registered on server.');
}
return $this->serverCapabilities ?? new ServerCapabilities(
tools: [] !== $this->tools,
toolsListChanged: $this->eventDispatcher instanceof EventDispatcherInterface,
resources: [] !== $this->resources || [] !== $this->resourceTemplates,
resourcesSubscribe: false,
resourcesListChanged: $this->eventDispatcher instanceof EventDispatcherInterface,
prompts: [] !== $this->prompts,
promptsListChanged: $this->eventDispatcher instanceof EventDispatcherInterface,
logging: false,
completions: true,
);
}
public function registerTool(Tool $tool, callable|array|string $handler, bool $isManual = false): void
{
$toolName = $tool->name;
@ -220,41 +193,9 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
}
}
public function getTool(string $name): ToolReference
public function hasTools(): bool
{
return $this->tools[$name] ?? throw new ToolNotFoundException($name);
}
public function getResource(
string $uri,
bool $includeTemplates = true,
): ResourceReference|ResourceTemplateReference {
$registration = $this->resources[$uri] ?? null;
if ($registration) {
return $registration;
}
if ($includeTemplates) {
foreach ($this->resourceTemplates as $template) {
if ($template->matches($uri)) {
return $template;
}
}
}
$this->logger->debug('No resource matched URI.', ['uri' => $uri]);
throw new ResourceNotFoundException($uri);
}
public function getResourceTemplate(string $uriTemplate): ResourceTemplateReference
{
return $this->resourceTemplates[$uriTemplate] ?? throw new ResourceNotFoundException($uriTemplate);
}
public function getPrompt(string $name): PromptReference
{
return $this->prompts[$name] ?? throw new PromptNotFoundException($name);
return [] !== $this->tools;
}
public function getTools(?int $limit = null, ?string $cursor = null): Page
@ -279,6 +220,16 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
return new Page($paginatedTools, $nextCursor);
}
public function getTool(string $name): ToolReference
{
return $this->tools[$name] ?? throw new ToolNotFoundException($name);
}
public function hasResources(): bool
{
return [] !== $this->resources;
}
public function getResources(?int $limit = null, ?string $cursor = null): Page
{
$resources = [];
@ -301,26 +252,31 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
return new Page($paginatedResources, $nextCursor);
}
public function getPrompts(?int $limit = null, ?string $cursor = null): Page
public function getResource(
string $uri,
bool $includeTemplates = true,
): ResourceReference|ResourceTemplateReference {
$registration = $this->resources[$uri] ?? null;
if ($registration) {
return $registration;
}
if ($includeTemplates) {
foreach ($this->resourceTemplates as $template) {
if ($template->matches($uri)) {
return $template;
}
}
}
$this->logger->debug('No resource matched URI.', ['uri' => $uri]);
throw new ResourceNotFoundException($uri);
}
public function hasResourceTemplates(): bool
{
$prompts = [];
foreach ($this->prompts as $promptReference) {
$prompts[$promptReference->prompt->name] = $promptReference->prompt;
}
if (null === $limit) {
return new Page($prompts, null);
}
$paginatedPrompts = $this->paginateResults($prompts, $limit, $cursor);
$nextCursor = $this->calculateNextCursor(
\count($prompts),
$cursor,
$limit
);
return new Page($paginatedPrompts, $nextCursor);
return [] !== $this->resourceTemplates;
}
public function getResourceTemplates(?int $limit = null, ?string $cursor = null): Page
@ -345,12 +301,41 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
return new Page($paginatedTemplates, $nextCursor);
}
public function hasElements(): bool
public function getResourceTemplate(string $uriTemplate): ResourceTemplateReference
{
return !empty($this->tools)
|| !empty($this->resources)
|| !empty($this->prompts)
|| !empty($this->resourceTemplates);
return $this->resourceTemplates[$uriTemplate] ?? throw new ResourceNotFoundException($uriTemplate);
}
public function hasPrompts(): bool
{
return [] !== $this->prompts;
}
public function getPrompts(?int $limit = null, ?string $cursor = null): Page
{
$prompts = [];
foreach ($this->prompts as $promptReference) {
$prompts[$promptReference->prompt->name] = $promptReference->prompt;
}
if (null === $limit) {
return new Page($prompts, null);
}
$paginatedPrompts = $this->paginateResults($prompts, $limit, $cursor);
$nextCursor = $this->calculateNextCursor(
\count($prompts),
$cursor,
$limit
);
return new Page($paginatedPrompts, $nextCursor);
}
public function getPrompt(string $name): PromptReference
{
return $this->prompts[$name] ?? throw new PromptNotFoundException($name);
}
/**
@ -464,9 +449,4 @@ final class Registry implements ReferenceProviderInterface, ReferenceRegistryInt
return array_values(\array_slice($items, $offset, $limit));
}
public function setServerCapabilities(ServerCapabilities $serverCapabilities): void
{
$this->serverCapabilities = $serverCapabilities;
}
}

View file

@ -19,7 +19,7 @@ use Mcp\Capability\Discovery\DocBlockParser;
use Mcp\Capability\Discovery\HandlerResolver;
use Mcp\Capability\Discovery\SchemaGenerator;
use Mcp\Capability\Registry\ElementReference;
use Mcp\Capability\Registry\ReferenceRegistryInterface;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\ConfigurationException;
use Mcp\Schema\Annotations;
use Mcp\Schema\Icon;
@ -86,7 +86,7 @@ final class ArrayLoader implements LoaderInterface
) {
}
public function load(ReferenceRegistryInterface $registry): void
public function load(RegistryInterface $registry): void
{
$docBlockParser = new DocBlockParser(logger: $this->logger);
$schemaGenerator = new SchemaGenerator($docBlockParser);

View file

@ -13,7 +13,7 @@ namespace Mcp\Capability\Registry\Loader;
use Mcp\Capability\Discovery\CachedDiscoverer;
use Mcp\Capability\Discovery\Discoverer;
use Mcp\Capability\Registry\ReferenceRegistryInterface;
use Mcp\Capability\RegistryInterface;
use Psr\Log\LoggerInterface;
use Psr\SimpleCache\CacheInterface;
@ -35,7 +35,7 @@ final class DiscoveryLoader implements LoaderInterface
) {
}
public function load(ReferenceRegistryInterface $registry): void
public function load(RegistryInterface $registry): void
{
// This now encapsulates the discovery process
$discoverer = new Discoverer($this->logger);

View file

@ -11,12 +11,12 @@
namespace Mcp\Capability\Registry\Loader;
use Mcp\Capability\Registry\ReferenceRegistryInterface;
use Mcp\Capability\RegistryInterface;
/**
* @author Antoine Bluchet <soyuka@gmail.com>
*/
interface LoaderInterface
{
public function load(ReferenceRegistryInterface $registry): void;
public function load(RegistryInterface $registry): void;
}

View file

@ -11,6 +11,9 @@
namespace Mcp\Capability\Registry;
use Mcp\Exception\InvalidArgumentException;
use Mcp\Exception\RegistryException;
/**
* Interface for handling execution of MCP elements.
* Allows custom implementations of element execution logic.
@ -27,8 +30,8 @@ interface ReferenceHandlerInterface
*
* @return mixed the result of the element execution
*
* @throws \Mcp\Exception\InvalidArgumentException if the handler is invalid
* @throws \Mcp\Exception\RegistryException if execution fails
* @throws InvalidArgumentException if the handler is invalid
* @throws RegistryException if execution fails
*/
public function handle(ElementReference $reference, array $arguments): mixed;
}

View file

@ -1,79 +0,0 @@
<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Capability\Registry;
use Mcp\Exception\PromptNotFoundException;
use Mcp\Exception\ResourceNotFoundException;
use Mcp\Exception\ToolNotFoundException;
use Mcp\Schema\Page;
/**
* Interface for providing access to registered MCP elements.
* Separates the concern of accessing elements from registering them.
*
* @author Pavel Buchnev <butschster@gmail.com>
*/
interface ReferenceProviderInterface
{
/**
* Gets a tool reference by name.
*
* @throws ToolNotFoundException
*/
public function getTool(string $name): ToolReference;
/**
* Gets a resource reference by URI (includes template matching if enabled).
*
* @throws ResourceNotFoundException
*/
public function getResource(string $uri, bool $includeTemplates = true): ResourceReference|ResourceTemplateReference;
/**
* Gets a resource template reference by URI template.
*
* @throws ResourceNotFoundException
*/
public function getResourceTemplate(string $uriTemplate): ResourceTemplateReference;
/**
* Gets a prompt reference by name.
*
* @throws PromptNotFoundException
*/
public function getPrompt(string $name): PromptReference;
/**
* Gets all registered tools.
*/
public function getTools(?int $limit = null, ?string $cursor = null): Page;
/**
* Gets all registered resources.
*/
public function getResources(?int $limit = null, ?string $cursor = null): Page;
/**
* Gets all registered prompts.
*/
public function getPrompts(?int $limit = null, ?string $cursor = null): Page;
/**
* Gets all registered resource templates.
*/
public function getResourceTemplates(?int $limit = null, ?string $cursor = null): Page;
/**
* Checks if any elements (manual or discovered) are currently registered.
*/
public function hasElements(): bool;
}

View file

@ -1,91 +0,0 @@
<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Capability\Registry;
use Mcp\Capability\Discovery\DiscoveryState;
use Mcp\Schema\Prompt;
use Mcp\Schema\Resource;
use Mcp\Schema\ResourceTemplate;
use Mcp\Schema\ServerCapabilities;
use Mcp\Schema\Tool;
/**
* @phpstan-import-type Handler from ElementReference
*
* Interface for registering MCP elements.
* Separates the concern of registering elements from accessing them.
*
* @author Pavel Buchnev <butschster@gmail.com>
*/
interface ReferenceRegistryInterface
{
/**
* Gets server capabilities based on registered elements.
*/
public function getCapabilities(): ServerCapabilities;
/**
* Registers a tool with its handler.
*
* @param Handler $handler
*/
public function registerTool(Tool $tool, callable|array|string $handler, bool $isManual = false): void;
/**
* Registers a resource with its handler.
*
* @param Handler $handler
*/
public function registerResource(Resource $resource, callable|array|string $handler, bool $isManual = false): void;
/**
* Registers a resource template with its handler and completion providers.
*
* @param Handler $handler
* @param array<string, class-string|object> $completionProviders
*/
public function registerResourceTemplate(
ResourceTemplate $template,
callable|array|string $handler,
array $completionProviders = [],
bool $isManual = false,
): void;
/**
* Registers a prompt with its handler and completion providers.
*
* @param Handler $handler
* @param array<string, class-string|object> $completionProviders
*/
public function registerPrompt(
Prompt $prompt,
callable|array|string $handler,
array $completionProviders = [],
bool $isManual = false,
): void;
/**
* Clear discovered elements from registry.
*/
public function clear(): void;
/**
* Get the current discovery state (only discovered elements, not manual ones).
*/
public function getDiscoveryState(): DiscoveryState;
/**
* Set discovery state, replacing all discovered elements.
* Manual elements are preserved.
*/
public function setDiscoveryState(DiscoveryState $state): void;
}

View file

@ -0,0 +1,160 @@
<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Capability;
use Mcp\Capability\Discovery\DiscoveryState;
use Mcp\Capability\Registry\ElementReference;
use Mcp\Capability\Registry\PromptReference;
use Mcp\Capability\Registry\ResourceReference;
use Mcp\Capability\Registry\ResourceTemplateReference;
use Mcp\Capability\Registry\ToolReference;
use Mcp\Exception\PromptNotFoundException;
use Mcp\Exception\ResourceNotFoundException;
use Mcp\Exception\ToolNotFoundException;
use Mcp\Schema\Page;
use Mcp\Schema\Prompt;
use Mcp\Schema\Resource;
use Mcp\Schema\ResourceTemplate;
use Mcp\Schema\Tool;
/**
* @phpstan-import-type Handler from ElementReference
*
* @author Kyrian Obikwelu <koshnawaza@gmail.com>
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
interface RegistryInterface
{
/**
* Registers a tool with its handler.
*
* @param Handler $handler
*/
public function registerTool(Tool $tool, callable|array|string $handler, bool $isManual = false): void;
/**
* Registers a resource with its handler.
*
* @param Handler $handler
*/
public function registerResource(Resource $resource, callable|array|string $handler, bool $isManual = false): void;
/**
* Registers a resource template with its handler and completion providers.
*
* @param Handler $handler
* @param array<string, class-string|object> $completionProviders
*/
public function registerResourceTemplate(
ResourceTemplate $template,
callable|array|string $handler,
array $completionProviders = [],
bool $isManual = false,
): void;
/**
* Registers a prompt with its handler and completion providers.
*
* @param Handler $handler
* @param array<string, class-string|object> $completionProviders
*/
public function registerPrompt(
Prompt $prompt,
callable|array|string $handler,
array $completionProviders = [],
bool $isManual = false,
): void;
/**
* Clear discovered elements from registry.
*/
public function clear(): void;
/**
* Get the current discovery state (only discovered elements, not manual ones).
*/
public function getDiscoveryState(): DiscoveryState;
/**
* Set discovery state, replacing all discovered elements.
* Manual elements are preserved.
*/
public function setDiscoveryState(DiscoveryState $state): void;
/**
* @return bool true if any tools are registered
*/
public function hasTools(): bool;
/**
* Gets all registered tools.
*/
public function getTools(?int $limit = null, ?string $cursor = null): Page;
/**
* Gets a tool reference by name.
*
* @throws ToolNotFoundException
*/
public function getTool(string $name): ToolReference;
/**
* @return bool true if any resources are registered
*/
public function hasResources(): bool;
/**
* Gets all registered resources.
*/
public function getResources(?int $limit = null, ?string $cursor = null): Page;
/**
* Gets a resource reference by URI (includes template matching if enabled).
*
* @throws ResourceNotFoundException
*/
public function getResource(string $uri, bool $includeTemplates = true): ResourceReference|ResourceTemplateReference;
/**
* @return bool true if any resource templates are registered
*/
public function hasResourceTemplates(): bool;
/**
* Gets all registered resource templates.
*/
public function getResourceTemplates(?int $limit = null, ?string $cursor = null): Page;
/**
* Gets a resource template reference by URI template.
*
* @throws ResourceNotFoundException
*/
public function getResourceTemplate(string $uriTemplate): ResourceTemplateReference;
/**
* @return bool true if any prompts are registered
*/
public function hasPrompts(): bool;
/**
* Gets all registered prompts.
*/
public function getPrompts(?int $limit = null, ?string $cursor = null): Page;
/**
* Gets a prompt reference by name.
*
* @throws PromptNotFoundException
*/
public function getPrompt(string $name): PromptReference;
}

View file

@ -18,6 +18,7 @@ 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\Capability\RegistryInterface;
use Mcp\JsonRpc\MessageFactory;
use Mcp\Schema\Annotations;
use Mcp\Schema\Enum\ProtocolVersion;
@ -47,6 +48,8 @@ final class Builder
{
private ?Implementation $serverInfo = null;
private RegistryInterface $registry;
private ?LoggerInterface $logger = null;
private ?CacheInterface $discoveryCache = null;
@ -248,6 +251,13 @@ final class Builder
return $this;
}
public function setRegistry(RegistryInterface $registry): self
{
$this->registry = $registry;
return $this;
}
/**
* Provides a PSR-3 logger instance. Defaults to NullLogger.
*/
@ -440,7 +450,7 @@ final class Builder
{
$logger = $this->logger ?? new NullLogger();
$container = $this->container ?? new Container();
$registry = new Registry($this->eventDispatcher, $logger);
$registry = $this->registry ?? new Registry($this->eventDispatcher, $logger);
$loaders = [
...$this->loaders,
@ -455,16 +465,22 @@ final class Builder
$loader->load($registry);
}
if ($this->serverCapabilities) {
$registry->setServerCapabilities($this->serverCapabilities);
}
$sessionTtl = $this->sessionTtl ?? 3600;
$sessionFactory = $this->sessionFactory ?? new SessionFactory();
$sessionStore = $this->sessionStore ?? new InMemorySessionStore($sessionTtl);
$messageFactory = MessageFactory::make();
$capabilities = $registry->getCapabilities();
$capabilities = $this->serverCapabilities ?? new ServerCapabilities(
tools: $registry->hasTools(),
toolsListChanged: $this->eventDispatcher instanceof EventDispatcherInterface,
resources: $registry->hasResources() || $registry->hasResourceTemplates(),
resourcesSubscribe: false,
resourcesListChanged: $this->eventDispatcher instanceof EventDispatcherInterface,
prompts: $registry->hasPrompts(),
promptsListChanged: $this->eventDispatcher instanceof EventDispatcherInterface,
logging: false,
completions: true,
);
$configuration = new Configuration($this->serverInfo, $capabilities, $this->paginationLimit, $this->instructions, $this->protocolVersion);
$referenceHandler = new ReferenceHandler($container);

View file

@ -12,7 +12,7 @@
namespace Mcp\Server\Handler\Request;
use Mcp\Capability\Registry\ReferenceHandlerInterface;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\ToolCallException;
use Mcp\Exception\ToolNotFoundException;
use Mcp\Schema\Content\TextContent;
@ -34,7 +34,7 @@ use Psr\Log\NullLogger;
final class CallToolHandler implements RequestHandlerInterface
{
public function __construct(
private readonly ReferenceProviderInterface $referenceProvider,
private readonly RegistryInterface $registry,
private readonly ReferenceHandlerInterface $referenceHandler,
private readonly LoggerInterface $logger = new NullLogger(),
) {
@ -58,7 +58,7 @@ final class CallToolHandler implements RequestHandlerInterface
$this->logger->debug('Executing tool', ['name' => $toolName, 'arguments' => $arguments]);
try {
$reference = $this->referenceProvider->getTool($toolName);
$reference = $this->registry->getTool($toolName);
$arguments['_session'] = $session;

View file

@ -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;

View file

@ -12,7 +12,7 @@
namespace Mcp\Server\Handler\Request;
use Mcp\Capability\Registry\ReferenceHandlerInterface;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\PromptGetException;
use Mcp\Exception\PromptNotFoundException;
use Mcp\Schema\JsonRpc\Error;
@ -32,7 +32,7 @@ use Psr\Log\NullLogger;
final class GetPromptHandler implements RequestHandlerInterface
{
public function __construct(
private readonly ReferenceProviderInterface $referenceProvider,
private readonly RegistryInterface $registry,
private readonly ReferenceHandlerInterface $referenceHandler,
private readonly LoggerInterface $logger = new NullLogger(),
) {
@ -54,7 +54,7 @@ final class GetPromptHandler implements RequestHandlerInterface
$arguments = $request->arguments ?? [];
try {
$reference = $this->referenceProvider->getPrompt($promptName);
$reference = $this->registry->getPrompt($promptName);
$arguments['_session'] = $session;

View file

@ -11,7 +11,7 @@
namespace Mcp\Server\Handler\Request;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\InvalidCursorException;
use Mcp\Schema\JsonRpc\Request;
use Mcp\Schema\JsonRpc\Response;
@ -27,7 +27,7 @@ use Mcp\Server\Session\SessionInterface;
final class ListPromptsHandler implements RequestHandlerInterface
{
public function __construct(
private readonly ReferenceProviderInterface $registry,
private readonly RegistryInterface $registry,
private readonly int $pageSize = 20,
) {
}

View file

@ -11,7 +11,7 @@
namespace Mcp\Server\Handler\Request;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\InvalidCursorException;
use Mcp\Schema\JsonRpc\Request;
use Mcp\Schema\JsonRpc\Response;
@ -27,7 +27,7 @@ use Mcp\Server\Session\SessionInterface;
final class ListResourceTemplatesHandler implements RequestHandlerInterface
{
public function __construct(
private readonly ReferenceProviderInterface $registry,
private readonly RegistryInterface $registry,
private readonly int $pageSize = 20,
) {
}

View file

@ -11,7 +11,7 @@
namespace Mcp\Server\Handler\Request;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\InvalidCursorException;
use Mcp\Schema\JsonRpc\Request;
use Mcp\Schema\JsonRpc\Response;
@ -27,7 +27,7 @@ use Mcp\Server\Session\SessionInterface;
final class ListResourcesHandler implements RequestHandlerInterface
{
public function __construct(
private readonly ReferenceProviderInterface $registry,
private readonly RegistryInterface $registry,
private readonly int $pageSize = 20,
) {
}

View file

@ -11,7 +11,7 @@
namespace Mcp\Server\Handler\Request;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\InvalidCursorException;
use Mcp\Schema\JsonRpc\Request;
use Mcp\Schema\JsonRpc\Response;
@ -28,7 +28,7 @@ use Mcp\Server\Session\SessionInterface;
final class ListToolsHandler implements RequestHandlerInterface
{
public function __construct(
private readonly ReferenceProviderInterface $registry,
private readonly RegistryInterface $registry,
private readonly int $pageSize = 20,
) {
}

View file

@ -12,8 +12,8 @@
namespace Mcp\Server\Handler\Request;
use Mcp\Capability\Registry\ReferenceHandlerInterface;
use Mcp\Capability\Registry\ReferenceProviderInterface;
use Mcp\Capability\Registry\ResourceTemplateReference;
use Mcp\Capability\RegistryInterface;
use Mcp\Exception\ResourceNotFoundException;
use Mcp\Exception\ResourceReadException;
use Mcp\Schema\JsonRpc\Error;
@ -33,7 +33,7 @@ use Psr\Log\NullLogger;
final class ReadResourceHandler implements RequestHandlerInterface
{
public function __construct(
private readonly ReferenceProviderInterface $referenceProvider,
private readonly RegistryInterface $referenceProvider,
private readonly ReferenceHandlerInterface $referenceHandler,
private readonly LoggerInterface $logger = new NullLogger(),
) {