Merge pull request #403 from yuki3738/add_annotations_field_to_resource
Add `annotations` field to `MCP::Resource` and `MCP::ResourceTemplate` per MCP specification
This commit is contained in:
commit
3a163ad096
2 changed files with 40 additions and 4 deletions
|
|
@ -53,5 +53,23 @@ module MCP
|
|||
|
||||
assert_equal meta, resource_template.to_h[:_meta]
|
||||
end
|
||||
|
||||
test "#to_h omits annotations when nil" do
|
||||
resource_template = ResourceTemplate.new(uri_template: "file:///{path}", name: "template_without_annotations")
|
||||
|
||||
refute resource_template.to_h.key?(:annotations)
|
||||
end
|
||||
|
||||
test "#to_h includes annotations when present" do
|
||||
annotations = Annotations.new(audience: ["user"], priority: 0.8, last_modified: "2025-01-12T15:00:58Z")
|
||||
resource_template = ResourceTemplate.new(
|
||||
uri_template: "file:///{path}",
|
||||
name: "template_with_annotations",
|
||||
annotations: annotations,
|
||||
)
|
||||
|
||||
expected = { audience: ["user"], priority: 0.8, lastModified: "2025-01-12T15:00:58Z" }
|
||||
assert_equal expected, resource_template.to_h[:annotations]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -67,5 +67,19 @@ module MCP
|
|||
|
||||
assert_equal 0, resource.to_h[:size]
|
||||
end
|
||||
|
||||
test "#to_h omits annotations when nil" do
|
||||
resource = Resource.new(uri: "file:///test.txt", name: "resource_without_annotations")
|
||||
|
||||
refute resource.to_h.key?(:annotations)
|
||||
end
|
||||
|
||||
test "#to_h includes annotations when present" do
|
||||
annotations = Annotations.new(audience: ["user"], priority: 0.8, last_modified: "2025-01-12T15:00:58Z")
|
||||
resource = Resource.new(uri: "file:///test.txt", name: "resource_with_annotations", annotations: annotations)
|
||||
|
||||
expected = { audience: ["user"], priority: 0.8, lastModified: "2025-01-12T15:00:58Z" }
|
||||
assert_equal expected, resource.to_h[:annotations]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue