Class: UpstreamRegistry

Inherits:
Object
  • Object
show all
Defined in:
app/mcp/upstream_registry.rb

Overview

Registry of upstream MCP servers that can be proxied through our gateway.

Each upstream is identified by a service key (matching ApiAuthentication::UPSTREAM_SERVICES)
and has a URL, optional headers, and connection state.

Credentials are loaded from Rails credentials under mcp.upstream.<service_key>.

Examples:

registry = UpstreamRegistry.new
registry.each_enabled do |service_key, upstream|
  client = upstream.connect
  tools = client.tools
end

Defined Under Namespace

Classes: Upstream

Instance Method Summary collapse

Instance Method Details

#each_enabledObject

Iterate over enabled upstreams



28
29
30
# File 'app/mcp/upstream_registry.rb', line 28

def each_enabled(&)
  enabled_upstreams.each(&)
end

#enabled_upstreamsArray<Upstream>

Returns all configured upstream servers (those with credentials present).

Returns:



23
24
25
# File 'app/mcp/upstream_registry.rb', line 23

def enabled_upstreams
  @enabled_upstreams ||= build_upstreams
end

#find(service_key) ⇒ Upstream?

Find an upstream by service key

Parameters:

  • service_key (String)

Returns:



35
36
37
# File 'app/mcp/upstream_registry.rb', line 35

def find(service_key)
  enabled_upstreams.find { |u| u.service_key == service_key }
end