Skip to content

Commit e9403c5

Browse files
committed
[Doc] Tweak an example for MCP::Resource in the README
`MCP::Resource` doesn't have `text` attribute: https://github.com/modelcontextprotocol/ruby-sdk/blob/v0.1.0/lib/mcp/resource.rb#L8-L13 I've replaced it with attributes that it actually supports. Also, the use of `text: "Hello, world!"` in the example of `server.resources_read_handler` implementation resulted in an unexpected response the first time I worked with `Resource`. While it may not be the best (but better), in my experience using Resources with Cline, `text: params[:uri]` served as a clearer response when interacting with an LLM, making it easier to understand.
1 parent fda5640 commit e9403c5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,10 @@ The `MCP::Resource` class provides a way to register resources with the server.
460460

461461
```ruby
462462
resource = MCP::Resource.new(
463-
uri: "example.com/my_resource",
464-
mime_type: "text/plain",
465-
text: "Lorem ipsum dolor sit amet"
463+
uri: "https://example.com/my_resource",
464+
name: "My Resource",
465+
description: "Lorem ipsum dolor sit amet",
466+
mime_type: "text/html",
466467
)
467468

468469
server = MCP::Server.new(
@@ -478,13 +479,13 @@ server.resources_read_handler do |params|
478479
[{
479480
uri: params[:uri],
480481
mimeType: "text/plain",
481-
text: "Hello, world!",
482+
text: params[:uri],
482483
}]
483484
end
484485

485486
```
486487

487-
otherwise 'resources/read' requests will be a no-op.
488+
otherwise `resources/read` requests will be a no-op.
488489

489490
## Releases
490491

0 commit comments

Comments
 (0)