Skip to main content
Glama

security

Audit MCP server configurations to identify hardcoded secrets, tokens in arguments, and shell injection patterns.

Instructions

Audit all MCP server configs for security issues like hardcoded secrets, tokens in args, and shell injection patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function `checkSecurity` that implements the security checking logic. It iterates over all MCP servers and checks for: hardcoded secrets in env vars (high/medium severity), shell operators in commands (medium severity), missing arguments for npx/node (low severity), and unencrypted HTTP URLs (high severity).
    export function checkSecurity(servers: McpServer[]): SecurityIssue[] {
      const issues: SecurityIssue[] = [];
    
      for (const server of servers) {
        if (server.env) {
          for (const [key, value] of Object.entries(server.env)) {
            const isSensitiveName = SECRET_PATTERNS.some((p) => p.test(key));
    
            if (isSensitiveName && value && !value.startsWith("${") && !value.startsWith("$")) {
              const isHardcoded = HARDCODED_SECRET_PATTERNS.some((p) => p.test(value));
    
              if (isHardcoded) {
                issues.push({
                  server,
                  severity: "high",
                  message: `Hardcoded secret in env var "${key}"`,
                  detail: `Value matches known API key pattern. Use environment variables or a secrets manager instead of hardcoding in config.`,
                });
              } else if (value.length > 10) {
                issues.push({
                  server,
                  severity: "medium",
                  message: `Possible hardcoded secret in "${key}"`,
                  detail: `Env var name suggests a secret and value appears hardcoded. Consider using $ENV_VAR references.`,
                });
              }
            }
          }
        }
    
        if (server.command) {
          if (server.command.includes("&&") || server.command.includes("|") || server.command.includes(";")) {
            issues.push({
              server,
              severity: "medium",
              message: "Command contains shell operators",
              detail: `Command "${server.command}" uses shell operators which could be a security risk.`,
            });
          }
        }
    
        if (server.type === "stdio" && server.command && (!server.args || server.args.length === 0)) {
          if (server.command === "npx" || server.command === "node") {
            issues.push({
              server,
              severity: "low",
              message: "Command has no arguments",
              detail: `"${server.command}" is called without arguments — likely misconfigured.`,
            });
          }
        }
    
        if (server.url && server.url.startsWith("http://")) {
          issues.push({
            server,
            severity: "high",
            message: "SSE server using unencrypted HTTP",
            detail: `URL "${server.url}" uses HTTP instead of HTTPS. Data is transmitted in plaintext.`,
          });
        }
      }
    
      return issues;
    }
  • src/index.ts:48-66 (registration)
    The 'security' command is registered as a CLI subcommand using Commander.js. It calls `checkSecurity(servers)` and either prints via `printSecurityIssues` or outputs JSON.
    program
      .command("security")
      .description("Check MCP configs for security issues")
      .option("--json", "Output results as JSON")
      .action(async (opts) => {
        const servers = await discoverServers(opts.json);
        if (servers.length === 0) return;
    
        if (!opts.json) {
          const secSpinner = ora("Running security checks...").start();
          var issues = checkSecurity(servers);
          secSpinner.succeed("Security scan complete");
          console.log();
          printSecurityIssues(issues);
        } else {
          const issues = checkSecurity(servers);
          console.log(JSON.stringify(issues.map(formatSecurityIssue), null, 2));
        }
      });
  • The `SecurityIssue` interface defines the shape of security issues: server reference, severity level (high/medium/low), message, and detail.
    export interface SecurityIssue {
      server: McpServer;
      severity: "high" | "medium" | "low";
      message: string;
      detail: string;
    }
  • The `McpServer` interface used by the security handler, containing server fields like type, command, args, url, and env.
    export interface McpServer {
      name: string;
      source: string;       // e.g. "Claude Code (~/.claude.json)"
      configPath: string;   // full path to the config file
      type: "stdio" | "sse" | "unknown";
      command?: string;
      args?: string[];
      url?: string;
      env?: Record<string, string>;
    }
  • The `printSecurityIssues` helper function that displays security issues in a formatted table to the console.
    export function printSecurityIssues(issues: SecurityIssue[]): void {
      if (issues.length === 0) {
        console.log(chalk.green("  ✓ No security issues found.\n"));
        return;
      }
    
      const table = new Table({
        head: [
          chalk.white("Severity"),
          chalk.white("Server"),
          chalk.white("Issue"),
        ],
        style: { head: [], border: ["dim"] },
        colWidths: [12, 20, 60],
        wordWrap: true,
      });
    
      for (const issue of issues) {
        const sev =
          issue.severity === "high"
            ? chalk.red("HIGH")
            : issue.severity === "medium"
              ? chalk.yellow("MEDIUM")
              : chalk.dim("LOW");
    
        table.push([sev, chalk.cyan(issue.server.name), `${issue.message}\n${chalk.dim(issue.detail)}`]);
      }
    
      console.log(table.toString());
      console.log(
        `\n  Found ${chalk.yellow(String(issues.length))} issue(s)\n`
      );
    }
Behavior3/5

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

The description discloses what issues the tool checks for (hardcoded secrets, tokens, shell injection), which is helpful. However, with no annotations, it does not explicitly state whether the tool is read-only or has side effects, nor does it mention authorization requirements or output format.

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, well-structured sentence of 16 words that front-loads the purpose with a strong verb ('Audit') and provides concrete examples. No wasted words.

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 parameterless audit tool, the description is fairly complete: it states the target (MCP server configs), the action (audit), and examples of issues. However, it does not describe the output format or how results are presented, which would be beneficial but not critical given the tool's simplicity.

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?

The input schema has zero parameters and 100% coverage, so the schema fully documents the lack of parameters. The description adds no param info, which is acceptable; baseline for 0 params is 4.

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's purpose: auditing MCP server configs for security issues like hardcoded secrets, tokens in args, and shell injection patterns. This is specific and distinguishes it from sibling tools (bench, doctor, scan) which likely cover performance, health, and other scans.

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?

The description implies usage for security auditing but provides no explicit guidance on when to use this tool versus alternatives, nor any conditions or prerequisites. The context is clear but lacks exclusions or comparison.

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/realwigu/mcp-doctor'

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