Merge pull request #113 from koic/document_title_as_draft_and_restore_annotations_title

Document `title` as Draft and restore `annotations.title`
This commit is contained in:
Koichi ITO 2025-08-24 01:23:19 +09:00 • committed by GitHub
commit 541bbe0859
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 10 deletions

View file

@ -373,7 +373,7 @@ This gem provides a `MCP::Tool` class that can be used to create tools in two wa
```ruby
class MyTool < MCP::Tool
title "My Tool"
title "My Tool" # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
description "This tool performs specific functionality..."
input_schema(
properties: {
@ -385,7 +385,8 @@ class MyTool < MCP::Tool
read_only_hint: true,
destructive_hint: false,
idempotent_hint: true,
open_world_hint: false
open_world_hint: false,
title: "My Tool"
)
def self.call(message:, server_context:)
@ -401,10 +402,11 @@ tool = MyTool
```ruby
tool = MCP::Tool.define(
name: "my_tool",
title: "My Tool",
title: "My Tool", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
description: "This tool performs specific functionality...",
annotations: {
read_only_hint: true
read_only_hint: true,
title: "My Tool"
}
) do |args, server_context|
MCP::Tool::Response.new([{ type: "text", text: "OK" }])
@ -418,11 +420,11 @@ e.g. around authentication state.
Tools can include annotations that provide additional metadata about their behavior. The following annotations are supported:
- `title`: A human-readable title for the tool
- `read_only_hint`: Indicates if the tool only reads data (doesn't modify state)
- `destructive_hint`: Indicates if the tool performs destructive operations
- `idempotent_hint`: Indicates if the tool's operations are idempotent
- `open_world_hint`: Indicates if the tool operates in an open world context
- `read_only_hint`: Indicates if the tool only reads data (doesn't modify state)
- `title`: A human-readable title for the tool
Annotations can be set either through the class definition using the `annotations` class method or when defining a tool using the `define` method.
@ -437,7 +439,7 @@ The `MCP::Prompt` class provides two ways to create prompts:
```ruby
class MyPrompt < MCP::Prompt
prompt_name "my_prompt" # Optional - defaults to underscored class name
title "My Prompt"
title "My Prompt" # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
description "This prompt performs specific functionality..."
arguments [
MCP::Prompt::Argument.new(
@ -474,7 +476,7 @@ prompt = MyPrompt
```ruby
prompt = MCP::Prompt.define(
name: "my_prompt",
title: "My Prompt",
title: "My Prompt", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
description: "This prompt performs specific functionality...",
arguments: [
MCP::Prompt::Argument.new(
@ -561,7 +563,7 @@ The `MCP::Resource` class provides a way to register resources with the server.
resource = MCP::Resource.new(
uri: "https://example.com/my_resource",
name: "my-resource",
title: "My Resource",
title: "My Resource", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
description: "Lorem ipsum dolor sit amet",
mime_type: "text/html",
)

View file

@ -133,6 +133,7 @@ module MCP
description: "a mock tool for testing",
annotations: {
read_only_hint: true,
title: "Mock Tool",
},
) do |_|
Tool::Response.new([{ type: "text", content: "OK" }])
@ -142,7 +143,7 @@ module MCP
assert_equal tool.title, "Mock Tool"
assert_equal tool.description, "a mock tool for testing"
assert_equal tool.input_schema, Tool::InputSchema.new
assert_equal tool.annotations_value.to_h, { readOnlyHint: true }
assert_equal tool.annotations_value.to_h, { readOnlyHint: true, title: "Mock Tool" }
end
# Tests for Tool::Annotations class