Add support for pagination on list requests (#55)
10 - Added the list resources handler with test class 10 - Update the ListPromptsHandler to use annotations 10 - Add the list resource handler, and it's test as well 10 - Added the registry logic 10 - Added the list tools handler logic 10 - Fix all php-cs-fixer related issues 10 - Resolved phpstan issues for ListPromptsHandlerTest 10 - Resolved phpstan issues for ListToolsHandlerTest 10 - Resolved phpstan issues for ListResourcesHandlerTest 10 - Resolved phpstan issues in registry class 10 - Resolved phpstan issues for the handler class 10 - Resolved php cs fixer issues 10 - Resolved all phpstan issues by generating the baseline again 10 - Remove the two loop operation and use foreach for optimization 10 - Removed unused code and resolved namespace 10 - Add signatures to interface and registry 10 - Add updated phpstan rule set 10 - Arranged according to property type 10 - Introduce reference page DTO, fix all failing test 10 - Resolve cs-fixer issues 10 - Resolve phpstan issues 10 - Resolve php cs fixer issues 10 - Created a reference directory for the Page DTO 10 - Remove manual loop for clean code readability Co-authored-by: larry.sulebalogun <larry.sulebalogun@tillo.io>
This commit is contained in:
parent
4db831778b
commit
325b4aaf9c
1 changed files with 1016 additions and 131 deletions
|
|
@ -12,6 +12,7 @@
|
|||
namespace Mcp\Server\RequestHandler;
|
||||
|
||||
use Mcp\Capability\Registry\ReferenceProviderInterface;
|
||||
use Mcp\Exception\InvalidCursorException;
|
||||
use Mcp\Schema\JsonRpc\HasMethodInterface;
|
||||
use Mcp\Schema\JsonRpc\Response;
|
||||
use Mcp\Schema\Request\ListPromptsRequest;
|
||||
|
|
@ -35,17 +36,18 @@ final class ListPromptsHandler implements MethodHandlerInterface
|
|||
return $message instanceof ListPromptsRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidCursorException
|
||||
*/
|
||||
public function handle(ListPromptsRequest|HasMethodInterface $message, SessionInterface $session): Response
|
||||
{
|
||||
\assert($message instanceof ListPromptsRequest);
|
||||
|
||||
$cursor = null;
|
||||
$prompts = $this->registry->getPrompts($this->pageSize, $message->cursor);
|
||||
$nextCursor = (null !== $cursor && \count($prompts) === $this->pageSize) ? $cursor : null;
|
||||
$page = $this->registry->getPrompts($this->pageSize, $message->cursor);
|
||||
|
||||
return new Response(
|
||||
$message->getId(),
|
||||
new ListPromptsResult($prompts, $nextCursor),
|
||||
new ListPromptsResult($page->references, $page->nextCursor),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue