ruby-sdk/docs/_includes/head_custom.html
Koichi ITO 88831b46f6 Move the Documentation From README.md to the Documentation Site
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.
2026-08-21 13:24:04 +09:00

209 lines
6.1 KiB
HTML

<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<script>
(function() {
const storageKey = "mcp-ruby-sdk-docs-theme";
const validPreferences = ["system", "light", "dark"];
const preferenceLabels = {
system: "System",
light: "Light",
dark: "Dark"
};
const mediaQuery = window.matchMedia ?
window.matchMedia("(prefers-color-scheme: dark)") :
{ matches: false };
function isValidPreference(preference) {
return validPreferences.indexOf(preference) !== -1;
}
function getStoredPreference() {
try {
const preference = window.localStorage.getItem(storageKey);
return isValidPreference(preference) ? preference : "system";
} catch (error) {
return "system";
}
}
function savePreference(preference) {
try {
window.localStorage.setItem(storageKey, preference);
} catch (error) {
/* Ignore storage errors so private browsing modes still get theme switching. */
}
}
function resolvedTheme(preference) {
if (preference === "dark" || preference === "light") {
return preference;
}
return mediaQuery.matches ? "dark" : "light";
}
const colorSchemePattern = /just-the-docs-(default|light|dark)\.css(\?.*)?$/;
let pendingColorLink = null;
function findColorStylesheet() {
const links = document.querySelectorAll('link[rel="stylesheet"]');
for (let index = 0; index < links.length; index += 1) {
if (colorSchemePattern.test(links[index].getAttribute("href") || "")) {
return links[index];
}
}
return null;
}
function stylesheetTheme(link) {
const match = colorSchemePattern.exec(link.getAttribute("href") || "");
const scheme = match ? match[1] : "default";
return scheme === "default" ? "light" : scheme;
}
/*
* Swap the color stylesheet without going through jtd.setTheme, which
* rewrites the href of the render-blocking link and lets the page paint
* unstyled until the replacement CSS arrives. The site's color_scheme is
* the light variant, so the default stylesheet equals the light one
* and needs no swap at all;
* for dark, keep the old sheet applied until the new one has loaded.
*/
function setColorStylesheet(theme) {
const currentLink = findColorStylesheet();
if (!currentLink) {
return;
}
if (pendingColorLink) {
if (pendingColorLink.parentNode) {
pendingColorLink.parentNode.removeChild(pendingColorLink);
}
pendingColorLink = null;
}
if (stylesheetTheme(currentLink) === theme) {
return;
}
const newLink = document.createElement("link");
newLink.setAttribute("rel", "stylesheet");
newLink.setAttribute("blocking", "render");
newLink.setAttribute(
"href",
currentLink.getAttribute("href").replace(colorSchemePattern, "just-the-docs-" + theme + ".css")
);
newLink.addEventListener("load", function() {
if (pendingColorLink !== newLink) {
return;
}
pendingColorLink = null;
if (currentLink.parentNode) {
currentLink.parentNode.removeChild(currentLink);
}
});
newLink.addEventListener("error", function() {
if (pendingColorLink === newLink) {
pendingColorLink = null;
}
if (newLink.parentNode) {
newLink.parentNode.removeChild(newLink);
}
});
currentLink.parentNode.insertBefore(newLink, currentLink.nextSibling);
pendingColorLink = newLink;
}
function nextPreference(preference) {
const index = validPreferences.indexOf(preference);
if (index === -1 || index === validPreferences.length - 1) {
return validPreferences[0];
}
return validPreferences[index + 1];
}
function setThemeToggleLabel(preference) {
const buttons = document.querySelectorAll("[data-theme-toggle]");
const label = "Theme: " + preferenceLabels[preference];
for (let index = 0; index < buttons.length; index += 1) {
buttons[index].setAttribute("aria-label", label);
buttons[index].setAttribute("title", label);
}
}
function applyPreference(preference) {
const safePreference = isValidPreference(preference) ? preference : "system";
const theme = resolvedTheme(safePreference);
setColorStylesheet(theme);
document.documentElement.setAttribute("data-theme-preference", safePreference);
document.documentElement.setAttribute("data-theme", theme);
setThemeToggleLabel(safePreference);
}
window.mcpDocsTheme = {
apply: applyPreference,
getPreference: getStoredPreference,
save: function(preference) {
const safePreference = isValidPreference(preference) ? preference : "system";
savePreference(safePreference);
applyPreference(safePreference);
}
};
applyPreference(getStoredPreference());
function initThemeToggle() {
const buttons = document.querySelectorAll("[data-theme-toggle]");
if (buttons.length === 0) {
return;
}
setThemeToggleLabel(getStoredPreference());
for (let index = 0; index < buttons.length; index += 1) {
buttons[index].addEventListener("click", function() {
window.mcpDocsTheme.save(nextPreference(getStoredPreference()));
});
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initThemeToggle);
} else {
initThemeToggle();
}
function applySystemPreference() {
if (getStoredPreference() === "system") {
applyPreference("system");
}
}
if (mediaQuery.addEventListener) {
mediaQuery.addEventListener("change", applySystemPreference);
} else if (mediaQuery.addListener) {
mediaQuery.addListener(applySystemPreference);
}
})();
</script>
<script>
/*
* Open external links (GitHub, the MCP specification, rubydoc, and so on)
* in a new tab, keeping the docs page the reader came from. Line comments
* would swallow the script here: the theme compresses the HTML to one line.
*/
document.addEventListener("DOMContentLoaded", function () {
for (const anchor of document.querySelectorAll("a[href^='http']")) {
if (anchor.hostname !== window.location.hostname) {
anchor.target = "_blank";
anchor.rel = "noopener";
}
}
});
</script>