@@ -5,20 +5,29 @@ class Configuration
55 DEFAULT_PROTOCOL_VERSION = "2025-06-18"
66 SUPPORTED_PROTOCOL_VERSIONS = [ DEFAULT_PROTOCOL_VERSION , "2025-03-26" , "2024-11-05" ]
77
8- attr_writer :exception_reporter , :instrumentation_callback , :protocol_version , :validate_tool_call_arguments
8+ attr_writer :exception_reporter , :instrumentation_callback
99
1010 def initialize ( exception_reporter : nil , instrumentation_callback : nil , protocol_version : nil ,
1111 validate_tool_call_arguments : true )
1212 @exception_reporter = exception_reporter
1313 @instrumentation_callback = instrumentation_callback
1414 @protocol_version = protocol_version
15- if protocol_version && !SUPPORTED_PROTOCOL_VERSIONS . include? ( protocol_version )
16- message = "protocol_version must be #{ SUPPORTED_PROTOCOL_VERSIONS [ 0 ...-1 ] . join ( ", " ) } , or #{ SUPPORTED_PROTOCOL_VERSIONS [ -1 ] } "
17- raise ArgumentError , message
18- end
19- unless validate_tool_call_arguments . is_a? ( TrueClass ) || validate_tool_call_arguments . is_a? ( FalseClass )
20- raise ArgumentError , "validate_tool_call_arguments must be a boolean"
15+ if protocol_version
16+ validate_protocol_version! ( protocol_version )
2117 end
18+ validate_value_of_validate_tool_call_arguments! ( validate_tool_call_arguments )
19+
20+ @validate_tool_call_arguments = validate_tool_call_arguments
21+ end
22+
23+ def protocol_version = ( protocol_version )
24+ validate_protocol_version! ( protocol_version )
25+
26+ @protocol_version = protocol_version
27+ end
28+
29+ def validate_tool_call_arguments = ( validate_tool_call_arguments )
30+ validate_value_of_validate_tool_call_arguments! ( validate_tool_call_arguments )
2231
2332 @validate_tool_call_arguments = validate_tool_call_arguments
2433 end
@@ -83,6 +92,19 @@ def merge(other)
8392
8493 private
8594
95+ def validate_protocol_version! ( protocol_version )
96+ unless SUPPORTED_PROTOCOL_VERSIONS . include? ( protocol_version )
97+ message = "protocol_version must be #{ SUPPORTED_PROTOCOL_VERSIONS [ 0 ...-1 ] . join ( ", " ) } , or #{ SUPPORTED_PROTOCOL_VERSIONS [ -1 ] } "
98+ raise ArgumentError , message
99+ end
100+ end
101+
102+ def validate_value_of_validate_tool_call_arguments! ( validate_tool_call_arguments )
103+ unless validate_tool_call_arguments . is_a? ( TrueClass ) || validate_tool_call_arguments . is_a? ( FalseClass )
104+ raise ArgumentError , "validate_tool_call_arguments must be a boolean"
105+ end
106+ end
107+
86108 def default_exception_reporter
87109 @default_exception_reporter ||= -> ( exception , server_context ) { }
88110 end
0 commit comments