Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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:)
Expand All @@ -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" }])
Expand All @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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

Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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",
)
Expand Down
3 changes: 2 additions & 1 deletion test/mcp/tool_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class InputSchemaTool < Tool
description: "a mock tool for testing",
annotations: {
read_only_hint: true,
title: "Mock Tool",
},
) do |_|
Tool::Response.new([{ type: "text", content: "OK" }])
Expand All @@ -142,7 +143,7 @@ class InputSchemaTool < Tool
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
Expand Down