Skip to main content
Glama
6
by 6

get_rubygem_info

Fetch detailed metadata about a RubyGem from RubyGems.org API using the input gem name. Retrieve information such as dependencies, ownership, and package details for efficient Ruby development workflows.

Instructions

Get information about a RubyGem from the RubyGems.org API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
$schemaNo
additionalPropertiesNo
propertiesNo
requiredNo
typeNo

Implementation Reference

  • Core handler function that fetches RubyGem information from the RubyGems.org API, handles HTTP errors (including 404), parses JSON response, and validates with Zod schema.
    async function getRubyGemInfo(gemName: string): Promise<RubyGemInfo> { const response = await fetch( `https://rubygems.org/api/v1/gems/${gemName}.json` ); if (!response.ok) { if (response.status === 404) { throw new Error(`RubyGem '${gemName}' not found`); } throw new Error(`Failed to fetch RubyGem info: ${response.statusText}`); } const data = await response.json(); return RubyGemInfoSchema.parse(data); }
  • Zod schema defining the structure of RubyGem info returned by the API, used for response validation.
    const RubyGemInfoSchema = z.object({ name: z.string(), version: z.string(), downloads: z.number(), info: z.string(), homepage_uri: z.string().nullable(), source_code_uri: z.string().nullable(), documentation_uri: z.string().nullable(), bug_tracker_uri: z.string().nullable(), authors: z.string(), licenses: z.array(z.string()), metadata: z.record(z.string(), z.any()).optional(), });
  • Zod input schema for the tool, validating the required 'rubygem_name' parameter.
    const GetRubyGemInfoInputSchema = z.object({ rubygem_name: z .string() .min(1) .describe('Name of the RubyGem to fetch information for'), });
  • Export of the MCP tool object 'getRubyGemInfoTool' with name, description, converted JSON input schema, and wrapper handler that parses input, calls core handler, returns formatted text response or error.
    export const getRubyGemInfoTool: McpTool = { name: 'get_rubygem_info', description: 'Get information about a RubyGem from the RubyGems.org API', inputSchema: { type: 'object', properties: zodToJsonSchema(GetRubyGemInfoInputSchema), }, handler: async (args: Record<string, unknown> | undefined) => { const { rubygem_name } = GetRubyGemInfoInputSchema.parse(args || {}); try { const gemInfo = await getRubyGemInfo(rubygem_name); return { content: [ { type: 'text', text: JSON.stringify(gemInfo, null, 2), }, ], }; } catch (error: unknown) { // Return error context instead of throwing an error return createErrorResponse(error, 'Failed to fetch RubyGem info'); } }, };
  • src/index.ts:20-27 (registration)
    Registration of getRubyGemInfoTool (first in list) in the server's tools array, used by ListToolsRequestHandler and CallToolRequestHandler.
    const tools: readonly McpTool[] = [ getRubyGemInfoTool, searchRubyGemsTool, getGemVersionsTool, getGemReverseDependenciesTool, getOwnerGemsTool, getGemOwnersTool, ] as const;

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/6/mcp-server-rubygems'

If you have feedback or need assistance with the MCP directory API, please join our Discord server