Class: Evilution::MCP::InfoTool

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/evilution/mcp/info_tool.rb,
lib/evilution/mcp/info_tool/actions.rb

Defined Under Namespace

Modules: Actions, ConfigFactory, ErrorMapper, RequestParser, ResponseFormatter, StatusGlossary

Constant Summary collapse

VALID_ACTIONS =
%w[subjects tests environment statuses feedback].freeze

Class Method Summary collapse

Class Method Details

.call(server_context:, action: nil, files: nil, target: nil, spec: nil, integration: nil, skip_config: nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/evilution/mcp/info_tool.rb', line 73

def call(server_context:, action: nil, files: nil, target: nil, spec: nil, integration: nil, skip_config: nil)
  return ResponseFormatter.error("config_error", "action is required") unless action
  return ResponseFormatter.error("config_error", "unknown action: #{action}") unless ACTIONS.key?(action)

  parsed_files = nil
  line_ranges = nil
  if files
    parsed = RequestParser.parse_files(Array(files))
    parsed_files = parsed.files
    line_ranges = parsed.ranges
  end

  ACTIONS[action].call(
    files: parsed_files, line_ranges: line_ranges, target: target, spec: spec,
    integration: integration, skip_config: skip_config
  )
rescue Evilution::Error => e
  ResponseFormatter.error_for(e)
end