-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathRegistryInterface.php
More file actions
160 lines (138 loc) · 4.47 KB
/
RegistryInterface.php
File metadata and controls
160 lines (138 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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;
}