ruby-sdk/lib/mcp/resource/embedded.rb
Koichi ITO 05c0119e53 Fix Resource::Embedded not setting @resource in initialize
The `initialize` method was missing the assignment of `@resource`,
causing the resource method to always return `nil` and `to_h` to return
an incorrect hash with an empty resource value.

Added comprehensive tests to verify the fix and prevent regression.
2026-01-26 11:37:33 +09:00

18 lines
359 B
Ruby

# frozen_string_literal: true
module MCP
class Resource
class Embedded
attr_reader :resource, :annotations
def initialize(resource:, annotations: nil)
@resource = resource
@annotations = annotations
end
def to_h
{ resource: resource.to_h, annotations: annotations }.compact
end
end
end
end