Skip to content

Commit 541bbe0

Browse files
authored
Merge pull request #113 from koic/document_title_as_draft_and_restore_annotations_title
Document `title` as Draft and restore `annotations.title`
2 parents 06bf90d + b4da129 commit 541bbe0

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ This gem provides a `MCP::Tool` class that can be used to create tools in two wa
373373

374374
```ruby
375375
class MyTool < MCP::Tool
376-
title "My Tool"
376+
title "My Tool" # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
377377
description "This tool performs specific functionality..."
378378
input_schema(
379379
properties: {
@@ -385,7 +385,8 @@ class MyTool < MCP::Tool
385385
read_only_hint: true,
386386
destructive_hint: false,
387387
idempotent_hint: true,
388-
open_world_hint: false
388+
open_world_hint: false,
389+
title: "My Tool"
389390
)
390391

391392
def self.call(message:, server_context:)
@@ -401,10 +402,11 @@ tool = MyTool
401402
```ruby
402403
tool = MCP::Tool.define(
403404
name: "my_tool",
404-
title: "My Tool",
405+
title: "My Tool", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
405406
description: "This tool performs specific functionality...",
406407
annotations: {
407-
read_only_hint: true
408+
read_only_hint: true,
409+
title: "My Tool"
408410
}
409411
) do |args, server_context|
410412
MCP::Tool::Response.new([{ type: "text", text: "OK" }])
@@ -418,11 +420,11 @@ e.g. around authentication state.
418420

419421
Tools can include annotations that provide additional metadata about their behavior. The following annotations are supported:
420422

421-
- `title`: A human-readable title for the tool
422-
- `read_only_hint`: Indicates if the tool only reads data (doesn't modify state)
423423
- `destructive_hint`: Indicates if the tool performs destructive operations
424424
- `idempotent_hint`: Indicates if the tool's operations are idempotent
425425
- `open_world_hint`: Indicates if the tool operates in an open world context
426+
- `read_only_hint`: Indicates if the tool only reads data (doesn't modify state)
427+
- `title`: A human-readable title for the tool
426428

427429
Annotations can be set either through the class definition using the `annotations` class method or when defining a tool using the `define` method.
428430

@@ -437,7 +439,7 @@ The `MCP::Prompt` class provides two ways to create prompts:
437439
```ruby
438440
class MyPrompt < MCP::Prompt
439441
prompt_name "my_prompt" # Optional - defaults to underscored class name
440-
title "My Prompt"
442+
title "My Prompt" # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
441443
description "This prompt performs specific functionality..."
442444
arguments [
443445
MCP::Prompt::Argument.new(
@@ -474,7 +476,7 @@ prompt = MyPrompt
474476
```ruby
475477
prompt = MCP::Prompt.define(
476478
name: "my_prompt",
477-
title: "My Prompt",
479+
title: "My Prompt", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
478480
description: "This prompt performs specific functionality...",
479481
arguments: [
480482
MCP::Prompt::Argument.new(
@@ -561,7 +563,7 @@ The `MCP::Resource` class provides a way to register resources with the server.
561563
resource = MCP::Resource.new(
562564
uri: "https://example.com/my_resource",
563565
name: "my-resource",
564-
title: "My Resource",
566+
title: "My Resource", # WARNING: This is a `Draft` and is not supported in the `Version 2025-06-18 (latest)` specification.
565567
description: "Lorem ipsum dolor sit amet",
566568
mime_type: "text/html",
567569
)

test/mcp/tool_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class InputSchemaTool < Tool
133133
description: "a mock tool for testing",
134134
annotations: {
135135
read_only_hint: true,
136+
title: "Mock Tool",
136137
},
137138
) do |_|
138139
Tool::Response.new([{ type: "text", content: "OK" }])
@@ -142,7 +143,7 @@ class InputSchemaTool < Tool
142143
assert_equal tool.title, "Mock Tool"
143144
assert_equal tool.description, "a mock tool for testing"
144145
assert_equal tool.input_schema, Tool::InputSchema.new
145-
assert_equal tool.annotations_value.to_h, { readOnlyHint: true }
146+
assert_equal tool.annotations_value.to_h, { readOnlyHint: true, title: "Mock Tool" }
146147
end
147148

148149
# Tests for Tool::Annotations class

0 commit comments

Comments
 (0)