pagination

package
v0.40.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pagination provides a helper for following MCP list-pagination cursors when querying backends.

MCP list operations (tools/list, resources/list, prompts/list) are paginated: a result may carry a NextCursor pointing at the next page, and a client that issues a single request without following the cursor silently drops every item beyond the first page. Backends served by the toolhive-core mcpcompat server paginate at DefaultPageSize=1000, so any backend advertising more than 1000 tools/resources/prompts would lose the tail without cursor following.

This package lives under pkg/vmcp/internal so both pkg/vmcp/client and pkg/vmcp/session can depend on it without introducing an import cycle (pkg/vmcp/client already imports pkg/vmcp/session).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListAll

func ListAll[T any](
	ctx context.Context,
	fetch func(ctx context.Context, cursor mcp.Cursor) (items []T, next mcp.Cursor, err error),
) ([]T, error)

ListAll repeatedly invokes fetch, following the MCP pagination cursor, until the backend returns an empty next cursor. It accumulates and returns every item across all pages.

fetch is called with the cursor for the page to retrieve (empty on the first call) and must return that page's items, the cursor for the next page (empty when no more pages remain), and any error. A fetch error is returned to the caller immediately.

ListAll guards against a misbehaving backend in two ways: it returns an error if the same non-empty cursor is seen twice (a cycle), and it caps the total number of pages at maxIterations.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL