Summary
The high-level McpServer class does not implement cursor-based pagination for tools/list, resources/list, resources/templates/list, or prompts/list. All registered items are returned in a single response regardless of set size.
Spec Reference
The MCP pagination specification defines an opaque cursor-based pagination model where:
- Servers return a page of results along with an optional
nextCursor field
- Clients continue paginating by including the cursor in subsequent requests
- Page size is determined by the server
The following operations are expected to support pagination:
resources/list
resources/templates/list
prompts/list
tools/list
Current Behavior
In mcp.ts, all three list handlers return the complete set without reading the cursor request parameter or returning nextCursor:
// tools/list — returns everything
this.server.setRequestHandler('tools/list', (): ListToolsResult => ({
tools: Object.entries(this._registeredTools).filter(...).map(...)
}));
// resources/list — returns everything
this.server.setRequestHandler('resources/list', async (_request, ctx) => {
// ...
return { resources: [...resources, ...templateResources] };
});
// prompts/list — returns everything
this.server.setRequestHandler('prompts/list', (): ListPromptsResult => ({
prompts: Object.entries(this._registeredPrompts).filter(...).map(...)
}));
Notes
- The client (
packages/client) already handles paginated responses correctly (loops on nextCursor).
- The type system already defines nextCursor in PaginatedResultSchema (
schemas.ts).
- Users can work around this by using the low-level Server class and implementing their own list handlers with cursor logic, but
McpServer provides no built-in mechanism or configuration for it.
I'd be happy to open a PR for this if the maintainers are aligned with the need.
Summary
The high-level McpServer class does not implement cursor-based pagination for
tools/list,resources/list,resources/templates/list, orprompts/list. All registered items are returned in a single response regardless of set size.Spec Reference
The MCP pagination specification defines an opaque cursor-based pagination model where:
nextCursorfieldThe following operations are expected to support pagination:
resources/listresources/templates/listprompts/listtools/listCurrent Behavior
In
mcp.ts, all three list handlers return the complete set without reading the cursor request parameter or returning nextCursor:Notes
packages/client) already handles paginated responses correctly (loops onnextCursor).schemas.ts).McpServerprovides no built-in mechanism or configuration for it.I'd be happy to open a PR for this if the maintainers are aligned with the need.