Class: Hitch::MCP::Context

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

Overview

Frozen, request-local authority envelope passed to host MCP policy and behavior. Host and Active Record references are intentionally preserved as opaque references; freezing this envelope does not claim to freeze those objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(principal:, access_token:, scope:, granted_scopes:, client_id:, resource:, request_id:, remote_ip:, user_agent:, protocol_version:, meta:) ⇒ Context

Returns a new instance of Context.

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/hitch/mcp/context.rb', line 13

def initialize(
  principal:,
  access_token:,
  scope:,
  granted_scopes:,
  client_id:,
  resource:,
  request_id:,
  remote_ip:,
  user_agent:,
  protocol_version:,
  meta:
)
  raise ArgumentError, "principal is required" if principal.nil?
  raise ArgumentError, "access_token is required" if access_token.nil?

  @principal = principal
  @access_token = access_token
  @scope = scope
  @granted_scopes = copy_scopes(granted_scopes)
  @client_id = copy_required_string(client_id, "client_id")
  @resource = copy_required_string(resource, "resource")
  @request_id = copy_request_id(request_id)
  @remote_ip = copy_required_string(remote_ip, "remote_ip")
  @user_agent = copy_optional_string(user_agent, "user_agent")
  @protocol_version = copy_required_string(protocol_version, "protocol_version")
  @meta = copy_meta(meta)
  freeze
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def access_token
  @access_token
end

#client_idObject (readonly)

Returns the value of attribute client_id.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def client_id
  @client_id
end

#granted_scopesObject (readonly)

Returns the value of attribute granted_scopes.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def granted_scopes
  @granted_scopes
end

#metaObject (readonly)

Returns the value of attribute meta.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def meta
  @meta
end

#principalObject (readonly)

Returns the value of attribute principal.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def principal
  @principal
end

#protocol_versionObject (readonly)

Returns the value of attribute protocol_version.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def protocol_version
  @protocol_version
end

#remote_ipObject (readonly)

Returns the value of attribute remote_ip.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def remote_ip
  @remote_ip
end

#request_idObject (readonly)

Returns the value of attribute request_id.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def request_id
  @request_id
end

#resourceObject (readonly)

Returns the value of attribute resource.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def resource
  @resource
end

#scopeObject (readonly)

Returns the value of attribute scope.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def scope
  @scope
end

#user_agentObject (readonly)

Returns the value of attribute user_agent.



10
11
12
# File 'app/models/hitch/mcp/context.rb', line 10

def user_agent
  @user_agent
end