Class: MCP::Configuration
- Inherits:
-
Object
- Object
- MCP::Configuration
- Defined in:
- lib/mcp/configuration.rb
Constant Summary collapse
- LATEST_STABLE_PROTOCOL_VERSION =
"2026-07-28"- SUPPORTED_STABLE_PROTOCOL_VERSIONS =
[ LATEST_STABLE_PROTOCOL_VERSION, "2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05", ].freeze
- DEFAULT_NEGOTIATED_PROTOCOL_VERSION =
"2025-03-26"- LATEST_MODERN_PROTOCOL_VERSION =
Protocol versions of the stateless "modern" lifecycle introduced by the MCP 2026-07-28 spec release (SEP-2575). 2026-07-28 serves both lifecycles of the dual-era model: it is negotiable through the legacy
initializehandshake (so it also appears inSUPPORTED_STABLE_PROTOCOL_VERSIONS), and it is the version of the modern lifecycle, where each request carries its own version in_metaand is validated against this list independently, with no handshake. https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2575 "2026-07-28"- SUPPORTED_MODERN_PROTOCOL_VERSIONS =
[LATEST_MODERN_PROTOCOL_VERSION].freeze
Instance Attribute Summary collapse
- #around_request ⇒ Object
- #exception_reporter ⇒ Object
-
#instrumentation_callback ⇒ Object
deprecated
Deprecated.
Use #around_request instead.
instrumentation_callbackfires 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.
Class Method Summary collapse
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.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mcp/configuration.rb', line 34 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
84 85 86 |
# File 'lib/mcp/configuration.rb', line 84 def around_request @around_request || default_around_request end |
#exception_reporter ⇒ Object
76 77 78 |
# File 'lib/mcp/configuration.rb', line 76 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).
96 97 98 |
# File 'lib/mcp/configuration.rb', line 96 def instrumentation_callback @instrumentation_callback || default_instrumentation_callback end |
#validate_tool_call_arguments ⇒ Object
Returns the value of attribute validate_tool_call_arguments.
106 107 108 |
# File 'lib/mcp/configuration.rb', line 106 def validate_tool_call_arguments @validate_tool_call_arguments end |
#validate_tool_call_results ⇒ Object
Returns the value of attribute validate_tool_call_results.
107 108 109 |
# File 'lib/mcp/configuration.rb', line 107 def validate_tool_call_results @validate_tool_call_results end |
Class Method Details
.modern_protocol_version?(version) ⇒ Boolean
21 22 23 |
# File 'lib/mcp/configuration.rb', line 21 def modern_protocol_version?(version) SUPPORTED_MODERN_PROTOCOL_VERSIONS.include?(version) end |
Instance Method Details
#around_request? ⇒ Boolean
88 89 90 |
# File 'lib/mcp/configuration.rb', line 88 def around_request? !@around_request.nil? end |
#exception_reporter? ⇒ Boolean
80 81 82 |
# File 'lib/mcp/configuration.rb', line 80 def exception_reporter? !@exception_reporter.nil? end |
#instrumentation_callback? ⇒ Boolean
Use #around_request? instead.
102 103 104 |
# File 'lib/mcp/configuration.rb', line 102 def instrumentation_callback? !@instrumentation_callback.nil? end |
#merge(other) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/mcp/configuration.rb', line 117 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
68 69 70 |
# File 'lib/mcp/configuration.rb', line 68 def protocol_version @protocol_version || LATEST_STABLE_PROTOCOL_VERSION end |
#protocol_version=(protocol_version) ⇒ Object
50 51 52 53 54 |
# File 'lib/mcp/configuration.rb', line 50 def protocol_version=(protocol_version) validate_protocol_version!(protocol_version) @protocol_version = protocol_version end |
#protocol_version? ⇒ Boolean
72 73 74 |
# File 'lib/mcp/configuration.rb', line 72 def protocol_version? !@protocol_version.nil? end |
#validate_tool_call_arguments? ⇒ Boolean
109 110 111 |
# File 'lib/mcp/configuration.rb', line 109 def validate_tool_call_arguments? !!@validate_tool_call_arguments end |
#validate_tool_call_results? ⇒ Boolean
113 114 115 |
# File 'lib/mcp/configuration.rb', line 113 def validate_tool_call_results? !!@validate_tool_call_results end |