-
Notifications
You must be signed in to change notification settings - Fork 352
feat: Add Pagination for server requests #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add Pagination for server requests #140
Conversation
4c05e1a
to
8d48b93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution! It is a great start, would you like to take this further and unify the logic for other listing requests?
mcp/src/main/java/io/modelcontextprotocol/spec/McpParamsValidationError.java
Outdated
Show resolved
Hide resolved
mcp/src/main/java/io/modelcontextprotocol/spec/McpParamsValidationError.java
Outdated
Show resolved
Hide resolved
mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java
Outdated
Show resolved
Hide resolved
mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java
Outdated
Show resolved
Hide resolved
Hi, thanks for your review and your feedback!
Yes I will do this. I should be able to update the pull request by the end of the week. |
3dce44d
to
0c93c71
Compare
0c93c71
to
b02db82
Compare
I did another push with small changes in the commit title and message and have also changed a few comments and names in tests. No business logic was affected. |
3718965
to
5f7bb9b
Compare
Adds the Pagination feature as described in the specification for prompts, resources, resource templates and tools. To make this possible mainly two changes are made: 1. The logic for cursor handling is added. 2. Handling for invalid parameters (MCP error code `-32602 (Invalid params)`) is added to the `McpServerSession`. For now the cursor is the base64 encoded start index of the next page and the hash value of the collection at time of computing. The page size is set to 10. When parameters are found to be invalid the newly introduced `McpParamsValidationError` is returned to handle it properly in the `McpServerSession`.
5f7bb9b
to
094088d
Compare
Adds the Pagination feature to the
prompts/list
feature to fulfil the specification.Motivation and Context
This adds the Pagination feature to the
prompts/list
feature as described in the specification.To make this possible mainly two changes are made:
-32602 (Invalid params)
) is added to theMcpServerSession
.Decisions made:
base64
string.10
.McpParamsValidationError
is returned to handle it properly in theMcpServerSession
.If this change is ok, I'm happy to create a follow-up PR for the other MCP features. Maybe some parts of the cursor handling can be moved out to separate methods.
How Has This Been Tested?
Integration tests are added for the
prompts/list
feature.Types of changes
Checklist