Class: BundlerMCP::Tools::GetGemDetails
- Inherits:
-
FastMcp::Tool
- Object
- FastMcp::Tool
- BundlerMCP::Tools::GetGemDetails
- Defined in:
- lib/bundler_mcp/tools/get_gem_details.rb
Overview
Retrieve details about a specific bundled Ruby gem
Class Method Summary collapse
-
.name ⇒ String
Tool name exposed by FastMCP to clients.
Instance Method Summary collapse
-
#call(name:) ⇒ Hash
Contains the gem’s details, or an error message if the gem is not found.
-
#initialize(collection = ResourceCollection.instance) ⇒ GetGemDetails
constructor
A new instance of GetGemDetails.
Constructor Details
#initialize(collection = ResourceCollection.instance) ⇒ GetGemDetails
Returns a new instance of GetGemDetails.
27 28 29 30 |
# File 'lib/bundler_mcp/tools/get_gem_details.rb', line 27 def initialize(collection = ResourceCollection.instance) @resource_collection = collection super() end |
Class Method Details
.name ⇒ String
Returns Tool name exposed by FastMCP to clients.
24 |
# File 'lib/bundler_mcp/tools/get_gem_details.rb', line 24 def self.name = "get_gem_details" |
Instance Method Details
#call(name:) ⇒ Hash
Returns Contains the gem’s details, or an error message if the gem is not found.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bundler_mcp/tools/get_gem_details.rb', line 34 def call(name:) name = name.to_s.strip gem_resource = resource_collection.find { |r| r.name.casecmp?(name) } data = if gem_resource gem_resource.to_h(include_source_files: true) else { error: "We could not find '#{name}' among the project's bundled gems" } end JSON.generate(data) end |