Class: Hitch::MCP::Internal::VerifiedRequest

Inherits:
Object
  • Object
show all
Defined in:
app/models/hitch/mcp/internal/verified_request.rb

Overview

Builds the one immutable request value that may cross into the SDK. HTTP media and body-size admission happen before this object sees bytes.

Defined Under Namespace

Classes: Failure

Constant Summary collapse

CLIENT_INFO_KEY =
"io.modelcontextprotocol/clientInfo"
CLIENT_INFO_STRING_KEYS =
%w[name version title description websiteUrl].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_body, headers) ⇒ VerifiedRequest

Returns a new instance of VerifiedRequest.



32
33
34
35
# File 'app/models/hitch/mcp/internal/verified_request.rb', line 32

def initialize(raw_body, headers)
  @raw_body = raw_body
  @headers = headers
end

Class Method Details

.call(raw_body:, headers:) ⇒ Object



27
28
29
# File 'app/models/hitch/mcp/internal/verified_request.rb', line 27

def call(raw_body:, headers:)
  new(raw_body, headers).call
end

Instance Method Details

#callObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/hitch/mcp/internal/verified_request.rb', line 37

def call
  parsed = parse
  validate_json_values!(parsed)
  request_id = validate_envelope!(parsed)
  validate_metadata!(parsed, request_id)
  validate_protocol_and_method_headers!(parsed, request_id)
  validate_method!(parsed, request_id)
  validate_call_shape!(parsed, request_id)
  validate_name_header!(parsed, request_id)
  validate_reserved_arguments!(parsed, request_id)
  # The parse output is freshly built and aliased by nothing, so the
  # product needs freezing, not another copy of the whole tree.
  JsonValues.deep_freeze(parsed)
end