Class: Tools::FindReviewsTool

Inherits:
ApplicationTool show all
Defined in:
app/mcp/tools/find_reviews_tool.rb

Overview

MCP Tool for finding customer reviews.
Reviews contain real customer feedback about products and installations.

Examples:

Find reviews about floor heating

{ query: "easy to install floor heating", limit: 5 }

Class Method Summary collapse

Class Method Details

.call(query:, min_rating: 4, limit: 10, server_context: nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/mcp/tools/find_reviews_tool.rb', line 36

def call(query:, min_rating: 4, limit: 10, server_context: nil)
  limit = [[limit.to_i, 1].max, 30].min
  min_rating = [[min_rating.to_i, 1].max, 5].min

  reviews = SemanticSearchService.find_reviews(query, limit: limit * 2)
  reviews = reviews.select { |r| r.rating >= min_rating }.first(limit)

  json_response(
    query: query,
    min_rating: min_rating,
    total_results: reviews.size,
    reviews: reviews.map { |r| format_review(r) }
  )
end