Interface McpCursor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Pagination strategy for MCP
list dispatchers (tools / prompts / resources / resource templates).
Built-in strategies:
SINGLE_PAGE- Returns everything in one page (default; ignores any incoming cursor).fixedSize(int)- Slices a list into pages of a fixed size using opaque integer cursors.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final McpCursorReturns everything in a single page; emits nonextCursor. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringExtracts the opaque pagination cursor from a JSON-RPCparamsvalue.static McpCursorfixedSize(int pageSize) Returns a fixed-page-size cursor.<T> McpPage<T>Slices a descriptor list into a page returned fromtools/list,prompts/list,resources/list, orresources/templates/list.static intparseOffset(String cursor) Parses a cursor as a non-negative integer offset; returns0fornullor non-numeric inputs.
-
Field Details
-
SINGLE_PAGE
Returns everything in a single page; emits nonextCursor.
-
-
Method Details
-
page
Slices a descriptor list into a page returned fromtools/list,prompts/list,resources/list, orresources/templates/list.- Type Parameters:
T- Element type.- Parameters:
all- The full list of descriptors. Nevernull.cursor- Opaque cursor from the request, ornullfor the first page.ctx- Per-request bean store (provided for cursor strategies that need access to the request).- Returns:
- A non-
nullpage.
-
fixedSize
Returns a fixed-page-size cursor.Cursor representation is an opaque integer offset (parsed leniently; non-numeric values restart at offset 0).
- Parameters:
pageSize- Maximum items per page. Must be> 0.- Returns:
- A new cursor strategy.
-
parseOffset
Parses a cursor as a non-negative integer offset; returns0fornullor non-numeric inputs.- Parameters:
cursor- Cursor value (may benull).- Returns:
- Parsed offset.
-
cursorOf
Extracts the opaque pagination cursor from a JSON-RPCparamsvalue.- Parameters:
params- The raw params value from the request. Can benull .- Returns:
- The
cursorparameter, ornull if absent. - Throws:
McpException- Ifparamsis present but is not a JSON object.
-