fastmcp.utilities.pagination
Pagination utilities for MCP list operations.
Functions
paginate_sequence
items: The full sequence to paginate.cursor: Optional cursor from a previous request. None for first page.page_size: Maximum number of items per page.
- Tuple of (page_items, next_cursor). next_cursor is None if no more pages.
ValueError: If the cursor is invalid.
Classes
CursorState
Internal representation of pagination cursor state.
The cursor encodes the offset into the result set. This is opaque to clients
per the MCP spec - they should not parse or modify cursors.
Methods:
encode
decode
ValueError: If the cursor is invalid or malformed.

