add titles to tools, prompts and resources
This commit is contained in:
parent
d1c6a46e1a
commit
8b4085468e
1 changed files with 94 additions and 40 deletions
|
|
@ -5,6 +5,7 @@ module MCP
|
|||
class << self
|
||||
NOT_SET = Object.new
|
||||
|
||||
attr_reader :title_value
|
||||
attr_reader :description_value
|
||||
attr_reader :annotations_value
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ module MCP
|
|||
def to_h
|
||||
result = {
|
||||
name: name_value,
|
||||
title: title_value,
|
||||
description: description_value,
|
||||
inputSchema: input_schema_value.to_h,
|
||||
}
|
||||
|
|
@ -25,6 +27,7 @@ module MCP
|
|||
def inherited(subclass)
|
||||
super
|
||||
subclass.instance_variable_set(:@name_value, nil)
|
||||
subclass.instance_variable_set(:@title_value, nil)
|
||||
subclass.instance_variable_set(:@description_value, nil)
|
||||
subclass.instance_variable_set(:@input_schema_value, nil)
|
||||
subclass.instance_variable_set(:@annotations_value, nil)
|
||||
|
|
@ -46,6 +49,14 @@ module MCP
|
|||
@input_schema_value || InputSchema.new
|
||||
end
|
||||
|
||||
def title(value = NOT_SET)
|
||||
if value == NOT_SET
|
||||
@title_value
|
||||
else
|
||||
@title_value = value
|
||||
end
|
||||
end
|
||||
|
||||
def description(value = NOT_SET)
|
||||
if value == NOT_SET
|
||||
@description_value
|
||||
|
|
@ -74,9 +85,10 @@ module MCP
|
|||
end
|
||||
end
|
||||
|
||||
def define(name: nil, description: nil, input_schema: nil, annotations: nil, &block)
|
||||
def define(name: nil, title: nil, description: nil, input_schema: nil, annotations: nil, &block)
|
||||
Class.new(self) do
|
||||
tool_name name
|
||||
title title
|
||||
description description
|
||||
input_schema input_schema
|
||||
self.annotations(annotations) if annotations
|
||||
|
|
|
|||
Loading…
Reference in a new issue