Skip to main content
Glama
nahmanmate

Code Research MCP Server

by nahmanmate

search_pypi

Search PyPI for Python packages to find code examples and documentation, helping developers locate programming resources.

Instructions

Search PyPI for Python packages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query

Implementation Reference

  • The core handler function for the 'search_pypi' tool. It queries the PyPI JSON API for the exact package name provided in the query parameter, caches the result, and formats package information. Handles 404 by returning a 'not found' message.
    private async searchPyPI(query: string, limit: number = 5): Promise<string> {
      const cacheKey = `pypi:${query}:${limit}`;
      const cached = cache.get<string>(cacheKey);
      if (cached) return cached;
    
      try {
        const response = await this.axiosInstance.get(
          `https://pypi.org/pypi/${encodeURIComponent(query)}/json`
        );
    
        const pkg = response.data.info;
        const result = `Package: ${pkg.name} (v${pkg.version})\n` +
                      `Description: ${pkg.summary || 'No description'}\n` +
                      `Author: ${pkg.author || 'Unknown'}\n` +
                      `Homepage: ${pkg.home_page || pkg.project_url || 'N/A'}\n` +
                      `PyPI: https://pypi.org/project/${pkg.name}/\n`;
    
        cache.set(cacheKey, result);
        return result;
      } catch (error) {
        if (axios.isAxiosError(error) && error.response?.status === 404) {
          return `No package found for "${query}"`;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `PyPI API error: ${error instanceof Error ? error.message : 'Unknown error'}`
        );
      }
    }
  • The input schema defining the expected parameters for the search_pypi tool: a required 'query' string.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'Search query'
        }
      },
      required: ['query']
    }
  • src/index.ts:398-411 (registration)
    Registration of the 'search_pypi' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'search_pypi',
      description: 'Search PyPI for Python packages',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query'
          }
        },
        required: ['query']
      }
    },
  • src/index.ts:493-504 (registration)
    The dispatch logic in CallToolRequestSchema handler that routes 'search_pypi' calls to the searchPyPI method and formats the response.
    case 'search_pypi': {
      const { query } = request.params.arguments as { query: string };
      const results = await this.searchPyPI(query);
      return {
        content: [
          {
            type: 'text',
            text: results
          }
        ]
      };
    }
Behavior2/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. While 'Search' implies a read-only operation, it doesn't specify whether this requires authentication, rate limits, pagination behavior, or what the response format looks like. For a search tool with zero annotation coverage, this leaves significant behavioral gaps.

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 a single, efficient sentence that states exactly what the tool does without any unnecessary words. It's appropriately sized and front-loaded with the core functionality, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is minimally adequate but lacks important context. It doesn't explain what the search returns (packages, versions, metadata), how results are formatted, or any limitations. While the schema covers the parameter, the absence of output information and behavioral details makes this incomplete for optimal agent use.

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

Parameters3/5

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

The input schema has 100% description coverage, with the single 'query' parameter documented as 'Search query.' The description doesn't add any additional meaning about parameter usage, syntax, or examples beyond what the schema provides. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no parameter information in the description.

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

Purpose4/5

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

The description clearly states the action ('Search') and target resource ('PyPI for Python packages'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its sibling search tools (search_github, search_npm, etc.) beyond specifying the PyPI platform, which is why it doesn't reach a perfect score of 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like search_all, search_github, or search_npm. It doesn't mention any specific contexts, prerequisites, or exclusions for using this PyPI-specific search tool, leaving the agent without usage direction.

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

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/nahmanmate/code-research-mcp-server'

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