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_enabled(&block) ⇒ Object

Iterate over enabled upstreams



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

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

#enabled_upstreamsArray<Upstream>

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

Returns:



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

def enabled_upstreams
  @enabled_upstreams ||= build_upstreams
end

#find(service_key) ⇒ Upstream?

Find an upstream by service key

Parameters:

  • service_key (String)

Returns:



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

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