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", ]
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.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mcp/configuration.rb', line 18 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
68 69 70 |
# File 'lib/mcp/configuration.rb', line 68 def around_request @around_request || default_around_request end |
#exception_reporter ⇒ Object
60 61 62 |
# File 'lib/mcp/configuration.rb', line 60 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).
80 81 82 |
# File 'lib/mcp/configuration.rb', line 80 def instrumentation_callback @instrumentation_callback || default_instrumentation_callback end |
#validate_tool_call_arguments ⇒ Object
Returns the value of attribute validate_tool_call_arguments.
90 91 92 |
# File 'lib/mcp/configuration.rb', line 90 def validate_tool_call_arguments @validate_tool_call_arguments end |
#validate_tool_call_results ⇒ Object
Returns the value of attribute validate_tool_call_results.
91 92 93 |
# File 'lib/mcp/configuration.rb', line 91 def validate_tool_call_results @validate_tool_call_results end |
Instance Method Details
#around_request? ⇒ Boolean
72 73 74 |
# File 'lib/mcp/configuration.rb', line 72 def around_request? !@around_request.nil? end |
#exception_reporter? ⇒ Boolean
64 65 66 |
# File 'lib/mcp/configuration.rb', line 64 def exception_reporter? !@exception_reporter.nil? end |
#instrumentation_callback? ⇒ Boolean
Use #around_request? instead.
86 87 88 |
# File 'lib/mcp/configuration.rb', line 86 def instrumentation_callback? !@instrumentation_callback.nil? end |
#merge(other) ⇒ Object
101 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 |
# File 'lib/mcp/configuration.rb', line 101 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
52 53 54 |
# File 'lib/mcp/configuration.rb', line 52 def protocol_version @protocol_version || LATEST_STABLE_PROTOCOL_VERSION end |
#protocol_version=(protocol_version) ⇒ Object
34 35 36 37 38 |
# File 'lib/mcp/configuration.rb', line 34 def protocol_version=(protocol_version) validate_protocol_version!(protocol_version) @protocol_version = protocol_version end |
#protocol_version? ⇒ Boolean
56 57 58 |
# File 'lib/mcp/configuration.rb', line 56 def protocol_version? !@protocol_version.nil? end |
#validate_tool_call_arguments? ⇒ Boolean
93 94 95 |
# File 'lib/mcp/configuration.rb', line 93 def validate_tool_call_arguments? !!@validate_tool_call_arguments end |
#validate_tool_call_results? ⇒ Boolean
97 98 99 |
# File 'lib/mcp/configuration.rb', line 97 def validate_tool_call_results? !!@validate_tool_call_results end |