Add cursor pagination to list methods (tools/list etc.) #12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add cursor-based pagination to list methods (
tools/list, and eventuallyresources/list,prompts/list,resources/templates/list).Goal
The MCP spec defines list methods as cursor-paginated: response carries optional
nextCursor; request carries optionalcursor. lmcp'stools/listreturns everything at once with no cursor field. This is non-conformant — strict clients may reject the response shape or fail to handle a server that suddenly grows past their default page.Method signatures to align
tools/listparams.cursor(opaque string)result.nextCursor(opaque string, optional)resources/list,prompts/list,resources/templates/listAPI for lmcp
No surface change for tool authors. Server-side: implement a
paginate(items, cursor, limit)helper that:cursor(e.g. base64-encoded offset string),(page, next_cursor_or_nil).Default page size: 50 (well above today's tool count; mostly a contract-conformance change).
Cursor format
Opaque to clients per spec. lmcp can use
b64(offset)orb64(last_name)— implementation detail. Don't expose offset semantics.Scope (v1)
cursorparam parsing andnextCursoremission totools/list.paginate()helper.resources/list/prompts/listetc. as those land — or piggyback on this issue and update once Resources/Prompts merge.Out of scope
Priority
Low. Pure conformance fix; no current-user impact (no lmcp server is anywhere near 50 tools). Hour of work.
Implemented.
paginate(items, cursor)helper in lmcp.lua; wired intotools/list,resources/list,resources/templates/list. Default page size 50. Cursor is opaque base64(offset).Verified with 60-tool synthetic server: page 1 returns 50 + nextCursor
NTA=(base64 of50); page 2 returns 10, no nextCursor. Malformed cursors are tolerated (treated as offset 0). Backwards-compatible: requests with no cursor param work as before.Production server.lua (9 tools) emits no nextCursor — still single-page, contract is now spec-conformant.