Merge pull request #47 from koic/tweak_an_example_for_mcp_resource_in_readme
[Doc] Tweak an example for `MCP::Resource` in the README
This commit is contained in:
commit
04710ac472
1 changed files with 6 additions and 5 deletions
11
README.md
11
README.md
|
|
@ -460,9 +460,10 @@ The `MCP::Resource` class provides a way to register resources with the server.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
resource = MCP::Resource.new(
|
resource = MCP::Resource.new(
|
||||||
uri: "example.com/my_resource",
|
uri: "https://example.com/my_resource",
|
||||||
mime_type: "text/plain",
|
name: "My Resource",
|
||||||
text: "Lorem ipsum dolor sit amet"
|
description: "Lorem ipsum dolor sit amet",
|
||||||
|
mime_type: "text/html",
|
||||||
)
|
)
|
||||||
|
|
||||||
server = MCP::Server.new(
|
server = MCP::Server.new(
|
||||||
|
|
@ -478,13 +479,13 @@ server.resources_read_handler do |params|
|
||||||
[{
|
[{
|
||||||
uri: params[:uri],
|
uri: params[:uri],
|
||||||
mimeType: "text/plain",
|
mimeType: "text/plain",
|
||||||
text: "Hello, world!",
|
text: params[:uri],
|
||||||
}]
|
}]
|
||||||
end
|
end
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
otherwise 'resources/read' requests will be a no-op.
|
otherwise `resources/read` requests will be a no-op.
|
||||||
|
|
||||||
## Releases
|
## Releases
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue