Class: ProxyToolBuilder
- Inherits:
-
Object
- Object
- ProxyToolBuilder
- Defined in:
- app/mcp/proxy_tool_builder.rb
Overview
Builds dynamic MCP::Tool subclasses that proxy calls to upstream MCP servers.
Each tool is namespaced with the upstream service key to avoid name collisions:
service_tool-name → calls upstream tool "tool-name" on that service
Access control is enforced per-call by checking Thread.current[:mcp_auth_result],
which is set by the McpBearerAuth middleware in config.ru.
Class Method Summary collapse
-
.build(upstream_proxy) ⇒ Array<Class>
Build tool classes for all tools advertised by an upstream proxy.
Class Method Details
.build(upstream_proxy) ⇒ Array<Class>
Build tool classes for all tools advertised by an upstream proxy.
23 24 25 26 27 28 29 30 31 32 |
# File 'app/mcp/proxy_tool_builder.rb', line 23 def self.build(upstream_proxy) service_key = upstream_proxy.service_key upstream_proxy.list_tools.filter_map do |remote_tool| build_one(service_key, upstream_proxy, remote_tool) rescue => e Rails.logger.warn "[MCP Proxy] Skipping tool #{remote_tool.name} from #{service_key}: #{e.}" nil end end |