Module: MCP::Client::ModernEnvelope
- Extended by:
- ModernEnvelope
- Included in:
- ModernEnvelope
- Defined in:
- lib/mcp/client/modern_envelope.rb
Overview
Stamps the SEP-2575 per-request _meta envelope onto outgoing modern requests.
The reserved key names are shared with the server-side MCP::RequestEnvelope.
Reserved keys always win over caller-supplied _meta entries because they are
wire vocabulary the SDK is responsible for; every other entry is preserved.
Instance Method Summary collapse
-
#stamp(request, protocol_version:, client_info:, capabilities:) ⇒ Object
Returns a copy of
requestwithparams._metacarrying the modern triple.
Instance Method Details
#stamp(request, protocol_version:, client_info:, capabilities:) ⇒ Object
Returns a copy of request with params._meta carrying the modern triple.
Neither request nor its nested hashes are mutated.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mcp/client/modern_envelope.rb', line 16 def stamp(request, protocol_version:, client_info:, capabilities:) params_key = request.key?("params") ? "params" : :params params = request[params_key] || {} = params.key?("_meta") ? "_meta" : :_meta = params[] || {} = .merge( RequestEnvelope::PROTOCOL_VERSION_META_KEY.to_sym => protocol_version, RequestEnvelope::CLIENT_INFO_META_KEY.to_sym => client_info, RequestEnvelope::CLIENT_CAPABILITIES_META_KEY.to_sym => capabilities, ) request.merge(params_key => params.merge( => )) end |