Class: RosettAi::Mcp::Tools::RuleSearchTool
- Inherits:
-
Object
- Object
- RosettAi::Mcp::Tools::RuleSearchTool
- Defined in:
- lib/rosett_ai/mcp/tools/rule_search_tool.rb
Overview
MCP tool: search compiled rules by keyword.
Searches behaviour YAML source files for rules matching a keyword, with optional filters for minimum priority, scope, and enabled status. Read-only operation.
Constant Summary collapse
- TOOL_NAME =
'rai_rule_search'- DESCRIPTION =
'Search rules by keyword with optional priority/scope/enabled filters'- ANNOTATIONS =
{ 'readOnlyHint' => true, 'destructiveHint' => false, 'idempotentHint' => true, 'openWorldHint' => false }.freeze
Instance Method Summary collapse
-
#call(keyword:, priority_min: nil, scope: nil, enabled_only: true) ⇒ Hash
Searches rules across all behaviour files.
Instance Method Details
#call(keyword:, priority_min: nil, scope: nil, enabled_only: true) ⇒ Hash
Searches rules across all behaviour files.
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rosett_ai/mcp/tools/rule_search_tool.rb', line 38 def call(keyword:, priority_min: nil, scope: nil, enabled_only: true) matches = [] each_behaviour_file do |path, data| search_behaviour(data, keyword, path, matches) end matches = apply_filters(matches, priority_min, scope, enabled_only) matches.sort_by! { |m| -(m[:priority] || 0) } { keyword: keyword, matches: matches, total: matches.size } rescue StandardError => e ResponseHelper.error("Rule search failed: #{e.}") end |