Class: Rubydex::MCPServer::GetFileDeclarationsTool
- Defined in:
- lib/rubydex/mcp_server/tools/get_file_declarations_tool.rb
Constant Summary
Constants inherited from BaseTool
Instance Method Summary collapse
-
#call(file_path:) ⇒ Object
: (file_path: String) -> 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(file_path:) ⇒ Object
: (file_path: String) -> Tool::Response
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubydex/mcp_server/tools/get_file_declarations_tool.rb', line 16 def call(file_path:) absolute_target = if Pathname.new(file_path).absolute? file_path else File.join(@root_path, file_path) end return file_not_found_response(file_path) unless File.exist?(absolute_target) document = document_for_path(file_path) return file_not_found_response(file_path) unless document declarations = document.definitions.filter_map do |definition| declaration = definition.declaration next unless declaration { name: declaration.name, kind: declaration_kind(declaration), line: definition.location.to_display.start_line, } end response(file: format_path(document.uri), declarations: declarations) end |