Skip to main content
Glama

check_downloads

Retrieve the weekly download count for any npm or PyPI package by providing its name and registry.

Instructions

Check the weekly download count of a package on npm or PyPI.

Args: package_name: The package name — e.g. "react", "express", "flask", "requests" registry: "npm" or "pypi" (defaults to "npm")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
package_nameYes
registryNonpm

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual tool handler function for 'check_downloads'. It calls _query_fact with registry, package_name, and field 'weekly_downloads'.
    @mcp.tool()
    async def check_downloads(package_name: str, registry: str = "npm") -> str:
        """Check the weekly download count of a package on npm or PyPI.
    
        Args:
            package_name: The package name — e.g. "react", "express", "flask", "requests"
            registry: "npm" or "pypi" (defaults to "npm")
        """
        return await _query_fact(registry, package_name, "weekly_downloads")
  • The @mcp.tool() decorator registers 'check_downloads' as an MCP tool on the FastMCP server instance.
    @mcp.tool()
  • The _query_fact helper function that check_downloads delegates to. It makes an HTTP GET request to the Grounded API and formats the response.
    async def _query_fact(source: str, entity: str, field: str) -> str:
        """Query the Grounded API and return a formatted result."""
        headers = {}
        if API_KEY:
            headers["X-API-Key"] = API_KEY
        async with httpx.AsyncClient() as client:
            resp = await client.get(
                f"{API_BASE}/v1/fact",
                params={"source": source, "entity": entity, "field": field},
                headers=headers,
                timeout=10.0,
            )
    
        if resp.status_code == 200:
            data = resp.json()
            return (
                f"Value: {data['value']}\n"
                f"Source: {data['source_url']}\n"
                f"Fetched at: {data['fetched_at']}\n"
                f"Hash: {data['raw_response_hash']}\n"
                f"Tier: {data['tier']} (TTL: {data['ttl_seconds']}s)"
            )
        elif resp.status_code == 404:
            detail = resp.json().get("detail", "Not found")
            return f"Not found: {detail}"
        else:
            return f"Error: HTTP {resp.status_code}"
Behavior3/5

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

No annotations provided, so description carries burden. It states it checks weekly download count, but does not disclose rate limits, caching behavior, or error handling. Adequate for a simple read operation but leaves some traits implicit.

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?

Description is concise with no fluff. Purpose stated upfront, parameter explanations follow immediately. Each sentence earns its place.

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 simple tool with few parameters and an output schema, description covers purpose and parameters well. Could mention that it returns weekly data, but output schema likely clarifies. Good enough.

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?

Schema description coverage is 0%, so description must compensate. It adds meaning with examples for package_name and clarifies registry values and default. Lacks validation details but adds significant value beyond schema.

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 it checks weekly download count for a package on npm or PyPI, with specific verb and resource. It distinguishes from siblings like check_package_version (checks version) or check_service_status (checks service status).

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

Usage Guidelines3/5

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

No explicit when-to-use or when-not-to-use guidance, but the examples and registry options imply usage for download statistics. Could be improved by mentioning alternatives like check_package_version for version info.

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/nghizas/grounded-mcp'

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