Allow specifying a server version

This commit is contained in:
Kevin Fischer 2025-05-13 23:51:02 +09:00
commit ea4828987c
No known key found for this signature in database
GPG key ID: 8E4CB46A9AC8D1C1

View file

@ -6,6 +6,8 @@ require_relative "methods"
module ModelContextProtocol
class Server
DEFAULT_VERSION = "0.1.0"
class RequestHandlerError < StandardError
attr_reader :error_type
attr_reader :original_error
@ -20,10 +22,11 @@ module ModelContextProtocol
include Instrumentation
attr_accessor :name, :tools, :prompts, :resources, :server_context, :configuration, :capabilities
attr_accessor :name, :version, :tools, :prompts, :resources, :server_context, :configuration, :capabilities
def initialize(
name: "model_context_protocol",
version: DEFAULT_VERSION,
tools: [],
prompts: [],
resources: [],
@ -33,6 +36,7 @@ module ModelContextProtocol
capabilities: { prompts: {}, resources: {}, tools: {} }
)
@name = name
@version = version
@tools = tools.to_h { |t| [t.name_value, t] }
@prompts = prompts.to_h { |p| [p.name_value, p] }
@resources = resources
@ -153,7 +157,7 @@ module ModelContextProtocol
def server_info
@server_info ||= {
name:,
version: ModelContextProtocol::VERSION,
version:,
}
end