Skip to main content
Glama

audit

Run security audits on npm packages to identify and fix vulnerabilities in dependencies, with options for automatic fixes and severity filtering.

Instructions

Run a security audit on the package

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the package directory
fixNoAutomatically fix vulnerabilities
levelNoMinimum vulnerability level to report
productionNoOnly audit production dependencies

Implementation Reference

  • Registration and handler implementation for the 'audit' MCP tool.
    // ── npm audit ──
    server.tool(
      "audit",
      "Run a security audit on the package",
      {
        path: z.string().describe("Absolute path to the package directory"),
        fix: z.boolean().optional().describe("Automatically fix vulnerabilities"),
        level: z
          .enum(["info", "low", "moderate", "high", "critical"])
          .optional()
          .describe("Minimum vulnerability level to report"),
        production: z.boolean().optional().describe("Only audit production dependencies"),
      },
      async ({ path, fix, level, production }) => {
        const args = fix ? ["audit", "fix"] : ["audit"];
        args.push("--json");
        if (level) args.push("--audit-level", level);
        if (production) args.push("--omit=dev");
        try {
          const { stdout } = await run(args, path);
          return { content: [{ type: "text", text: stdout }] };
        } catch (e: any) {
          // npm audit exits non-zero when vulnerabilities found
          return { content: [{ type: "text", text: e.stdout || e.stderr || e.message }] };
        }
      },
    );

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/mikusnuz/npm-mcp'

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