Skip to content

Conversation

@bigdevlarry
Copy link
Contributor

@bigdevlarry bigdevlarry commented Sep 9, 2025

Implements MCP pagination for tools/list, prompts/list, and resources/list endpoints.

  • Added pagination support to ListToolsHandler, ListPromptsHandler, ListResourcesHandler
  • Enhanced Registry with pagination methods and cursor calculation
  • Added comprehensive unit tests for all pagination scenarios
  • Added proper exception handling with @throws annotations
  • Regenerate new phpstan baseline with - vendor/bin/phpstan analyse --generate-baseline

Motivation and Context

The change was raised as an issue to enable the list request to have pagination support.

How Has This Been Tested?

Yes, this has been tested.

Breaking Changes

No, users don't need to make any updates

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@bigdevlarry
Copy link
Contributor Author

Hi @chr-hertel,I have opened a PR to address the issue related to pagination.

@chr-hertel
Copy link
Member

Thanks @bigdevlarry for jumping on that 👍

I think this should wait for #46 as well - you could basically use that as a base branch already

@chr-hertel
Copy link
Member

#46 got merged, needs a rebase

@bigdevlarry
Copy link
Contributor Author

@chr-hertel this is back up for review again

@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Sep 21, 2025
@chr-hertel chr-hertel changed the title BugFix - Pagination of List requests [Server][Bug] Pagination of List requests Sep 21, 2025
/**
* @implements \ArrayAccess<int|string, mixed>
*/
final class Page implements \Countable, \ArrayAccess
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about extending ArrayObject instead? would maybe ease some stuff

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was testing this with adding more tools to example no1 and added the pagination limit on the builder - this still needs to be taken into account here - or do we better split into a follow-up PR?

anyhow, this needs a rebase after #49 and #46

Thanks already @bigdevlarry!

@chr-hertel
Copy link
Member

Oh, and can you please make sure to squash this into a single, signed commit please

@bigdevlarry
Copy link
Contributor Author

@chr-hertel I think we should split it into another PR once this one gets merged.

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
@chr-hertel chr-hertel force-pushed the Server-pagination-of-fixed-requests branch from 3e63cc8 to 49e2834 Compare September 24, 2025 19:42
Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bigdevlarry - I squashed and rebased - let's get this merged!

@chr-hertel chr-hertel merged commit 325b4aa into modelcontextprotocol:main Sep 24, 2025
9 checks passed
@bigdevlarry bigdevlarry deleted the Server-pagination-of-fixed-requests branch September 25, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Server Issues & PRs related to the Server component Status: Needs Work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants