ruby-sdk/docs
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Koichi ITO b6df40b134 Support class-based Resource and ResourceTemplate definitions
## Motivation and Context

Resolve the design difference raised in issue #98: Tools and Prompts support class-based definitions
while Resources and Resource Templates were plain data objects requiring a `resources_read_handler` block
with manual URI routing.

`MCP::Resource` and `MCP::ResourceTemplate` now support the same class-level DSL as `MCP::Tool`
and `MCP::Prompt` (`uri`, `resource_name`, `title`, `description`, `icons`, `mime_type`, `annotations`,
`size`, `meta`, and `uri_template` / `resource_template_name` for templates), plus `define` factory methods
and `MCP::Server#define_resource` / `#define_resource_template`.

The default `resources/read` handler now routes requests automatically: an exact URI match calls
the class-based resource's `contents` method, and class-based resource templates match
simple RFC 6570 level 1 `{var}` expressions, passing extracted variables as keyword arguments.
`contents` can opt in to a `server_context:` keyword argument. When class-based entries are registered
and no match is found, the server responds with -32602 carrying the URI in error data per SEP-2164.

## How Has This Been Tested?

- Added regression tests covering the class-level DSL, URI template matching, auto-routing,
  `server_context:` opt-in, error responses, and backward compatibility of the no-op default.
- Verified end-to-end with a smoke script exercising exact-match reads, template-match reads,
  unknown URIs, and legacy instance-only setups.

## Breaking Changes

No. Instance-based registration, `resources_read_handler` precedence, and the no-op `[]` response for
setups without class-based entries are unchanged. Reassigning `Server#resources` now rebuilds
the internal URI index.

Closes #98
2026-07-10 22:39:42 +09:00
..
_includes docs: add dark mode support 2026-05-11 08:46:40 -04:00
_sass/custom docs: add dark mode support 2026-05-11 08:46:40 -04:00
assets docs: add dark mode support 2026-05-11 08:46:40 -04:00
latest Add API documentation with GitHub Pages deployment 2025-11-21 12:21:38 -06:00
_config.yml docs: add dark mode support 2026-05-11 08:46:40 -04:00
building-clients.md Bound stdio frame reads with max_line_bytes 2026-07-05 21:30:28 +09:00
building-servers.md Support class-based Resource and ResourceTemplate definitions 2026-07-10 22:39:42 +09:00
CNAME [Doc] Add CNAME file to preserve custom domain across deployments 2026-03-30 13:27:58 +09:00
index.md [Doc] Update homepage with just-the-docs theme 2026-04-15 22:48:15 +09:00
installation.md [Doc] Update homepage with just-the-docs theme 2026-04-15 22:48:15 +09:00