feat(pagination): cursor-based pagination + two-phase tool discovery#6
Merged
feat(pagination): cursor-based pagination + two-phase tool discovery#6
Conversation
Adds opt-in pagination for tools/list and two-phase discovery (tools/list_summary + tools/describe) to reduce token overhead for MCP clients with many tools. - Cursor-based pagination (MCP spec-compliant) with HMAC-signed cursors - No-cursor requests always return ALL tools (prevents silent tool loss) - Two-phase: tools/list_summary (name+description) + tools/describe (full schema) - PaginationConfig on ServerConfig with pageSize validation (>= 1) - Constant-time HMAC verification via crypto.subtle.verify() - Cached tool list (immutable after registration) - 102 tests, 100% line/statement/function coverage
- Reject NaN and non-integer floats for pageSize (Number.isInteger) - Wrap atob() in try-catch in hmacVerify for edge runtime compat - Update stale test comment
- Bump package.json to 0.2.0 - Add v0.2.0 CHANGELOG entry (pagination + two-phase + security) - Add pagination section to README API reference - Update CLAUDE.md and AGENTS.md with pagination architecture - Regenerate llms.txt and llms-full.txt with pagination API docs - Update default server version to 0.2.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools/list(MCP spec-compliant)tools/list_summary(name+description only) +tools/describe(full schema on-demand)paginationfield onServerConfigKey design decisions
tools/listwithout cursor always returns ALL tools — prevents silent tool loss for clients that don't support paginationcrypto.subtle.verify(), cross-method namespace prevents cursor reuseregisterTools()to avoid SDKassertCanSetRequestHandlerconflicttools/list_summary+tools/describeare custom MCP methods (community proposal #1923), documented as bespoke extensions targeting custom agentsFiles changed
src/pagination.tspaginateTools(),createPaginationContext()src/server.tstools/listhandler, register two-phase handlerssrc/types.tsPaginationConfiginterface +paginationonServerConfigsrc/index.tsPaginationConfig,ToolSummary,ToolPagetests/pagination.test.tsvitest.config.tsTest plan
setRequestHandleroverride works