add _meta field to Prompt
> See [General fields: `_meta`](/specification/2025-06-18/basic/index#meta) for notes on `_meta` usage.
51e093b8eb/schema/2025-06-18/schema.ts (L680-L683)
This commit is contained in:
parent
701f6faab6
commit
a1dd3dd005
1 changed files with 67 additions and 4 deletions
|
|
@ -8,13 +8,20 @@ module MCP
|
|||
attr_reader :title_value
|
||||
attr_reader :description_value
|
||||
attr_reader :arguments_value
|
||||
attr_reader :meta_value
|
||||
|
||||
def template(args, server_context: nil)
|
||||
raise NotImplementedError, "Subclasses must implement template"
|
||||
end
|
||||
|
||||
def to_h
|
||||
{ name: name_value, title: title_value, description: description_value, arguments: arguments_value.map(&:to_h) }.compact
|
||||
{
|
||||
name: name_value,
|
||||
title: title_value,
|
||||
description: description_value,
|
||||
arguments: arguments_value&.map(&:to_h),
|
||||
_meta: meta_value,
|
||||
}.compact
|
||||
end
|
||||
|
||||
def inherited(subclass)
|
||||
|
|
@ -23,6 +30,7 @@ module MCP
|
|||
subclass.instance_variable_set(:@title_value, nil)
|
||||
subclass.instance_variable_set(:@description_value, nil)
|
||||
subclass.instance_variable_set(:@arguments_value, nil)
|
||||
subclass.instance_variable_set(:@meta_value, nil)
|
||||
end
|
||||
|
||||
def prompt_name(value = NOT_SET)
|
||||
|
|
@ -61,7 +69,15 @@ module MCP
|
|||
end
|
||||
end
|
||||
|
||||
def define(name: nil, title: nil, description: nil, arguments: [], &block)
|
||||
def meta(value = NOT_SET)
|
||||
if value == NOT_SET
|
||||
@meta_value
|
||||
else
|
||||
@meta_value = value
|
||||
end
|
||||
end
|
||||
|
||||
def define(name: nil, title: nil, description: nil, arguments: [], meta: nil, &block)
|
||||
Class.new(self) do
|
||||
prompt_name name
|
||||
title title
|
||||
|
|
@ -70,6 +86,7 @@ module MCP
|
|||
define_singleton_method(:template) do |args, server_context: nil|
|
||||
instance_exec(args, server_context:, &block)
|
||||
end
|
||||
meta meta
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue