Class: Rubydex::MCPServer::SearchDeclarationsTool
- Defined in:
- lib/rubydex/mcp_server/tools/search_declarations_tool.rb
Constant Summary
Constants inherited from BaseTool
Instance Method Summary collapse
-
#call(query:, kind: nil, match_mode: nil, limit: nil, offset: nil) ⇒ Object
: (query: String, ?kind: String, ?match_mode: String, ?limit: Integer, ?offset: Integer) -> Tool::Response.
Methods inherited from BaseTool
#declaration_kind, #display_location, #document_for_path, #file_path_for_uri, #format_path, #initialize, #lookup_declaration, #paginate, #response
Methods inherited from Tool
description, inherited, input_schema, to_h, tool_name, tools_by_name
Constructor Details
This class inherits a constructor from Rubydex::MCPServer::BaseTool
Instance Method Details
#call(query:, kind: nil, match_mode: nil, limit: nil, offset: nil) ⇒ Object
: (query: String, ?kind: String, ?match_mode: String, ?limit: Integer, ?offset: Integer) -> Tool::Response
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubydex/mcp_server/tools/search_declarations_tool.rb', line 20 def call(query:, kind: nil, match_mode: nil, limit: nil, offset: nil) declarations = case match_mode when nil, "fuzzy" @graph.fuzzy_search(query) when "exact" @graph.search(query) else return response( Error.new( "invalid_match_mode", "Invalid match_mode '#{match_mode}'", 'Use "fuzzy" or "exact"', ), ) end if kind declarations = declarations.lazy.select { |declaration| declaration_kind(declaration).casecmp?(kind) } end page, total = paginate(declarations, offset, limit, 100) results = page.map do |declaration| { name: declaration.name, kind: declaration_kind(declaration), locations: declaration.definitions.map do |definition| display_location(definition.location) end, } end response(results: results, total: total) end |