Skip to main content
Glama

Get Package Quality Metrics

get_package_quality

Analyze npm package quality metrics from npms.io to evaluate reliability and maintenance status before installation.

Instructions

Get quality metrics from npms.io

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
finalYes
qualityYes
popularityYes
maintenanceYes

Implementation Reference

  • The inline anonymous async handler function that implements the core logic of the get_package_quality tool. It fetches quality metrics from the npms.io API, validates the response using QualityMetricsSchema, computes formatted text output, and returns structured content with metrics.
    async ({ packageName }) => {
      try {
        const encodedPackageName = encodeURIComponent(packageName);
        const response = await fetch(
          `https://api.npms.io/v2/package/${encodedPackageName}`
        );
    
        if (!response.ok) {
          throw new Error(
            `Failed to fetch quality metrics: ${response.statusText}`
          );
        }
    
        const rawData = await response.json();
        const parseResult = QualityMetricsSchema.safeParse(rawData.score);
    
        if (!parseResult.success) {
          throw new Error(
            `Invalid quality metrics structure: ${parseResult.error.message}`
          );
        }
    
        const score = parseResult.data;
        const output = {
          name: packageName,
          final: score.final,
          quality: score.detail.quality,
          popularity: score.detail.popularity,
          maintenance: score.detail.maintenance,
        };
    
        const formattedText = `Package: ${packageName}\n\nQuality Metrics:\n  Overall Score: ${(
          score.final * 100
        ).toFixed(1)}%\n  Quality: ${(score.detail.quality * 100).toFixed(
          1
        )}%\n  Popularity: ${(score.detail.popularity * 100).toFixed(
          1
        )}%\n  Maintenance: ${(score.detail.maintenance * 100).toFixed(1)}%`;
    
        return {
          content: [
            {
              type: "text",
              text: formattedText,
            },
          ],
          structuredContent: output,
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error fetching quality metrics: ${
                error instanceof Error ? error.message : "Unknown error"
              }`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:920-998 (registration)
    The server.registerTool call that registers the get_package_quality tool, specifying its name, title, description, inputSchema (packageName: string), outputSchema (name, final, quality, popularity, maintenance scores), and references the handler function.
    server.registerTool(
      "get_package_quality",
      {
        title: "Get Package Quality Metrics",
        description: "Get quality metrics from npms.io",
        inputSchema: {
          packageName: z.string(),
        },
        outputSchema: {
          name: z.string(),
          final: z.number(),
          quality: z.number(),
          popularity: z.number(),
          maintenance: z.number(),
        },
      },
      async ({ packageName }) => {
        try {
          const encodedPackageName = encodeURIComponent(packageName);
          const response = await fetch(
            `https://api.npms.io/v2/package/${encodedPackageName}`
          );
    
          if (!response.ok) {
            throw new Error(
              `Failed to fetch quality metrics: ${response.statusText}`
            );
          }
    
          const rawData = await response.json();
          const parseResult = QualityMetricsSchema.safeParse(rawData.score);
    
          if (!parseResult.success) {
            throw new Error(
              `Invalid quality metrics structure: ${parseResult.error.message}`
            );
          }
    
          const score = parseResult.data;
          const output = {
            name: packageName,
            final: score.final,
            quality: score.detail.quality,
            popularity: score.detail.popularity,
            maintenance: score.detail.maintenance,
          };
    
          const formattedText = `Package: ${packageName}\n\nQuality Metrics:\n  Overall Score: ${(
            score.final * 100
          ).toFixed(1)}%\n  Quality: ${(score.detail.quality * 100).toFixed(
            1
          )}%\n  Popularity: ${(score.detail.popularity * 100).toFixed(
            1
          )}%\n  Maintenance: ${(score.detail.maintenance * 100).toFixed(1)}%`;
    
          return {
            content: [
              {
                type: "text",
                text: formattedText,
              },
            ],
            structuredContent: output,
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error fetching quality metrics: ${
                  error instanceof Error ? error.message : "Unknown error"
                }`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Zod schema definition for validating the 'score' object from npms.io API response, used in the handler's safeParse call.
    const QualityMetricsSchema = z.object({
      final: z.number(),
      detail: z.object({
        quality: z.number(),
        popularity: z.number(),
        maintenance: z.number(),
      }),
      analyzedAt: z.string().optional(),
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but lacks details on traits like rate limits, authentication needs, response format, or error handling. This is a significant gap for a tool with no annotation coverage.

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 with zero waste. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

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 (one parameter) and the presence of an output schema, the description is somewhat complete. However, with no annotations and 0% schema coverage, it lacks behavioral context and parameter semantics, making it only minimally adequate.

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 description coverage is 0%, so the description must compensate for undocumented parameters. It implies the 'packageName' parameter is used to fetch metrics but doesn't add meaning beyond what the schema's property name suggests. With only one parameter, the baseline is 4, but the description fails to provide any semantic context, lowering the score.

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 ('Get') and resource ('quality metrics from npms.io'), making the purpose understandable. However, it doesn't specifically differentiate this tool from its siblings like 'get_package_info' or 'get_download_stats' that might also provide quality-related metrics, preventing a perfect score.

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. With siblings like 'get_package_info' that might include quality metrics, there's no indication of what makes this tool unique or when it should be preferred, leaving usage unclear.

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/JuanSebastianGB/npm-context-agent-mcp'

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