Skip to content

List methods accept cursor: false and return the first page #751

Backlog

Description

@yorzi

Describe the bug

The shared paginator checks the cursor only when it is truthy. A JSON false cursor therefore skips the check and returns the first page, while a number such as 1 gets Invalid Params (-32602). The cursor is a string in the schema. The same paginator serves tools/list, prompts/list, resources/list, resources/templates/list and the Skills extension's skills/list, with or without page_size; the script below shows the first four.

To Reproduce

Save as repro.rb in the repository root and run bundle exec ruby -Ilib repro.rb on main (2e07497):

require "json"
require "mcp"

server = MCP::Server.new(
  name: "repro",
  version: "1.0",
  tools: [MCP::Tool.define(name: "t") {}],
  prompts: [MCP::Prompt.define(name: "p") {}],
  resources: [MCP::Resource.new(uri: "file:///a", name: "a")],
  resource_templates: [MCP::ResourceTemplate.new(uri_template: "file:///{x}", name: "x")],
)

["tools/list", "prompts/list", "resources/list", "resources/templates/list"].each do |method|
  [false, 1, nil].each do |cursor|
    response = JSON.parse(server.handle_json(JSON.generate({ jsonrpc: "2.0", id: 1, method: method, params: { cursor: cursor } })))
    outcome = response["error"] ? "error #{response["error"]["code"]}" : "result"
    puts "#{method} cursor: #{cursor.to_json} => #{outcome}"
  end
end

Expected behavior

cursor: false gets -32602, as cursor: 1 does. An absent or null cursor still returns the first page.

Logs

tools/list cursor: false => result
tools/list cursor: 1 => error -32602
tools/list cursor: null => result
prompts/list cursor: false => result
prompts/list cursor: 1 => error -32602
prompts/list cursor: null => result
resources/list cursor: false => result
resources/list cursor: 1 => error -32602
resources/list cursor: null => result
resources/templates/list cursor: false => result
resources/templates/list cursor: 1 => error -32602
resources/templates/list cursor: null => result

Additional context

Ruby 4.0.10. I have a fix with tests and will open a PR for it.

Activity

  1. added
    bug
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions