Module: AIA::McpParser

Defined in:
lib/aia/config/mcp_parser.rb

Class Method Summary collapse

Class Method Details

.parse_files(file_paths) ⇒ Array<Hash>

Parse MCP server configuration files and return array of server configs in robot_lab's nested transport format.

Parameters:

  • file_paths (Array<String>)

    paths to JSON configuration files

Returns:

  • (Array<Hash>)

    array of server configurations with nested transport



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/aia/config/mcp_parser.rb', line 48

def parse_files(file_paths)
  return [] if file_paths.nil? || file_paths.empty?

  servers = []

  file_paths.each do |file_path|
    expanded_path = File.expand_path(file_path)

    unless File.exist?(expanded_path)
      $stderr.puts "Warning: MCP config file not found: #{file_path}"
      next
    end

    begin
      json_content = File.read(expanded_path)
      parsed = JSON.parse(json_content)
      servers.concat(convert_to_config_format(parsed, file_path))
    rescue JSON::ParserError => e
      $stderr.puts "Warning: Invalid JSON in MCP config file '#{file_path}': #{e.message}"
    rescue StandardError => e
      $stderr.puts "Warning: Error reading MCP config file '#{file_path}': #{e.message}"
    end
  end

  servers
end