🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

mcpaudit

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mcpaudit

Security scanner for MCP servers — Python + TypeScript/JavaScript + Go, zero dependencies, 57+ rules, SBOM generation, remediation playbooks, regression detection, plugin system, live scanner, fleet scanning, policy engine, OWASP Agentic Top 10

pipPyPI
Version
2.1.0
Weekly downloads
26
Maintainers
1
███╗   ███╗ ██████╗██████╗      █████╗ ██╗   ██╗██████╗ ██╗████████╗
████╗ ████║██╔════╝██╔══██╗    ██╔══██╗██║   ██║██╔══██╗██║╚══██╔══╝
██╔████╔██║██║     ██████╔╝    ███████║██║   ██║██║  ██║██║   ██║
██║╚██╔╝██║██║     ██╔═══╝     ██╔══██║██║   ██║██║  ██║██║   ██║
██║ ╚═╝ ██║╚██████╗██║         ██║  ██║╚██████╔╝██████╔╝██║   ██║
╚═╝     ╚═╝ ╚═════╝╚═╝         ╚═╝  ╚═╝ ╚═════╝ ╚═════╝ ╚═╝   ╚═╝
        Security Scanner for MCP Servers — Zero Dependencies

python 3.10+  |  zero dependencies  |  MIT license  |  6430+ tests  |  v2.9.0

MCP servers are the bridge between LLMs and your system. If they have vulnerabilities, the AI can be manipulated to exploit them. mcpaudit finds those vulnerabilities before an attacker does.

How it works

  Your MCP Server Code
         |
         v
  +--------------+
  |   mcpaudit    |-->  AST parsing (no execution)
  |   scanner     |-->  72+ security rules
  |               |-->  CWE mapping + Trust Score
  +------+-------+
         |
    +----+----+----------+----------+
    v    v    v          v          v
  Text  JSON  HTML     SARIF    History
        (CI)  (report) (GitHub)  (trend)

Quick Start

pip install -e .

# Scan a file
mcpaudit server.py

# Scan a directory
mcpaudit /path/to/mcp-servers/

# HTML report
mcpaudit server.py --format html -o report.html

# SARIF for GitHub Code Scanning
mcpaudit server.py --format sarif -o results.sarif

Why mcpaudit?

AI-Infra-Guard (Tencent)mcpaudit
RequirementsDocker + 4GB RAM + LLM API keyPython 3.11+ (stdlib only)
SpeedMinutes (API calls)<200ms (static analysis)
Cost$$$ (LLM API)$0 (everything local)
DependenciesDocker, LLM SDKNone
LanguagesPython onlyPython + TypeScript + Go
CI/CDManualExit codes + JSON + SARIF

Features

FeatureCommandWhat it does
Static Scanmcpaudit scan FILEAST-based scanning (Python/TS/Go)
Fleet Scanmcpaudit scan-all DIRRecursive discovery + aggregate report
Fleet Reportmcpaudit scan-all --fleet-reportExecutive HTML with heatmap
Fingerprintmcpaudit fingerprint PATHDetect MCP framework + known vulns
Data Flowsmcpaudit flows FILEToxic source-to-sink analysis
Config Guardmcpaudit guard CONFIGClaude Code settings.json audit
Diff Scanmcpaudit diffCompare scans, find new/resolved
Live Scanmcpaudit live -- CMDRuntime probing (8 probes)
Watch Modemcpaudit scan --watchRe-scan on file change
Auto-Fixmcpaudit scan --fixAuto-remediation (5 rule types)
Policymcpaudit scan --policy FILEYAML policy enforcement
Compliancemcpaudit scan --compliance-reportOWASP Agentic Top 10 report
Trust Scoremcpaudit scan --min-score N0-100 score for CI/CD gates
Baselinemcpaudit --create-baselineSuppress known findings
Pluginsmcpaudit plugins listCustom rule loading
Rule Genmcpaudit generate --category30 rule templates from CVE/OWASP

Security Rules (72+)

Every finding includes a CWE reference and a confidence level (HIGH/MEDIUM/LOW).

RuleSeverityDetectsCWE
CMD-001CRITICALCommand injection (shell=True)CWE-78
CMD-002HIGHCommand injection (f-strings)CWE-78
SQL-001CRITICALSQL injection (string interpolation)CWE-89
SEC-001CRITICALHardcoded secrets (API keys, tokens)CWE-798
DESER-001CRITICALUnsafe deserialization (yaml.load)CWE-502
PATH-001HIGHPath traversal (unvalidated file ops)CWE-22
SSRF-001HIGHServer-Side Request ForgeryCWE-918
FILE-001HIGHUnsafe file write (dynamic path)CWE-73
PERM-001HIGHExcessive permissions (chmod 777)CWE-250
IDOR-001HIGHInsecure Direct Object ReferenceCWE-639
PRIV-001HIGHPrivilege escalation in toolsCWE-269
AUTH-001MEDIUMMissing authenticationCWE-306
AUTHZ-001MEDIUMMissing authorization in handlersCWE-862
CORS-001MEDIUMCORS wildcardCWE-942
VAL-001MEDIUMMissing input validation--
ERR-001MEDIUMMissing error handlingCWE-755
LOG-001MEDIUMSensitive data in logsCWE-532
RES-001MEDIUMResource exhaustionCWE-400
REDOS-001MEDIUMReDoS (nested quantifiers)--
MCP-003HIGHConfused deputy attack--
MCP-004MEDIUMPrompt injection vector--
MCP-006MEDIUMUnbounded tool response--
MCP-015HIGHUnauthenticated server--
MCP-016LOWMissing audit logging--
RATE-001LOWMissing rate limitingCWE-770
TEMP-001LOWInsecure temp filesCWE-377
INFO-001LOWInformation disclosure--

Grading and Trust Score

  Grade    Score    Meaning
  -----    -----    ----------------------
   A+        0      No findings
   A        1-2     Minor issues only
   B        3-5     Some medium issues
   C       6-10     High severity findings
   D      11-20     Multiple high severity
   F       21+      Critical issues present

  Trust Score: 0-100 (higher = more secure)
  Use --min-score N as CI/CD quality gate

Output Formats

Terminal (default)

============================================================
  MCP Security Audit -- Results
============================================================
  Files scanned: 1
  Lines scanned: 150
  Total findings: 3
============================================================

  [FILE] server.py
     Grade: C | 3 findings | 12.3ms

     [!!] [CMD-001] Command Injection (shell=True)
       Line 42: subprocess.run() with shell=True.
       Fix: Use argument list without shell=True.

     [!] [PATH-001] Potential Path Traversal
       Line 18: open() without path validation.
       Fix: Use path.resolve() and path.is_relative_to(base_dir).

     [-] [AUTH-001] Missing authentication
       Line 1: Server does not implement authentication.
============================================================
  Trust Score: 35/100 (LOW)

JSON, HTML, SARIF

mcpaudit server.py --format json            # CI/CD pipelines
mcpaudit server.py --format html -o r.html   # Visual dashboard
mcpaudit server.py --format sarif -o r.sarif # GitHub Code Scanning

CI/CD Integration

GitHub Actions

name: Security Scan
on: [push, pull_request]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - run: pip install -e path/to/mcpaudit
      - run: mcpaudit . --format sarif -o results.sarif
      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: results.sarif

Pre-commit Hook

cp hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

Baseline (only fail on NEW findings)

mcpaudit . --create-baseline .mcpaudit-baseline.json
mcpaudit . --baseline .mcpaudit-baseline.json

Exit Codes

CodeMeaning
0No HIGH or CRITICAL findings
1HIGH findings present
2CRITICAL findings present

Configuration

mcpaudit --init  # Generate .mcpaudit.yml
# .mcpaudit.yml
exclude_rules:
  - AUTH-001
  - RATE-001
exclude_paths:
  - "tests/*"
  - "vendor/*"
severity_threshold: medium
output_format: text

Custom Rules

from mcpaudit.rules import Rule
from mcpaudit.models import Finding, Severity

class MyRule(Rule):
    rule_id = "CUSTOM-001"
    name = "My Custom Check"
    severity = Severity.HIGH
    description = "Detects my custom pattern."

    def check(self, tree, source) -> list[Finding]:
        findings = []
        # Detection logic here
        return findings

from mcpaudit.scanner import MCPSecurityScanner
scanner = MCPSecurityScanner(rules=[MyRule()])

Architecture

mcpaudit/
+-- scanner.py            # Core Python scanning engine
+-- ts_scanner.py         # TypeScript/JavaScript scanner
+-- go_scanner.py         # Go scanner
+-- models.py             # Finding, ScanResult, Severity
+-- formatters.py         # Text + JSON formatters
+-- config.py             # .mcpaudit.yml loader
+-- rules/                # 27 Python security rules
+-- ts_rules/             # 15 TypeScript rules
+-- go_rules/             # 8 Go rules
+-- reporters/            # HTML + SARIF reporters
+-- flows.py              # Data flow analysis
+-- guard.py              # Config file auditing
+-- live.py               # Runtime MCP probing
+-- watcher.py            # File watch mode
+-- fixer.py              # Auto-remediation engine
+-- policy_engine.py      # YAML policy enforcement
+-- compliance.py         # OWASP Agentic Top 10
+-- trust_score.py        # 0-100 trust scoring
+-- baseline.py           # Finding suppression
+-- plugin_system.py      # External rule loading
+-- ...                   # 159 modules total
tests/
+-- ...                   # 6632 tests

Stats

MetricValue
Tests6632
Python rules27
TypeScript rules15
Go rules8
Source modules159
OWASP Agentic coverage10/10
CWE references20+
Output formats5 (text, JSON, HTML, SARIF, history)
CLI commands16
Dependencies0

License

MIT License.

Built by @cmiretf

Keywords

mcp

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts