Internal Release 0.2.0
- fix `lib/mcp-ruby` auto-import path - implement server resources - add basic listing of resources to Server - allow setting handlers on Server - wrap handler method results - make tool definition more declarative - make prompt definition more declarative - bump dependency versions
This commit is contained in:
parent
a4df3b8688
commit
6004f42573
1 changed files with 708 additions and 164 deletions
|
|
@ -2,57 +2,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ModelContextProtocol
|
||||
module Resource
|
||||
class Embedded
|
||||
attr_reader :resource, :annotations
|
||||
class Resource
|
||||
attr_reader :uri, :name, :description, :mime_type, :contents
|
||||
|
||||
def initialize(resource:, annotations: nil)
|
||||
@resource = resource
|
||||
@annotations = annotations
|
||||
end
|
||||
|
||||
def to_h
|
||||
{ resource: resource.to_h, annotations: }.compact
|
||||
end
|
||||
def initialize(uri:, name:, description:, mime_type:, contents:)
|
||||
@uri = uri
|
||||
@name = name
|
||||
@description = description
|
||||
@mime_type = mime_type
|
||||
@contents = contents
|
||||
end
|
||||
|
||||
class Contents
|
||||
attr_reader :uri, :mime_type
|
||||
|
||||
def initialize(uri:, mime_type: nil)
|
||||
@uri = uri
|
||||
@mime_type = mime_type
|
||||
end
|
||||
|
||||
def to_h
|
||||
{ uri:, mime_type: }.compact
|
||||
end
|
||||
end
|
||||
|
||||
class TextContents < Contents
|
||||
attr_reader :text
|
||||
|
||||
def initialize(text:, uri:, mime_type:)
|
||||
super(uri: uri, mime_type: mime_type)
|
||||
@text = text
|
||||
end
|
||||
|
||||
def to_h
|
||||
super.merge(text: text)
|
||||
end
|
||||
end
|
||||
|
||||
class BlobContents < Contents
|
||||
attr_reader :data
|
||||
|
||||
def initialize(data:, uri:, mime_type:)
|
||||
super(uri: uri, mime_type: mime_type)
|
||||
@data = data
|
||||
end
|
||||
|
||||
def to_h
|
||||
super.merge(data: data)
|
||||
end
|
||||
def to_h
|
||||
{
|
||||
uri: @uri,
|
||||
name: @name,
|
||||
description: @description,
|
||||
mimeType: @mime_type,
|
||||
contents: @contents.map(&:to_h),
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue