Skip to main content

MCP Pagination Module

The MCP Server V2 implements pagination for tools/list, resources/list, and prompts/list endpoints per the MCP 2025-11-25 specification.

Overview

Pagination uses opaque cursors (base64url encoded) that the server generates. Clients cannot determine page size - the server decides based on its configuration. Key Features:
  • Default page size: 50 items
  • Maximum page size: 100 items
  • Opaque cursor encoding (base64url)
  • Invalid cursor validation with JSON-RPC errors

Code Usage

Basic Pagination

Custom Page Size

Cursor Utilities

Resource and Prompt Pagination

Server Handler Integration

The MCP server automatically handles pagination in the protocol handlers:

Error Handling

Invalid cursors raise ValueError:
The server converts this to a JSON-RPC error with code -32602 (Invalid params).

MCP Protocol Compliance

This implementation follows MCP 2025-11-25 specification:

Constants

See Also