forked from modelcontextprotocol/ruby-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresource.rb
More file actions
32 lines (28 loc) · 758 Bytes
/
resource.rb
File metadata and controls
32 lines (28 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true
require_relative "resource/contents"
require_relative "resource/embedded"
module MCP
class Resource
attr_reader :uri, :name, :title, :description, :icons, :mime_type, :meta
def initialize(uri:, name:, title: nil, description: nil, icons: [], mime_type: nil, meta: nil)
@uri = uri
@name = name
@title = title
@description = description
@icons = icons
@mime_type = mime_type
@meta = meta
end
def to_h
{
uri: uri,
name: name,
title: title,
description: description,
icons: icons&.then { |icons| icons.empty? ? nil : icons.map(&:to_h) },
mimeType: mime_type,
_meta: meta,
}.compact
end
end
end