Snodo.Pagination (snodo v0.1.0)

Copy Markdown View Source

Stateless, protocol-neutral pagination for MCP list operations.

Routers continue to return complete, deterministically ordered catalogs. The server applies this policy after dispatch, issuing opaque cursors scoped to the protocol version, list operation, configured page size, and exact catalog contents. A catalog change therefore expires outstanding cursors instead of risking duplicate or skipped entries.

Summary

Functions

Builds and validates an immutable pagination policy.

Returns one page and attaches a next cursor to result metadata when more entries remain.

Types

operation()

@type operation() ::
  :tools_list | :prompts_list | :resources_list | :resource_templates_list

t()

@type t() :: %Snodo.Pagination{page_size: pos_integer()}

Functions

new(pagination)

@spec new(keyword() | t()) :: t()

Builds and validates an immutable pagination policy.

page(result, protocol_version, operation, params, pagination)

@spec page(Snodo.Result.t(), String.t(), operation(), map(), t()) ::
  {:ok, Snodo.Result.t()} | {:error, Snodo.Error.t()}

Returns one page and attaches a next cursor to result metadata when more entries remain.