Skip to main content
Glama
6

MCP Server RubyGems

by 6

get_gem_owners

Retrieve ownership details for a specific RubyGem using the RubyGems.org API. Input the gem name to fetch its owners, aiding in package management and collaboration.

Instructions

Get the owners of a specific RubyGem

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
$schemaNo
additionalPropertiesNo
propertiesNo
requiredNo
typeNo

Implementation Reference

  • Core handler function that fetches the owners of a RubyGem from the RubyGems API and validates the response.
    async function getGemOwners(gemName: string): Promise<GemOwner[]> {
      const response = await fetch(
        `https://rubygems.org/api/v1/gems/${gemName}/owners.json`
      );
    
      if (!response.ok) {
        if (response.status === 404) {
          throw new Error(`RubyGem '${gemName}' not found`);
        }
        throw new Error(`Failed to fetch gem owners: ${response.statusText}`);
      }
    
      const data = await response.json();
      return z.array(GemOwnerSchema).parse(data);
    }
  • Input schema defining the gem_name parameter for the get_gem_owners tool.
    const GetGemOwnersInputSchema = z.object({
      gem_name: z
        .string()
        .min(1)
        .describe('Name of the RubyGem to fetch owners for'),
    });
  • Schema for individual gem owner objects used in the response validation.
    const GemOwnerSchema = z.object({
      id: z.number(),
      handle: z.string(),
      email: z.string().optional(),
    });
  • MCP tool registration including name, description, input schema conversion, and wrapper handler that parses input, calls the core handler, formats response, and handles errors.
    export const getGemOwnersTool: McpTool = {
      name: 'get_gem_owners',
      description: 'Get the owners of a specific RubyGem',
      inputSchema: {
        type: 'object',
        properties: zodToJsonSchema(GetGemOwnersInputSchema),
      },
      handler: async (args: Record<string, unknown> | undefined) => {
        const { gem_name } = GetGemOwnersInputSchema.parse(args || {});
    
        try {
          const owners = await getGemOwners(gem_name);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(owners, null, 2),
              },
            ],
          };
        } catch (error: unknown) {
          return createErrorResponse(error, 'Failed to fetch gem owners');
        }
      },
    };
  • src/index.ts:20-27 (registration)
    Registration of all tools including getGemOwnersTool in the server's tools array.
    const tools: readonly McpTool[] = [
      getRubyGemInfoTool,
      searchRubyGemsTool,
      getGemVersionsTool,
      getGemReverseDependenciesTool,
      getOwnerGemsTool,
      getGemOwnersTool,
    ] as const;
Install Server

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