Class: BundlerMCP::Tools::GetGemDetails

Inherits:
FastMcp::Tool
  • Object
show all
Defined in:
lib/bundler_mcp/tools/get_gem_details.rb

Overview

Retrieve details about a specific bundled Ruby gem

See Also:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection = ResourceCollection.instance) ⇒ GetGemDetails

Returns a new instance of GetGemDetails.

Parameters:

  • collection (ResourceCollection) (defaults to: ResourceCollection.instance)

    contains installed gems



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

.nameString

Returns Tool name exposed by FastMCP to clients.

Returns:

  • (String)

    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.

Parameters:

  • name (String)

    The name of the gem to fetch

Returns:

  • (Hash)

    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