Skip to main content
Glama
6

MCP Server RubyGems

by 6

search_rubygems

Find RubyGems by searching gem names and descriptions using a query string. Customize results with a limit parameter up to 30. Example queries include 'authentication' or 'aws sdk'.

Instructions

Search for RubyGems matching a query string. The search matches against gem names and descriptions. Returns up to 10 results by default (customizable with limit parameter), ordered by relevance. Example queries: "authentication", "rails middleware", "aws sdk"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
$schemaNo
additionalPropertiesNo
propertiesNo
requiredNo
typeNo

Implementation Reference

  • Core handler function that executes the tool logic: fetches search results from RubyGems API, validates with Zod schema, applies limit, and returns results.
    async function searchRubyGems(
      query: string,
      limit?: number
    ): Promise<RubyGemSearchResult[]> {
      const response = await fetch(
        `https://rubygems.org/api/v1/search.json?query=${encodeURIComponent(query)}`
      );
    
      if (!response.ok) {
        throw new Error(`Failed to search RubyGems: ${response.statusText}`);
      }
    
      const data = await response.json();
      const results = z.array(RubyGemSearchResultSchema).parse(data);
    
      // Apply limit if provided
      if (limit && limit > 0) {
        return results.slice(0, limit);
      }
    
      return results;
    }
  • Input schema for the search_rubygems tool using Zod, defining query and optional limit parameters.
    const SearchRubyGemsInputSchema = z.object({
      query: z.string().min(1).describe('Search query for finding RubyGems'),
      limit: z
        .number()
        .int()
        .positive()
        .max(30)
        .optional()
        .describe('Maximum number of results to return (default: 10, max: 30)'),
    });
  • Schema for individual RubyGem search results used for response validation.
    const RubyGemSearchResultSchema = 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(),
    });
  • Exports the McpTool object for search_rubygems, including name, description, inputSchema, and wrapper handler that parses args, calls core function, formats response or error.
    export const searchRubyGemsTool: McpTool = {
      name: 'search_rubygems',
      description:
        'Search for RubyGems matching a query string. The search matches against gem names and descriptions. Returns up to 10 results by default (customizable with limit parameter), ordered by relevance. Example queries: "authentication", "rails middleware", "aws sdk"',
      inputSchema: {
        type: 'object',
        properties: zodToJsonSchema(SearchRubyGemsInputSchema),
      },
      handler: async (args: Record<string, unknown> | undefined) => {
        const { query, limit } = SearchRubyGemsInputSchema.parse(args || {});
        const resultLimit = limit || 10; // Default to 10 if not specified
    
        try {
          const results = await searchRubyGems(query, resultLimit);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(results, null, 2),
              },
            ],
          };
        } catch (error: unknown) {
          // Return error context instead of throwing an error
          return createErrorResponse(error, 'Failed to search RubyGems');
        }
      },
    };
  • src/index.ts:20-27 (registration)
    Registers searchRubyGemsTool in the server's tools array for use in MCP server.
    const tools: readonly McpTool[] = [
      getRubyGemInfoTool,
      searchRubyGemsTool,
      getGemVersionsTool,
      getGemReverseDependenciesTool,
      getOwnerGemsTool,
      getGemOwnersTool,
    ] as const;
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: the search scope (gem names and descriptions), result ordering (by relevance), default limit (10 results), and customizability. It doesn't mention rate limits, authentication needs, or error conditions, but provides substantial operational context for a search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with three sentences that each add value: stating the purpose, explaining search behavior, and providing examples. It's front-loaded with the core functionality and avoids any redundant or unnecessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with no annotations and no output schema, the description provides good coverage of what the tool does, how it behaves, and parameter usage. It could be more complete by mentioning the format of returned results or error handling, but it gives the agent enough information to use the tool effectively in most scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context about parameters beyond what the schema provides. While the schema has 0% description coverage and 5 parameters (though only 2 are shown in the provided schema), the description explains the 'limit' parameter's default value and purpose, and provides example queries that illustrate how the 'query' parameter should be used. This compensates well for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Search for RubyGems'), the target resource ('RubyGems'), and the matching criteria ('against gem names and descriptions'). It distinguishes this search tool from sibling tools that retrieve specific gem information, owners, or dependencies rather than performing searches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('Search for RubyGems matching a query string') and includes example queries that illustrate appropriate use cases. However, it doesn't explicitly state when NOT to use it or mention alternatives among the sibling tools, which would be needed for a score of 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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