According to the specification, the following attributes are optional, so using `compact` ensures consistency. - `description`: Optional description - `mimeType`: Optional MIME type - `size`: Optional size in bytes https://modelcontextprotocol.io/specification/2025-03-26/server/resources#resource
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:, mime_type:)
|
|
@uri = uri
|
|
@name = name
|
|
@description = description
|
|
@mime_type = mime_type
|
|
end
|
|
|
|
def to_h
|
|
{
|
|
uri: @uri,
|
|
name: @name,
|
|
description: @description,
|
|
mimeType: @mime_type,
|
|
}.compact
|
|
end
|
|
end
|
|
end
|