Skip to content

Commit cbf8723

Browse files
committed
Move the Documentation From README.md to the Documentation Site
Move the documentation that had grown to 3,000+ 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 20 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, and configuration), 8 client pages as the docs/_client/ collection (overview, transports, lifecycle, multi round-trip results, cancellation, ping, pagination, and authorization), and 3 advanced pages as the docs/_advanced/ collection (capability extensions, MCP Apps, and custom methods) - 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 /advanced/, 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, installation instructions, a stdio server and client quick start, a link-free feature overview in the Python SDK style, the conformance testing section, 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 examples 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 examples were corrected rather than copied, as noted above.
1 parent 5124cb4 commit cbf8723

49 files changed

Lines changed: 4157 additions & 3500 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 43 additions & 2996 deletions
Large diffs are not rendered by default.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
layout: default
3+
title: Capability Extensions
4+
nav_order: 1
5+
---
6+
7+
# Capability Extensions
8+
9+
Per SEP-2133, both clients and servers can declare protocol extensions under the `extensions` member of their capabilities.
10+
Keys are extension identifiers using the reverse-DNS prefix convention (e.g. `"io.modelcontextprotocol/tasks"`, `"com.example/feature"`);
11+
values are extension-defined configuration objects, with `{}` meaning "supported with no settings".
12+
13+
On the server, declare extensions through the `capabilities` keyword, either as a plain hash or via the `MCP::Server::Capabilities` builder:
14+
15+
```ruby
16+
capabilities = MCP::Server::Capabilities.new
17+
capabilities.support_tools
18+
capabilities.support_extensions("com.example/feature" => { enabled: true })
19+
20+
server = MCP::Server.new(name: "my_server", capabilities: capabilities)
21+
```
22+
23+
The declared extensions appear in the `initialize` result's `capabilities.extensions`. Extensions the client declared during `initialize` are
24+
readable via `server.client_capabilities[:extensions]` (or `session.client_capabilities[:extensions]` for per-session transports).
25+
26+
On the [modern lifecycle](/server/discovery/), the same declarations appear in the `server/discover` result,
27+
and the client's extensions ride each request's `_meta` envelope instead of an `initialize` handshake.
28+
Inside a handler, `server_context.client_capabilities[:extensions]` reads the current request's declarations
29+
with envelope-first resolution, on either lifecycle.
30+
31+
On the client, pass extensions through `connect`:
32+
33+
```ruby
34+
client.connect(capabilities: { extensions: { "com.example/feature" => {} } })
35+
```

docs/_advanced/custom-methods.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
layout: default
3+
title: Custom Methods
4+
nav_order: 3
5+
---
6+
7+
# Custom Methods
8+
9+
The server allows you to define custom JSON-RPC methods beyond the standard MCP protocol methods using the `define_custom_method` method:
10+
11+
```ruby
12+
server = MCP::Server.new(name: "my_server")
13+
14+
# Define a custom method that returns a result
15+
server.define_custom_method(method_name: "add") do |params|
16+
params[:a] + params[:b]
17+
end
18+
19+
# Define a custom notification method (returns nil)
20+
server.define_custom_method(method_name: "notify") do |params|
21+
# Process notification
22+
nil
23+
end
24+
```
25+
26+
**Key Features:**
27+
28+
- Accepts any method name as a string
29+
- Block receives the request parameters as a hash
30+
- Can handle both regular methods (with responses) and notifications
31+
- Prevents overriding existing MCP protocol methods
32+
- Supports instrumentation callbacks for monitoring
33+
- Blocks may opt in to a `server_context:` keyword like the built-in handlers
34+
(see [Cancellation](/server/cancellation/) for an example)
35+
36+
**Usage Example:**
37+
38+
The wire exchange for the custom `add` method defined above. The client sends:
39+
40+
```json
41+
{
42+
"jsonrpc": "2.0",
43+
"id": 1,
44+
"method": "add",
45+
"params": { "a": 5, "b": 3 }
46+
}
47+
```
48+
49+
The server responds:
50+
51+
```json
52+
{
53+
"jsonrpc": "2.0",
54+
"id": 1,
55+
"result": 8
56+
}
57+
```
58+
59+
**Error Handling:**
60+
61+
- Raises `MCP::Server::MethodAlreadyDefinedError` if trying to override an existing method
62+
- Supports the same exception reporting and instrumentation as standard methods

docs/_advanced/mcp-apps.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
layout: default
3+
title: MCP Apps
4+
nav_order: 2
5+
---
6+
7+
# MCP Apps
8+
9+
MCP Apps (SEP-1865) is a Final extension (negotiated via [Capability Extensions](/advanced/capability-extensions/)) that lets a server ship interactive
10+
HTML user interfaces which the host renders for tool results. On the server side the extension is a thin convention,
11+
and `MCP::Apps` provides the vocabulary and helpers:
12+
13+
```ruby
14+
capabilities = MCP::Server::Capabilities.new
15+
capabilities.support_tools
16+
capabilities.support_resources
17+
capabilities.support_extensions(MCP::Apps.capability) # { "io.modelcontextprotocol/ui" => { mimeTypes: [...] } }
18+
19+
server = MCP::Server.new(
20+
name: "weather_server",
21+
capabilities: capabilities,
22+
# UI templates are ordinary resources with a `ui://` URI and the `text/html;profile=mcp-app` MIME type.
23+
resources: [MCP::Apps.ui_resource(uri: "ui://weather-server/dashboard", name: "weather_dashboard")],
24+
)
25+
26+
server.resources_read_handler do |params|
27+
[{ uri: params[:uri], mimeType: MCP::Apps::RESOURCE_MIME_TYPE, text: "<html>...</html>" }]
28+
end
29+
30+
# Link the tool to its template via `_meta.ui.resourceUri` (pass `legacy: true` to also
31+
# emit the older flat `"ui/resourceUri"` alias for hosts that predate the Final spec).
32+
server.define_tool(
33+
name: "get_weather",
34+
meta: MCP::Apps.tool_meta(resource_uri: "ui://weather-server/dashboard"),
35+
) do |server_context:|
36+
# The extension is optional: always return a meaningful text result, and use
37+
# `MCP::Apps.client_supports?` when UI-capable clients should get richer structured content.
38+
MCP::Apps.client_supports?(server_context.client_capabilities) # => true when the host declared the extension
39+
MCP::Tool::Response.new([{ type: "text", text: "Sunny, 22 degrees Celsius" }])
40+
end
41+
```
42+
43+
`MCP::Apps.tool_meta` also accepts `visibility:` (an array of `"model"` / `"app"`) to restrict who sees the tool,
44+
and merges non-destructively into caller-supplied `meta:`.
45+
46+
Everything else the extension defines (the sandboxed iframe, the `ui/*` postMessage bridge, consent for UI-initiated actions)
47+
is the HOST's responsibility; a server only ever receives ordinary `resources/read` and `tools/call` requests.
48+
See the [MCP Apps specification](https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx).

0 commit comments

Comments
 (0)