Class: StatusMcp::Server::GetServiceDetailsTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/status_mcp/server.rb

Instance Method Summary collapse

Instance Method Details

#call(name:) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/status_mcp/server.rb', line 167

def call(name:)
  services = load_data
  fuzzy_results = find_services_fuzzy(services, name, threshold: 0.6)

  if fuzzy_results.empty?
    "Service '#{name}' not found"
  elsif fuzzy_results.first[:match_type] == :exact || fuzzy_results.first[:score] >= 0.9
    # Exact match or very high confidence - return the best match
    format_service(fuzzy_results.first[:service])
  elsif fuzzy_results.length == 1
    # Single fuzzy match - return it
    format_service(fuzzy_results.first[:service])
  else
    # Multiple matches - show the best one but mention alternatives
    best_match = fuzzy_results.first
    alternatives = fuzzy_results[1..2].map { |r| r[:service]["name"] }.compact

    output = format_service(best_match[:service])
    if alternatives.any?
      output += "\n\n**Note**: Did you mean one of these? #{alternatives.join(", ")}"
    end
    output
  end
end