Class: Tools::FindSupportCasesTool
- Inherits:
-
ApplicationTool
- Object
- MCP::Tool
- ApplicationTool
- Tools::FindSupportCasesTool
- Defined in:
- app/mcp/tools/find_support_cases_tool.rb
Overview
MCP Tool for searching and filtering support cases.
Supports structured queries by customer, case number, state, type, date range,
and assigned employee — returning case summaries with participant and activity counts.
Class Method Summary collapse
Class Method Details
.call(query: nil, customer: nil, state: nil, case_type: nil, assigned_to: nil, date_from: nil, date_to: nil, limit: 15, server_context: nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/mcp/tools/find_support_cases_tool.rb', line 64 def call(query: nil, customer: nil, state: nil, case_type: nil, assigned_to: nil, date_from: nil, date_to: nil, limit: 15, server_context: nil) limit = [[limit.to_i, 1].max, 50].min scope = SupportCase.includes(:assigned_to, support_case_participants: :party).order(created_at: :desc) scope = apply_query_filter(scope, query) scope = apply_customer_filter(scope, customer) scope = apply_state_filter(scope, state) scope = scope.where(case_type: case_type) if case_type.present? scope = apply_assigned_filter(scope, assigned_to) date_err = validate_date_params(date_from, date_to) return json_response(error: date_err) if date_err scope = apply_date_range(scope, date_from, date_to) cases = scope.limit(limit).to_a activity_counts, communication_counts = batch_counts_for(cases) json_response( filters: { query: query, customer: customer, state: state, case_type: case_type, assigned_to: assigned_to, date_from: date_from, date_to: date_to }.compact, total_results: cases.size, support_cases: cases.map { |sc| format_case_summary(sc, activity_counts, communication_counts) } ) end |