Class: RosettAi::Mcp::Tools::ContextQueryTool
- Inherits:
-
Object
- Object
- RosettAi::Mcp::Tools::ContextQueryTool
- Defined in:
- lib/rosett_ai/mcp/tools/context_query_tool.rb
Overview
MCP tool: query applicable rules for a given context.
Answers "What rules apply to this situation?" by matching rules against a file path, tool name, or action. Returns applicable rules ranked by priority. Read-only operation.
Constant Summary collapse
- TOOL_NAME =
'rai_context_query'- DESCRIPTION =
'Query applicable rules for a file path, tool name, or action'- ANNOTATIONS =
{ 'readOnlyHint' => true, 'destructiveHint' => false, 'idempotentHint' => true, 'openWorldHint' => false }.freeze
Instance Method Summary collapse
-
#call(file_path: nil, tool_name: nil, action: nil) ⇒ Hash
Queries rules applicable to the given context.
Instance Method Details
#call(file_path: nil, tool_name: nil, action: nil) ⇒ Hash
Queries rules applicable to the given context.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rosett_ai/mcp/tools/context_query_tool.rb', line 37 def call(file_path: nil, tool_name: nil, action: nil) query = build_query(file_path, tool_name, action) return ResponseHelper.error('At least one query parameter required') if query.empty? matches = search_rules(query) matches.sort_by! { |m| -(m[:priority] || 0) } { applicable_rules: matches, total: matches.size, query: query } rescue StandardError => e ResponseHelper.error("Context query failed: #{e.}") end |