get_gem_reverse_dependencies
Identify RubyGems that depend on a specific gem by querying reverse dependencies, using the MCP Server RubyGems API for accurate dependency insights.
Instructions
Get gems that depend on a specific RubyGem
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| $schema | No | ||
| additionalProperties | No | ||
| properties | No | ||
| required | No | ||
| type | No |
Implementation Reference
- Zod input schema defining the gem_name parameter for the tool.const GetGemReverseDependenciesInputSchema = z.object({ gem_name: z .string() .min(1) .describe('Name of the RubyGem to fetch reverse dependencies for'), });
- Core handler function that fetches and parses reverse dependencies from the RubyGems API.async function getGemReverseDependencies(gemName: string): Promise<string[]> { const response = await fetch( `https://rubygems.org/api/v1/gems/${gemName}/reverse_dependencies.json` ); if (!response.ok) { if (response.status === 404) { throw new Error(`RubyGem '${gemName}' not found`); } throw new Error( `Failed to fetch reverse dependencies: ${response.statusText}` ); } const data = await response.json(); return z.array(z.string()).parse(data); }
- src/tools/get_gem_reverse_dependencies.ts:34-61 (registration)Exports the McpTool object, registering the tool with its name, description, input schema, and wrapper handler.export const getGemReverseDependenciesTool: McpTool = { name: 'get_gem_reverse_dependencies', description: 'Get gems that depend on a specific RubyGem', inputSchema: { type: 'object', properties: zodToJsonSchema(GetGemReverseDependenciesInputSchema), }, handler: async (args: Record<string, unknown> | undefined) => { const { gem_name } = GetGemReverseDependenciesInputSchema.parse(args || {}); try { const reverseDependencies = await getGemReverseDependencies(gem_name); return { content: [ { type: 'text', text: JSON.stringify(reverseDependencies, null, 2), }, ], }; } catch (error: unknown) { return createErrorResponse( error, 'Failed to fetch gem reverse dependencies' ); } }, };
- src/index.ts:20-27 (registration)Includes the getGemReverseDependenciesTool in the list of available tools served by the MCP server.const tools: readonly McpTool[] = [ getRubyGemInfoTool, searchRubyGemsTool, getGemVersionsTool, getGemReverseDependenciesTool, getOwnerGemsTool, getGemOwnersTool, ] as const;