Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/mcp/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(data, mime_type, annotations: nil)
end

def to_h
{ data: data, mime_type: mime_type, annotations: annotations, type: "image" }.compact
{ data: data, mimeType: mime_type, annotations: annotations, type: "image" }.compact
end
end
end
Expand Down
33 changes: 33 additions & 0 deletions test/mcp/content_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require "test_helper"

module MCP
module Content
class ImageTest < ActiveSupport::TestCase
test "#to_h returns mimeType (camelCase) per MCP spec" do
image = Image.new("base64data", "image/png")
result = image.to_h

assert_equal "image/png", result[:mimeType]
refute result.key?(:mime_type), "Expected camelCase mimeType, got snake_case mime_type"
assert_equal "image", result[:type]
assert_equal "base64data", result[:data]
end

test "#to_h with annotations" do
image = Image.new("base64data", "image/png", annotations: { role: "thumbnail" })
result = image.to_h

assert_equal({ role: "thumbnail" }, result[:annotations])
end

test "#to_h without annotations omits the key" do
image = Image.new("base64data", "image/png")
result = image.to_h

refute result.key?(:annotations)
end
end
end
end