This change is related to #29. According to the specification, both `description` and `mimeType` of Resource are optional: https://modelcontextprotocol.io/specification/2025-03-26/server/resources#resource Therefore, it makes sense to treat them as optional keyword arguments, similar to how this is done in `ResourceTemplate`: https://github.com/modelcontextprotocol/ruby-sdk/blob/0b49c3/lib/mcp/resource_template.rb#L8 As additional context, the TypeScript SDK also treats them as optional. https://github.com/modelcontextprotocol/typescript-sdk/blob/1.12.1/src/types.ts#L438-L466
24 lines
455 B
Ruby
24 lines
455 B
Ruby
# typed: strict
|
|
# frozen_string_literal: true
|
|
|
|
module MCP
|
|
class Resource
|
|
attr_reader :uri, :name, :description, :mime_type
|
|
|
|
def initialize(uri:, name:, description: nil, mime_type: nil)
|
|
@uri = uri
|
|
@name = name
|
|
@description = description
|
|
@mime_type = mime_type
|
|
end
|
|
|
|
def to_h
|
|
{
|
|
uri: @uri,
|
|
name: @name,
|
|
description: @description,
|
|
mimeType: @mime_type,
|
|
}
|
|
end
|
|
end
|
|
end
|