Skip to content

Form elicitation is sent to URL-only clients, and capabilities declared as false count as declared #728

Backlog

Description

@yorzi

Describe the bug

Three checks of the client's declared capabilities give a wrong answer:

  1. ServerSession#create_form_elicitation (lib/mcp/server_session.rb:257) only checks that elicitation is present, so a client declaring elicitation: { url: {} } is sent a form mode request. The specification says servers MUST NOT send elicitation requests with modes the client does not support (2025-11-25, 2026-07-28). The input_required check already refuses it.
  2. InputRequiredResult#missing_client_capabilities (lib/mcp/server/input_required_result.rb:121) and ServerContext#require_client_capability! (lib/mcp/server_context.rb:90) take a capability declared as false as declared, while the ServerSession checks take it as not declared.
  3. ServerSession#create_url_elicitation (lib/mcp/server_session.rb:279) raises TypeError when elicitation is not an object, instead of the documented RuntimeError.

The schema defines these capabilities as objects, so 2 and 3 need a client that sends invalid values. 1 needs only a conformant client.

To Reproduce

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

require "mcp"

class RecordingTransport < MCP::Transport
  def send_request(method, params = nil, **)
    puts "sent #{method} (#{params[:mode]})"
    { action: "decline" }
  end
end

def attempt
  yield
rescue => e
  puts "#{e.class}: #{e.message}"
end

server = MCP::Server.new(name: "repro", version: "1.0")
session = MCP::ServerSession.new(server: server, transport: RecordingTransport.new(server), session_id: "s")

# 1. A client that declares URL mode only is sent a form mode request.
session.store_client_info(client: {}, capabilities: { elicitation: { url: {} } })
attempt do
  session.create_form_elicitation(related_request_id: "1", message: "Name?", requested_schema: { type: "object", properties: {} })
end

# 2. A capability declared as `false` counts as declared: nothing is reported missing.
result = MCP::Server::InputRequiredResult.new(input_requests: { r: { method: "roots/list" } })
p result.missing_client_capabilities({ roots: false })

# 3. A scalar declaration raises TypeError instead of the documented RuntimeError.
session.store_client_info(client: {}, capabilities: { elicitation: true })
attempt do
  session.create_url_elicitation(related_request_id: "1", message: "Sign in", url: "https://example.com", elicitation_id: "e")
end

Expected behavior

Form mode is refused when the client declares only URL mode. false counts as not declared. A declaration that is not an object raises the usual RuntimeError. A declaration naming neither mode, such as elicitation: {}, still implies form mode.

Logs

sent elicitation/create (form)
{}
TypeError: TrueClass does not have #dig method

Ruby 4.0.9.

Additional context

require_client_capability!(:elicitation, :form) does not apply the rule that elicitation: {} implies form mode, and tool-enabled sampling raises TypeError for sampling: true. Both are left for a separate change.

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

Activity

  1. added
    bug
    on Nov 30, 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