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
- INPUT_SCHEMA =
{ type: 'object', properties: { file_path: { type: 'string', description: 'File path to query applicable rules for' }, tool_name: { type: 'string', description: 'Tool name to query applicable rules for' }, action: { type: 'string', description: 'Action to query applicable rules for' } } }.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.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rosett_ai/mcp/tools/context_query_tool.rb', line 55 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 |