Skip to content

Commit e7dd120

Browse files
author
larry.sulebalogun
committed
10 - Created a reference directory for the Page DTO
1 parent 5d5ea13 commit e7dd120

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

src/Capability/Registry.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use Mcp\Schema\ResourceTemplate;
2828
use Mcp\Schema\ServerCapabilities;
2929
use Mcp\Schema\Tool;
30-
use Mcp\Server\RequestHandler\ReferencePage;
30+
use Mcp\Server\RequestHandler\Reference\Page;
3131
use Psr\EventDispatcher\EventDispatcherInterface;
3232
use Psr\Log\LoggerInterface;
3333
use Psr\Log\NullLogger;
@@ -248,15 +248,15 @@ public function getPrompt(string $name): ?PromptReference
248248
/**
249249
* Gets all registered tools.
250250
*/
251-
public function getTools(?int $limit = null, ?string $cursor = null): ReferencePage
251+
public function getTools(?int $limit = null, ?string $cursor = null): Page
252252
{
253253
$tools = [];
254254
foreach ($this->tools as $toolReference) {
255255
$tools[$toolReference->tool->name] = $toolReference->tool;
256256
}
257257

258258
if (null === $limit) {
259-
return new ReferencePage($tools, null);
259+
return new Page($tools, null);
260260
}
261261

262262
$paginatedTools = $this->paginateResults($tools, $limit, $cursor);
@@ -267,21 +267,21 @@ public function getTools(?int $limit = null, ?string $cursor = null): ReferenceP
267267
$limit
268268
);
269269

270-
return new ReferencePage($paginatedTools, $nextCursor);
270+
return new Page($paginatedTools, $nextCursor);
271271
}
272272

273273
/**
274274
* Gets all registered resources.
275275
*/
276-
public function getResources(?int $limit = null, ?string $cursor = null): ReferencePage
276+
public function getResources(?int $limit = null, ?string $cursor = null): Page
277277
{
278278
$resources = [];
279279
foreach ($this->resources as $resourceReference) {
280280
$resources[$resourceReference->schema->uri] = $resourceReference->schema;
281281
}
282282

283283
if (null === $limit) {
284-
return new ReferencePage($resources, null);
284+
return new Page($resources, null);
285285
}
286286

287287
$paginatedResources = $this->paginateResults($resources, $limit, $cursor);
@@ -292,21 +292,21 @@ public function getResources(?int $limit = null, ?string $cursor = null): Refere
292292
$limit
293293
);
294294

295-
return new ReferencePage($paginatedResources, $nextCursor);
295+
return new Page($paginatedResources, $nextCursor);
296296
}
297297

298298
/**
299299
* Gets all registered prompts.
300300
*/
301-
public function getPrompts(?int $limit = null, ?string $cursor = null): ReferencePage
301+
public function getPrompts(?int $limit = null, ?string $cursor = null): Page
302302
{
303303
$prompts = [];
304304
foreach ($this->prompts as $promptReference) {
305305
$prompts[$promptReference->prompt->name] = $promptReference->prompt;
306306
}
307307

308308
if (null === $limit) {
309-
return new ReferencePage($prompts, null);
309+
return new Page($prompts, null);
310310
}
311311

312312
$paginatedPrompts = $this->paginateResults($prompts, $limit, $cursor);
@@ -317,21 +317,21 @@ public function getPrompts(?int $limit = null, ?string $cursor = null): Referenc
317317
$limit
318318
);
319319

320-
return new ReferencePage($paginatedPrompts, $nextCursor);
320+
return new Page($paginatedPrompts, $nextCursor);
321321
}
322322

323323
/**
324324
* Gets all registered resource templates.
325325
*/
326-
public function getResourceTemplates(?int $limit = null, ?string $cursor = null): ReferencePage
326+
public function getResourceTemplates(?int $limit = null, ?string $cursor = null): Page
327327
{
328328
$templates = [];
329329
foreach ($this->resourceTemplates as $templateReference) {
330330
$templates[$templateReference->resourceTemplate->uriTemplate] = $templateReference->resourceTemplate;
331331
}
332332

333333
if (null === $limit) {
334-
return new ReferencePage($templates, null);
334+
return new Page($templates, null);
335335
}
336336

337337
$paginatedTemplates = $this->paginateResults($templates, $limit, $cursor);
@@ -342,7 +342,7 @@ public function getResourceTemplates(?int $limit = null, ?string $cursor = null)
342342
$limit
343343
);
344344

345-
return new ReferencePage($paginatedTemplates, $nextCursor);
345+
return new Page($paginatedTemplates, $nextCursor);
346346
}
347347

348348
public function hasElements(): bool

src/Capability/Registry/ReferenceProviderInterface.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
namespace Mcp\Capability\Registry;
1313

14-
use Mcp\Schema\Prompt;
15-
use Mcp\Schema\Tool;
16-
use Mcp\Server\RequestHandler\ReferencePage;
14+
use Mcp\Server\RequestHandler\Reference\Page;
1715

1816
/**
1917
* Interface for providing access to registered MCP elements.
@@ -46,22 +44,22 @@ public function getPrompt(string $name): ?PromptReference;
4644
/**
4745
* Gets all registered tools.
4846
*/
49-
public function getTools(?int $limit = null, ?string $cursor = null): ReferencePage;
47+
public function getTools(?int $limit = null, ?string $cursor = null): Page;
5048

5149
/**
5250
* Gets all registered resources.
5351
*/
54-
public function getResources(?int $limit = null, ?string $cursor = null): ReferencePage;
52+
public function getResources(?int $limit = null, ?string $cursor = null): Page;
5553

5654
/**
5755
* Gets all registered prompts.
5856
*/
59-
public function getPrompts(?int $limit = null, ?string $cursor = null): ReferencePage;
57+
public function getPrompts(?int $limit = null, ?string $cursor = null): Page;
6058

6159
/**
6260
* Gets all registered resource templates.
6361
*/
64-
public function getResourceTemplates(?int $limit = null, ?string $cursor = null): ReferencePage;
62+
public function getResourceTemplates(?int $limit = null, ?string $cursor = null): Page;
6563

6664
/**
6765
* Checks if any elements (manual or discovered) are currently registered.

src/Server/RequestHandler/ReferencePage.php renamed to src/Server/RequestHandler/Reference/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Mcp\Server\RequestHandler;
12+
namespace Mcp\Server\RequestHandler\Reference;
1313

1414
/**
1515
* @implements \ArrayAccess<int|string, mixed>
1616
*/
17-
final class ReferencePage implements \Countable, \ArrayAccess
17+
final class Page implements \Countable, \ArrayAccess
1818
{
1919
/**
2020
* @param array<int|string, mixed> $references Items can be Tool, Prompt, ResourceTemplate, or Resource

0 commit comments

Comments
 (0)