Class: MCP::Configuration
- Inherits:
-
Object
- Object
- MCP::Configuration
- Defined in:
- lib/mcp/configuration.rb
Constant Summary collapse
- LATEST_STABLE_PROTOCOL_VERSION =
"2025-11-25"- SUPPORTED_STABLE_PROTOCOL_VERSIONS =
[ LATEST_STABLE_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", ]
- DEFAULT_NEGOTIATED_PROTOCOL_VERSION =
"2025-03-26"
Instance Attribute Summary collapse
- #around_request ⇒ Object
- #exception_reporter ⇒ Object
-
#instrumentation_callback ⇒ Object
deprecated
Deprecated.
Use #around_request instead. ‘instrumentation_callback` fires only after a request completes and cannot wrap execution in a surrounding block (e.g. for Application Performance Monitoring (APM) spans).
-
#validate_tool_call_arguments ⇒ Object
Returns the value of attribute validate_tool_call_arguments.
-
#validate_tool_call_results ⇒ Object
Returns the value of attribute validate_tool_call_results.
Instance Method Summary collapse
- #around_request? ⇒ Boolean
- #exception_reporter? ⇒ Boolean
-
#initialize(exception_reporter: nil, around_request: nil, instrumentation_callback: nil, protocol_version: nil, validate_tool_call_arguments: true, validate_tool_call_results: false) ⇒ Configuration
constructor
A new instance of Configuration.
-
#instrumentation_callback? ⇒ Boolean
deprecated
Deprecated.
Use #around_request? instead.
- #merge(other) ⇒ Object
- #protocol_version ⇒ Object
- #protocol_version=(protocol_version) ⇒ Object
- #protocol_version? ⇒ Boolean
- #validate_tool_call_arguments? ⇒ Boolean
- #validate_tool_call_results? ⇒ Boolean
Constructor Details
#initialize(exception_reporter: nil, around_request: nil, instrumentation_callback: nil, protocol_version: nil, validate_tool_call_arguments: true, validate_tool_call_results: false) ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mcp/configuration.rb', line 19 def initialize(exception_reporter: nil, around_request: nil, instrumentation_callback: nil, protocol_version: nil, validate_tool_call_arguments: true, validate_tool_call_results: false) @exception_reporter = exception_reporter @around_request = around_request @instrumentation_callback = instrumentation_callback @protocol_version = protocol_version if protocol_version validate_protocol_version!(protocol_version) end validate_value_of_validate_tool_call_arguments!(validate_tool_call_arguments) validate_value_of_validate_tool_call_results!(validate_tool_call_results) @validate_tool_call_arguments = validate_tool_call_arguments @validate_tool_call_results = validate_tool_call_results end |
Instance Attribute Details
#around_request ⇒ Object
69 70 71 |
# File 'lib/mcp/configuration.rb', line 69 def around_request @around_request || default_around_request end |
#exception_reporter ⇒ Object
61 62 63 |
# File 'lib/mcp/configuration.rb', line 61 def exception_reporter @exception_reporter || default_exception_reporter end |
#instrumentation_callback ⇒ Object
Use #around_request instead. ‘instrumentation_callback` fires only after a request completes and cannot wrap execution in a surrounding block (e.g. for Application Performance Monitoring (APM) spans).
81 82 83 |
# File 'lib/mcp/configuration.rb', line 81 def instrumentation_callback @instrumentation_callback || default_instrumentation_callback end |
#validate_tool_call_arguments ⇒ Object
Returns the value of attribute validate_tool_call_arguments.
91 92 93 |
# File 'lib/mcp/configuration.rb', line 91 def validate_tool_call_arguments @validate_tool_call_arguments end |
#validate_tool_call_results ⇒ Object
Returns the value of attribute validate_tool_call_results.
92 93 94 |
# File 'lib/mcp/configuration.rb', line 92 def validate_tool_call_results @validate_tool_call_results end |
Instance Method Details
#around_request? ⇒ Boolean
73 74 75 |
# File 'lib/mcp/configuration.rb', line 73 def around_request? !@around_request.nil? end |
#exception_reporter? ⇒ Boolean
65 66 67 |
# File 'lib/mcp/configuration.rb', line 65 def exception_reporter? !@exception_reporter.nil? end |
#instrumentation_callback? ⇒ Boolean
Use #around_request? instead.
87 88 89 |
# File 'lib/mcp/configuration.rb', line 87 def instrumentation_callback? !@instrumentation_callback.nil? end |
#merge(other) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/mcp/configuration.rb', line 102 def merge(other) return self if other.nil? exception_reporter = if other.exception_reporter? other.exception_reporter else @exception_reporter end around_request = if other.around_request? other.around_request else @around_request end instrumentation_callback = if other.instrumentation_callback? other.instrumentation_callback else @instrumentation_callback end protocol_version = if other.protocol_version? other.protocol_version else @protocol_version end validate_tool_call_arguments = other.validate_tool_call_arguments validate_tool_call_results = other.validate_tool_call_results Configuration.new( exception_reporter: exception_reporter, around_request: around_request, instrumentation_callback: instrumentation_callback, protocol_version: protocol_version, validate_tool_call_arguments: validate_tool_call_arguments, validate_tool_call_results: validate_tool_call_results, ) end |
#protocol_version ⇒ Object
53 54 55 |
# File 'lib/mcp/configuration.rb', line 53 def protocol_version @protocol_version || LATEST_STABLE_PROTOCOL_VERSION end |
#protocol_version=(protocol_version) ⇒ Object
35 36 37 38 39 |
# File 'lib/mcp/configuration.rb', line 35 def protocol_version=(protocol_version) validate_protocol_version!(protocol_version) @protocol_version = protocol_version end |
#protocol_version? ⇒ Boolean
57 58 59 |
# File 'lib/mcp/configuration.rb', line 57 def protocol_version? !@protocol_version.nil? end |
#validate_tool_call_arguments? ⇒ Boolean
94 95 96 |
# File 'lib/mcp/configuration.rb', line 94 def validate_tool_call_arguments? !!@validate_tool_call_arguments end |
#validate_tool_call_results? ⇒ Boolean
98 99 100 |
# File 'lib/mcp/configuration.rb', line 98 def validate_tool_call_results? !!@validate_tool_call_results end |