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.
This commit is contained in:
parent
d745ccdedc
commit
028c5f3291
1 changed files with 139 additions and 15 deletions
22
lib/mcp/icon.rb
Normal file
22
lib/mcp/icon.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# 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
|
||||
Loading…
Reference in a new issue