ruby-sdk/lib/mcp/icon.rb
Koichi ITO 028c5f3291 Support icons parameter
This PR adds support for the optional `icons` parameter in prompt, resource,
resource template, and server info.

The specifications for `icons` are as follows.
https://modelcontextprotocol.io/specification/2025-11-25/schema#icon

Resolves https://github.com/modelcontextprotocol/ruby-sdk/issues/127.
2025-12-30 05:35:22 +09:00

22 lines
547 B
Ruby

# frozen_string_literal: true
module MCP
class Icon
SUPPORTED_THEMES = ["light", "dark"]
attr_reader :mime_type, :sizes, :src, :theme
def initialize(mime_type: nil, sizes: nil, src: nil, theme: nil)
raise ArgumentError, 'The value of theme must specify "light" or "dark".' if theme && !SUPPORTED_THEMES.include?(theme)
@mime_type = mime_type
@sizes = sizes
@src = src
@theme = theme
end
def to_h
{ mimeType: mime_type, sizes: sizes, src: src, theme: theme }.compact
end
end
end