Module: RubynCode::MCP::ToolBridge

Defined in:
lib/rubyn_code/mcp/tool_bridge.rb

Overview

Wraps MCP tools as native RubynCode tools by dynamically creating tool classes that delegate execution to the MCP client.

Each bridged tool:

  • Has TOOL_NAME prefixed with “mcp_”

  • Has RISK_LEVEL = :external

  • Delegates #execute to the MCP client’s #call_tool

  • Registers itself with Tools::Registry

Constant Summary collapse

JSON_TYPE_MAP =
{
  'string' => :string, 'integer' => :integer, 'number' => :number,
  'boolean' => :boolean, 'array' => :array, 'object' => :object
}.freeze

Class Method Summary collapse

Class Method Details

.bridge(mcp_client) ⇒ Array<Class>

Discovers tools from an MCP client and creates corresponding RubynCode tool classes.

Parameters:

Returns:

  • (Array<Class>)

    the dynamically created tool classes



25
26
27
28
29
30
31
32
# File 'lib/rubyn_code/mcp/tool_bridge.rb', line 25

def bridge(mcp_client)
  tools = mcp_client.tools
  return [] if tools.nil? || tools.empty?

  tools.map do |tool_def|
    build_tool_class(mcp_client, tool_def)
  end
end