Internal Release 0.6.0
Rename Context Arg
This commit is contained in:
parent
6da8bfab1a
commit
62184957e0
5 changed files with 52 additions and 52 deletions
|
|
@ -65,7 +65,7 @@ module ModelContextProtocol
|
|||
private
|
||||
|
||||
def default_exception_reporter
|
||||
@default_exception_reporter ||= ->(exception, context) {}
|
||||
@default_exception_reporter ||= ->(exception, server_context) {}
|
||||
end
|
||||
|
||||
def default_instrumentation_callback
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ module ModelContextProtocol
|
|||
attr_reader :description_value
|
||||
attr_reader :arguments_value
|
||||
|
||||
def template(args, context:)
|
||||
def template(args, server_context:)
|
||||
raise NotImplementedError, "Subclasses must implement template"
|
||||
end
|
||||
|
||||
|
|
@ -98,8 +98,8 @@ module ModelContextProtocol
|
|||
prompt_name name
|
||||
description description
|
||||
arguments arguments
|
||||
define_singleton_method(:template) do |args, context:|
|
||||
instance_exec(args, context:, &block)
|
||||
define_singleton_method(:template) do |args, server_context:|
|
||||
instance_exec(args, server_context:, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,16 +20,16 @@ module ModelContextProtocol
|
|||
|
||||
include Instrumentation
|
||||
|
||||
attr_accessor :name, :tools, :prompts, :resources, :context, :configuration
|
||||
attr_accessor :name, :tools, :prompts, :resources, :server_context, :configuration
|
||||
|
||||
def initialize(name: "model_context_protocol", tools: [], prompts: [], resources: [], context: nil,
|
||||
def initialize(name: "model_context_protocol", tools: [], prompts: [], resources: [], server_context: nil,
|
||||
configuration: nil)
|
||||
@name = name
|
||||
@tools = tools.to_h { |t| [t.name_value, t] }
|
||||
@prompts = prompts.to_h { |p| [p.name_value, p] }
|
||||
@resources = resources
|
||||
@resource_index = index_resources_by_uri(resources)
|
||||
@context = context
|
||||
@server_context = server_context
|
||||
@configuration = ModelContextProtocol.configuration.merge(configuration)
|
||||
@handlers = {
|
||||
Methods::RESOURCES_LIST => method(:list_resources),
|
||||
|
|
@ -154,7 +154,7 @@ module ModelContextProtocol
|
|||
add_instrumentation_data(tool_name:)
|
||||
|
||||
begin
|
||||
tool.call(**request[:arguments], context:).to_h
|
||||
tool.call(**request[:arguments], server_context:).to_h
|
||||
rescue => e
|
||||
raise RequestHandlerError.new("Internal error calling tool #{tool_name}", request, original_error: e)
|
||||
end
|
||||
|
|
@ -179,7 +179,7 @@ module ModelContextProtocol
|
|||
prompt_args = request[:arguments]
|
||||
prompt.validate_arguments!(prompt_args)
|
||||
|
||||
prompt.template(prompt_args, context:).to_h
|
||||
prompt.template(prompt_args, server_context:).to_h
|
||||
end
|
||||
|
||||
def list_resources(request)
|
||||
|
|
@ -202,8 +202,8 @@ module ModelContextProtocol
|
|||
resource.to_h
|
||||
end
|
||||
|
||||
def report_exception(exception, context = {})
|
||||
configuration.exception_reporter.call(exception, context)
|
||||
def report_exception(exception, server_context = {})
|
||||
configuration.exception_reporter.call(exception, server_context)
|
||||
end
|
||||
|
||||
def index_resources_by_uri(resources)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ module ModelContextProtocol
|
|||
attr_reader :input_schema_value
|
||||
attr_reader :annotations_value
|
||||
|
||||
def call(*args, context:)
|
||||
def call(*args, server_context:)
|
||||
raise NotImplementedError, "Subclasses must implement call"
|
||||
end
|
||||
|
||||
|
|
@ -108,8 +108,8 @@ module ModelContextProtocol
|
|||
description description
|
||||
input_schema input_schema
|
||||
self.annotations(annotations) if annotations
|
||||
define_singleton_method(:call) do |*args, context:|
|
||||
instance_exec(*args, context:, &block)
|
||||
define_singleton_method(:call) do |*args, server_context:|
|
||||
instance_exec(*args, server_context:, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ModelContextProtocol
|
||||
VERSION = "0.5.2"
|
||||
VERSION = "0.6.0"
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue