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

Parameters:

  • file_paths (Array<String>)

    paths to JSON configuration files

Returns:

  • (Array<Hash>)

    array of server configurations



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/aia/config/mcp_parser.rb', line 37

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)
      warn "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
      warn "Warning: Invalid JSON in MCP config file '#{file_path}': #{e.message}"
    rescue StandardError => e
      warn "Warning: Error reading MCP config file '#{file_path}': #{e.message}"
    end
  end

  servers
end