1111
1212namespace Mcp \Server \Capability ;
1313
14- use Mcp \Schema \Page ;
15- use Mcp \Schema \Prompt ;
16- use Mcp \Schema \ResourceDefinition ;
17- use Mcp \Schema \ResourceTemplate ;
18- use Mcp \Schema \Tool ;
19- use Mcp \Server \Capability \Registry \ElementReference ;
20- use Mcp \Server \Capability \Registry \PromptReference ;
21- use Mcp \Server \Capability \Registry \ResourceReference ;
2214use Mcp \Server \Capability \Registry \ResourceTemplateReference ;
23- use Mcp \Server \Capability \Registry \ToolReference ;
24- use Mcp \Server \Exception \ConfigurationException ;
25- use Mcp \Server \Exception \PromptNotFoundException ;
2615use Mcp \Server \Exception \ResourceNotFoundException ;
27- use Mcp \Server \Exception \ToolNotFoundException ;
2816use Mcp \Server \Subscription \PublishingEventDispatcher ;
2917
3018/**
31- * @phpstan-import-type Handler from ElementReference
32- *
3319 * @author Kyrian Obikwelu <koshnawaza@gmail.com>
3420 * @author Christopher Hertel <mail@christopher-hertel.de>
3521 */
36- interface RegistryInterface
22+ interface RegistryInterface extends ElementCatalogInterface, ElementResolverInterface, ElementWriterInterface
3723{
38- /**
39- * Registers a tool with its handler. Overwrites any prior registration of the same name.
40- * Returns the stored reference, whose identity callers may track to detect later overwrites.
41- *
42- * @param Handler $handler
43- */
44- public function registerTool (Tool $ tool , callable |array |string $ handler ): ToolReference ;
45-
46- /**
47- * Registers a resource with its handler. Overwrites any prior registration of the same URI.
48- * Returns the stored reference, whose identity callers may track to detect later overwrites.
49- *
50- * @param Handler $handler
51- */
52- public function registerResource (ResourceDefinition $ resource , callable |array |string $ handler ): ResourceReference ;
53-
54- /**
55- * Registers a resource template with its handler and completion providers.
56- * Overwrites any prior registration of the same URI template.
57- * Returns the stored reference, whose identity callers may track to detect later overwrites.
58- *
59- * @param Handler $handler
60- * @param array<string, class-string|object> $completionProviders
61- */
62- public function registerResourceTemplate (
63- ResourceTemplate $ template ,
64- callable |array |string $ handler ,
65- array $ completionProviders = [],
66- ): ResourceTemplateReference ;
67-
68- /**
69- * Registers a prompt with its handler and completion providers.
70- * Overwrites any prior registration of the same name.
71- * Returns the stored reference, whose identity callers may track to detect later overwrites.
72- *
73- * @param Handler $handler
74- * @param array<string, class-string|object> $completionProviders
75- */
76- public function registerPrompt (
77- Prompt $ prompt ,
78- callable |array |string $ handler ,
79- array $ completionProviders = [],
80- ): PromptReference ;
81-
82- /**
83- * Removes a tool by name. No-op if absent.
84- */
85- public function unregisterTool (string $ name ): void ;
86-
87- /**
88- * Removes a resource by URI. No-op if absent.
89- */
90- public function unregisterResource (string $ uri ): void ;
91-
92- /**
93- * Removes a resource template by URI template. No-op if absent.
94- */
95- public function unregisterResourceTemplate (string $ uriTemplate ): void ;
96-
97- /**
98- * Removes a prompt by name. No-op if absent.
99- */
100- public function unregisterPrompt (string $ name ): void ;
101-
10224 /**
10325 * Whether list changes reach a notification bus, e.g. through a {@see PublishingEventDispatcher}.
10426 * A decorator forwards the answer of the registry it wraps.
@@ -118,75 +40,25 @@ public function hasPrompt(string $name): bool;
11840 */
11941 public function hasTools (): bool ;
12042
121- /**
122- * Gets all registered tools.
123- *
124- * @return Page<Tool>
125- */
126- public function getTools (?int $ limit = null , ?string $ cursor = null ): Page ;
127-
128- /**
129- * Gets a tool reference by name.
130- *
131- * @throws ToolNotFoundException
132- * @throws ConfigurationException when the elements fail to load
133- */
134- public function getTool (string $ name ): ToolReference ;
135-
13643 /**
13744 * @return bool true if any resources are registered
13845 */
13946 public function hasResources (): bool ;
14047
141- /**
142- * Gets all registered resources.
143- *
144- * @return Page<ResourceDefinition>
145- */
146- public function getResources (?int $ limit = null , ?string $ cursor = null ): Page ;
147-
148- /**
149- * Gets a resource reference by URI (includes template matching if enabled).
150- *
151- * @throws ResourceNotFoundException
152- */
153- public function getResource (string $ uri , bool $ includeTemplates = true ): ResourceReference |ResourceTemplateReference ;
154-
15548 /**
15649 * @return bool true if any resource templates are registered
15750 */
15851 public function hasResourceTemplates (): bool ;
15952
16053 /**
161- * Gets all registered resource templates.
162- *
163- * @return Page<ResourceTemplate>
54+ * @return bool true if any prompts are registered
16455 */
165- public function getResourceTemplates (? int $ limit = null , ? string $ cursor = null ): Page ;
56+ public function hasPrompts ( ): bool ;
16657
16758 /**
16859 * Gets a resource template reference by URI template.
16960 *
17061 * @throws ResourceNotFoundException
17162 */
17263 public function getResourceTemplate (string $ uriTemplate ): ResourceTemplateReference ;
173-
174- /**
175- * @return bool true if any prompts are registered
176- */
177- public function hasPrompts (): bool ;
178-
179- /**
180- * Gets all registered prompts.
181- *
182- * @return Page<Prompt>
183- */
184- public function getPrompts (?int $ limit = null , ?string $ cursor = null ): Page ;
185-
186- /**
187- * Gets a prompt reference by name.
188- *
189- * @throws PromptNotFoundException
190- */
191- public function getPrompt (string $ name ): PromptReference ;
19264}
0 commit comments