Skip to content

fix: reject false pagination cursors - #758

Open
yorzi wants to merge 1 commit into
modelcontextprotocol:mainfrom
yorzi:fix/reject-false-pagination-cursor
Open

yorzi wants to merge 1 commit into
modelcontextprotocol:mainfrom
yorzi:fix/reject-false-pagination-cursor

Conversation

@yorzi

@yorzi yorzi commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Pagination#paginate validated the cursor under if cursor, so false skipped validation and was read as no cursor. It now validates every cursor that is not nil. A missing or null cursor still starts at the first page, and string cursors are handled as before.

Fixes #751

How Has This Been Tested?

  • test/mcp/server/pagination_test.rb: paginate raises Invalid Params for false without a page size.
  • test/mcp/server_test.rb: tools/list and prompts/list answer -32602 for cursor: false through handle_json.
  • Both tests fail on main.
  • With this change the script in the issue gets -32602 for false from all four methods, and null still returns a result.

bundle exec rake passes on Ruby 4.0.10 (RuboCop, 2859 runs with 0 failures, and the conformance baseline). yard --no-output passes.

  • Automated unit / integration tests
  • Tested manually
  • Tested in a real application

Breaking Changes

A request with cursor: false now gets Invalid Params instead of the first page. Other requests are unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Test update (non-breaking change which adds or updates tests)
  • Refactoring (non-breaking change which makes things better)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • CI/build script update (update CI workflow or build scripts)

Checklist

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

Validate every non-nil cursor before decoding the offset. Keep the
existing behavior for string cursors, absent cursors and explicit null.

Fixes modelcontextprotocol#751.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List methods accept cursor: false and return the first page

1 participant