Move the documentation that had grown to 3000+ lines in README.md onto https://ruby.sdk.modelcontextprotocol.io and slim the README down to a quick start and feature overview, following the Python SDK layout: - Add 21 server pages as the docs/_server/ collection (overview plus transports, discovery, tools, prompts, resources, roots, sampling, elicitation, multi round-trip results, notifications, notification subscriptions, cancellation, progress, ping, completions, logging, pagination, server context, configuration, and custom methods), 8 client pages as the docs/_client/ collection (overview, transports, lifecycle, multi round-trip results, cancellation, ping, pagination, and authorization), and 3 extension pages as the docs/_extensions/ collection (overview, capability extensions, and MCP Apps, following the Extensions Overview recommendation that SDK documentation list the supported extensions) - one page per topic, ordered to match the sidebar of the 2026-07-28 specification, with the client-side APIs (pinging, cancelling, and paginating from MCP::Client) documented under Building Clients - Add top-level Examples and Protocol Versions pages after Installation, linking the runnable examples in examples/ and summarizing the supported protocol versions, the era model, and client negotiation - Render the three sections as just-the-docs collections, which list every page beneath a plain category heading in the sidebar with no folding, and serve every page at an extensionless URL under /server/, /client/, and /extensions/, matching the sibling SDK documentation sites - Replace docs/building-servers.md and docs/building-clients.md with redirects to the new section overview pages via jekyll-redirect-from, redirect the previously published /installation.html to its extensionless URL, fold their content that was missing from README.md into the new pages, and update the Tool argument keys reference comment in lib/mcp/server.rb to the relocated Tools page - Reduce README.md to the badges, a compact feature overview in the Python SDK style, installation instructions, a stdio server and client quick start, and a License section, using absolute URLs for the remaining repository links so they resolve on rubygems.org - Adapt formatting where GitHub rendering habits break on the site: convert the numbered "three ways to define" lists into headings, since kramdown restarts numbering at 1 when code blocks split list items, convert GitHub-style alerts into just-the-docs callouts with the SEP-2260 server-to-client association note raised to a red warning, merge the duplicated Exception Reporting and Configuration Block Data sections into the Configuration page, and relocate the Streamable HTTP settings that were nested under the Logging section into the Transports page - Refresh the migrated content against the current implementation: correct stale claims and broken samples the README carried, note on each session-era feature how it relates to the modern lifecycle of MCP 2026-07-28, and point spec links at the latest revision, keeping deliberate 2025-11-25 pins for pages the modern revision removed - Style the site after the Rails API documentation palette (red links and accents on neutral surfaces) with matching light and dark color schemes, center the sidebar and content as one block, add a Previous/Next footer pager following the sidebar order, open external links in a new tab, and serve the MCP logo as the favicon Every code block and heading from the previous README was verified to have a home in the new docs pages or the slimmed README before the reduction; a few samples were corrected rather than copied, as noted above.
4 KiB
| layout | title | nav_order |
|---|---|---|
| default | Multi-Round-Trip Results | 10 |
Multi-Round-Trip Results
The modern lifecycle (MCP 2026-07-28) forbids server-initiated requests. Instead, per SEP-2322, a tools/call, prompts/get, or resources/read handler that
opts in to server_context: may return MCP::Server::InputRequiredResult.new(input_requests:, request_state:) to ask the client for
additional input (elicitation/create, sampling/createMessage, or roots/list shapes):
class GreetingTool < MCP::Tool
description "Greets the user by name"
def self.call(server_context:, **_args)
response = server_context.input_response("user_name")
unless response
return MCP::Server::InputRequiredResult.new(
input_requests: {
user_name: {
method: "elicitation/create",
params: {
message: "What is your name?",
requestedSchema: {
type: "object",
properties: { name: { type: "string" } },
required: ["name"],
},
},
},
},
)
end
MCP::Tool::Response.new([{ type: "text", text: "Hello, #{response.dig(:content, :name)}!" }])
end
end
Deterministic Replay
On the retried request the handler re-runs from the start and reads the answers via
server_context.input_responses / server_context.input_response(key) and the echoed opaque server_context.request_state
(deterministic replay; the server holds no memory between rounds). The server returns -32021
when an embedded request needs a client capability the request did not declare.
Securing requestState
The echoed requestState arrives as client-controlled input: pass MCP::Server::RequestStateSecurity.new(key:) (a 32-byte key) via
Server.new(request_state_security:) to have it sealed with AES-256-GCM and bound to a TTL plus the originating method, target, and arguments,
all transparently to handlers. Multi-process deployments must share the key across workers; without request_state_security: the state crosses
the wire exactly as the handler wrote it and protecting it is the handler author's responsibility.
server = MCP::Server.new(
name: "my_server",
tools: [GreetingTool],
request_state_security: MCP::Server::RequestStateSecurity.new(key: ENV.fetch("MCP_REQUEST_STATE_KEY")),
)
resultType Stamping
SEP-2322 also makes resultType a required member of every result a 2026-07-28 server returns. The server stamps resultType: "complete"
on all results of requests carrying the modern _meta envelope (and on server/discover results), while results that already carry
a discriminator ("input_required", the tasks extension's "task") keep it. Legacy results stay unstamped, and clients treat an absent
resultType as "complete" per the spec.
Legacy Clients
Handlers written in the 2026 style serve pre-2026 clients too: when a tools/call, prompts/get, or resources/read handler returns
an InputRequiredResult on the legacy wire, the server fulfills it in place of the client's driver. Each inputRequests entry is sent
as the equivalent real server-to-client request (elicitation/create, sampling/createMessage, roots/list), associated with
the originating request per SEP-2260; the answers are collected under the same keys, and the handler re-runs with
server_context.input_responses populated and the raw requestState echoed, the same deterministic replay contract
the modern client driver follows. The shim is on by default (matching the TypeScript SDK) and capped at 8 rounds;
MCP::Server.new(input_required_legacy_shim: false) restores the strict rejection of input_required results on legacy requests.
Client Side
call_tool, get_prompt, and read_resource drive input_required results automatically once the matching handlers are registered;
see the client Multi-Round-Trip Results page.