Skip to main content
Glama

Named Package Comparison

compare_competitors
Read-onlyIdempotent

Compare known npm or PyPI packages side by side using live metadata to verify claims about release dates, maintenance activity, and license types. Use when you already have candidate packages and need evidence.

Instructions

Compare two or more exact package names side by side using live npm or PyPI metadata. Use this when you already know the candidate packages and need evidence for claims such as 'tool A is newer', 'tool B is still maintained', or 'these packages use different licenses'. Do not use it to discover unknown alternatives; use estimate_market for category search and market sizing instead. Registry responses are cached for 5 minutes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packagesYesTwo to ten exact package names from the same registry, for example ['react', 'vue'].
registryNoRegistry that all package names belong to. All compared packages must come from the same registry.npm

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
packagesYesPackage names that were requested for comparison.
registryYesRegistry used for all comparisons.
comparisonsYesPer-package lookup results returned in the same order as the input package list.

Implementation Reference

  • src/index.ts:849-970 (registration)
    Registration of the compare_competitors tool via this.server.registerTool with inputSchema, outputSchema, and the handler function.
    this.server.registerTool(
      "compare_competitors",
      {
        title: "Named Package Comparison",
        description:
          "Compare two or more exact package names side by side using live npm or " +
          "PyPI metadata. Use this when you already know the candidate packages and " +
          "need evidence for claims such as 'tool A is newer', 'tool B is still " +
          "maintained', or 'these packages use different licenses'. It returns " +
          "per-package registry metadata in input order, with field availability " +
          "varying by registry. Missing or unpublished packages return found=false. " +
          "Do not use it to discover unknown alternatives, estimate market size, " +
          "or compare packages across different registries. Registry responses are " +
          "cached for 5 minutes.",
        inputSchema: {
          packages: z.array(z.string().trim().min(1)).min(2).max(10).describe(
            "Two to ten exact package names from the same registry, for example ['react', 'vue']. Use exact registry names, not search phrases or categories.",
          ),
          registry: z.enum(["npm", "pypi"]).default("npm").describe(
            "Registry that all package names belong to. All compared packages must come from the same registry, and returned metadata fields differ slightly between npm and PyPI.",
          ),
        },
        outputSchema: {
          packages: z.array(z.string()).describe(
            "Package names that were requested for comparison.",
          ),
          registry: z.enum(["npm", "pypi"]).describe(
            "Registry used for all comparisons.",
          ),
          comparisons: z.array(z.object({
            name: z.string().describe(
              "Package name that was looked up.",
            ),
            found: z.boolean().describe(
              "True when the registry lookup succeeded and returned package metadata.",
            ),
            description: z.string().describe(
              "Short package summary from the registry.",
            ).optional(),
            latestVersion: z.string().describe(
              "Latest package version known to the registry.",
            ).optional(),
            license: z.union([z.string(), z.null()]).describe(
              "Package license metadata when provided by the registry.",
            ).optional(),
            lastPublished: z.union([z.string(), z.null()]).describe(
              "Publish timestamp of the latest version when npm provides one.",
            ).optional(),
            created: z.union([z.string(), z.null()]).describe(
              "Package creation timestamp when npm provides one.",
            ).optional(),
            totalVersions: z.number().int().nonnegative().describe(
              "Number of published versions when npm metadata includes a version history.",
            ).optional(),
            author: z.string().describe(
              "Package author when PyPI metadata includes one.",
            ).optional(),
            keywords: z.array(z.string()).describe(
              "Registry keywords or tags associated with the package.",
            ).optional(),
            cached: z.boolean().describe(
              "True when the lookup came from the 5-minute cache.",
            ).optional(),
            error: z.string().describe(
              "Fetch error when registry metadata could not be retrieved for this package.",
            ).optional(),
          })).describe(
            "Per-package lookup results returned in the same order as the input package list. Some fields only exist for npm or only for PyPI, so consumers should treat absent fields as normal.",
          ),
        },
        annotations: readOnlyNetworkToolAnnotations,
      },
      async ({ packages, registry }) => {
        const comparisons = [];
        for (const pkg of packages) {
          if (registry === "npm") {
            const url = `https://registry.npmjs.org/${encodeURIComponent(pkg)}`;
            try {
              const { body, fromCache } = await cachedFetch(sql, url);
              const data = JSON.parse(body);
              const latest = data["dist-tags"]?.latest;
              const time = data.time || {};
              comparisons.push({
                name: pkg,
                found: true,
                description: (data.description || "").slice(0, 150),
                latestVersion: latest,
                license: data.license,
                lastPublished: time[latest] || null,
                created: time.created || null,
                totalVersions: Object.keys(data.versions || {}).length,
                keywords: (data.keywords || []).slice(0, 10),
                cached: fromCache,
              });
            } catch {
              comparisons.push({ name: pkg, found: false, error: "fetch failed" });
            }
          } else if (registry === "pypi") {
            const url = `https://pypi.org/pypi/${encodeURIComponent(pkg)}/json`;
            try {
              const { body, fromCache } = await cachedFetch(sql, url);
              const data = JSON.parse(body);
              const info = data.info || {};
              comparisons.push({
                name: pkg,
                found: true,
                description: (info.summary || "").slice(0, 150),
                latestVersion: info.version,
                license: info.license,
                author: info.author,
                keywords: info.keywords?.split(",").map((k: string) => k.trim()).slice(0, 10) || [],
                cached: fromCache,
              });
            } catch {
              comparisons.push({ name: pkg, found: false, error: "fetch failed" });
            }
          }
        }
        logUsage("compare_competitors", true);
        return structuredToolResult({ packages, registry, comparisons });
      }
    );
  • Handler function for compare_competitors. Accepts packages (array of 2-10 strings) and registry ('npm' | 'pypi'), fetches metadata from npm registry API or PyPI JSON API for each package, and returns per-package comparison data (description, latestVersion, license, lastPublished, created, totalVersions, author, keywords, cached status).
      async ({ packages, registry }) => {
        const comparisons = [];
        for (const pkg of packages) {
          if (registry === "npm") {
            const url = `https://registry.npmjs.org/${encodeURIComponent(pkg)}`;
            try {
              const { body, fromCache } = await cachedFetch(sql, url);
              const data = JSON.parse(body);
              const latest = data["dist-tags"]?.latest;
              const time = data.time || {};
              comparisons.push({
                name: pkg,
                found: true,
                description: (data.description || "").slice(0, 150),
                latestVersion: latest,
                license: data.license,
                lastPublished: time[latest] || null,
                created: time.created || null,
                totalVersions: Object.keys(data.versions || {}).length,
                keywords: (data.keywords || []).slice(0, 10),
                cached: fromCache,
              });
            } catch {
              comparisons.push({ name: pkg, found: false, error: "fetch failed" });
            }
          } else if (registry === "pypi") {
            const url = `https://pypi.org/pypi/${encodeURIComponent(pkg)}/json`;
            try {
              const { body, fromCache } = await cachedFetch(sql, url);
              const data = JSON.parse(body);
              const info = data.info || {};
              comparisons.push({
                name: pkg,
                found: true,
                description: (info.summary || "").slice(0, 150),
                latestVersion: info.version,
                license: info.license,
                author: info.author,
                keywords: info.keywords?.split(",").map((k: string) => k.trim()).slice(0, 10) || [],
                cached: fromCache,
              });
            } catch {
              comparisons.push({ name: pkg, found: false, error: "fetch failed" });
            }
          }
        }
        logUsage("compare_competitors", true);
        return structuredToolResult({ packages, registry, comparisons });
      }
    );
  • Input/output Zod schemas for compare_competitors: input expects packages (2-10 strings) and registry ('npm'|'pypi'), output returns packages array, registry, and comparisons array with per-package metadata fields.
    inputSchema: {
      packages: z.array(z.string().trim().min(1)).min(2).max(10).describe(
        "Two to ten exact package names from the same registry, for example ['react', 'vue']. Use exact registry names, not search phrases or categories.",
      ),
      registry: z.enum(["npm", "pypi"]).default("npm").describe(
        "Registry that all package names belong to. All compared packages must come from the same registry, and returned metadata fields differ slightly between npm and PyPI.",
      ),
    },
    outputSchema: {
      packages: z.array(z.string()).describe(
        "Package names that were requested for comparison.",
      ),
      registry: z.enum(["npm", "pypi"]).describe(
        "Registry used for all comparisons.",
      ),
      comparisons: z.array(z.object({
        name: z.string().describe(
          "Package name that was looked up.",
        ),
        found: z.boolean().describe(
          "True when the registry lookup succeeded and returned package metadata.",
        ),
        description: z.string().describe(
          "Short package summary from the registry.",
        ).optional(),
        latestVersion: z.string().describe(
          "Latest package version known to the registry.",
        ).optional(),
        license: z.union([z.string(), z.null()]).describe(
          "Package license metadata when provided by the registry.",
        ).optional(),
        lastPublished: z.union([z.string(), z.null()]).describe(
          "Publish timestamp of the latest version when npm provides one.",
        ).optional(),
        created: z.union([z.string(), z.null()]).describe(
          "Package creation timestamp when npm provides one.",
        ).optional(),
        totalVersions: z.number().int().nonnegative().describe(
          "Number of published versions when npm metadata includes a version history.",
        ).optional(),
        author: z.string().describe(
          "Package author when PyPI metadata includes one.",
        ).optional(),
        keywords: z.array(z.string()).describe(
          "Registry keywords or tags associated with the package.",
        ).optional(),
        cached: z.boolean().describe(
          "True when the lookup came from the 5-minute cache.",
        ).optional(),
        error: z.string().describe(
          "Fetch error when registry metadata could not be retrieved for this package.",
        ).optional(),
      })).describe(
        "Per-package lookup results returned in the same order as the input package list. Some fields only exist for npm or only for PyPI, so consumers should treat absent fields as normal.",
      ),
    },
    annotations: readOnlyNetworkToolAnnotations,
Behavior4/5

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

Annotations already declare the tool is read-only, idempotent, and not destructive. The description adds that registry responses are cached for 5 minutes, which is useful behavioral context beyond annotations.

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 extremely concise with two informative sentences and a caching note. It is front-loaded with the core purpose and avoids redundancy.

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

Completeness5/5

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

Given the tool's moderate complexity and the presence of an output schema, the description adequately covers purpose, usage boundaries, and caching behavior, leaving no gaps.

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?

Schema coverage is 100%, so parameters are already well-documented. The description does not add significant semantic meaning beyond what the schema provides, meeting the baseline.

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 tool compares exact package names using live npm or PyPI metadata, with a specific verb and resource. It also distinguishes from the sibling tool estimate_market, ensuring clarity.

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

Usage Guidelines5/5

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

The description explicitly states when to use (to get evidence for claims about known packages) and when not to use (for discovery, directing to estimate_market instead), providing clear guidance.

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/anish632/ground-truth-mcp'

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