Skip to main content

mcp-lint

CI Python 3.10+ License: MIT SARIF 2.1.0 Platform: Windows | macOS | Linux

A lightweight, zero-dependency static security and hygiene linter for Model Context Protocol (.mcp.json, .cursor/mcp.json, .vscode/mcp.json, and claude_desktop_config.json) configurations.

Quick Demo

image

Run mcp-lint against any MCP config (or run with no arguments to auto-discover local configs):

$ mcp-lint tests/fixtures/unsafe_mcp.json
tests/fixtures/unsafe_mcp.json: [MEDIUM] MCP002 (unsafe-fs): Unpinned package '@modelcontextprotocol/server-filesystem' via npx; pin a specific version.
tests/fixtures/unsafe_mcp.json: [CRITICAL] MCP003 (unsafe-fs): Possible hardcoded API token or secret detected in server config.
tests/fixtures/unsafe_mcp.json: [HIGH] MCP004 (unsafe-fs): Overly broad filesystem path '/' exposed to MCP server.
tests/fixtures/unsafe_mcp.json: [HIGH] MCP005 (unsafe-remote): Unencrypted remote endpoint 'http://example.com'; use https:// instead.
tests/fixtures/unsafe_mcp.json: [HIGH] MCP006 (injected-server): Suspicious prompt-injection or instruction-override phrase detected in config.
tests/fixtures/unsafe_mcp.json: [CRITICAL] MCP007 (injected-server): Privileged execution detected via 'sudo'; run MCP servers with least privilege.

Features

  • MCP001: Flags direct raw shell invocations (bash, sh, zsh, pwsh, powershell, cmd).
  • MCP002: Warns on unpinned npx and uvx package executions (including scoped packages without version pins).
  • MCP003: Detects hardcoded API keys and bearer tokens in env or args.
  • MCP004: Flags overly broad filesystem mounts (/, C:\, ~, /Users, /home, C:\Users).
  • MCP005: Flags unencrypted remote http:// MCP URLs (excluding localhost / 127.0.0.1) and disabled TLS verification flags.
  • MCP006: Detects suspicious prompt-injection or instruction-override phrases in server descriptions, arguments, or environment variables.
  • MCP007: Flags privileged or root-level command execution (sudo, runas, docker run --privileged).
  • Auto-Discovery: Automatically finds and scans local project and user MCP configuration files when run with no arguments.
  • SARIF 2.1.0 Output: Exports findings in SARIF format (--format sarif) for native GitHub Code Scanning and PR annotations.
  • Pre-commit Support: Ships with .pre-commit-hooks.yaml to catch insecure MCP configs before they are committed.

Cross-Platform Support

mcp-lint runs natively on Windows, macOS, and Linux with zero external dependencies:

  • Windows-Aware Paths & Shells: Flags Windows root mounts (C:\, C:\Users), privileged runas usage, and raw pwsh / powershell / cmd invocations.
  • Auto-Discovery Across OSes: Automatically locates %APPDATA%\Claude\claude_desktop_config.json on Windows, ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, and ~/.config/Claude/claude_desktop_config.json on Linux.
  • UTF-8 BOM Resilient: Cleanly parses JSON files saved with a UTF-8 Byte Order Mark by PowerShell or Windows editors.

Installation

# Run directly without installing
uvx --from mcp-guard-lint mcp-lint

# Or install via pip
pip install mcp-guard-lint

Usage

# Auto-discover project and user MCP configs (.mcp.json, .cursor/mcp.json, .vscode/mcp.json, Claude Desktop)
mcp-lint

# Auto-discover only configs inside the current project directory
mcp-lint --no-user-configs

# Scan one or more specific configuration files
mcp-lint path/to/.mcp.json .cursor/mcp.json

# Export SARIF 2.1.0 output for GitHub Code Scanning
mcp-lint --format sarif --output mcp-lint.sarif

# Scan Claude Desktop's config on Windows PowerShell
mcp-lint "$env:APPDATA\Claude\claude_desktop_config.json"

Example Output

.mcp.json: [CRITICAL] MCP003 (unsafe-fs): Possible hardcoded API token or secret detected in server config.
.mcp.json: [MEDIUM] MCP002 (unsafe-fs): Unpinned package '@modelcontextprotocol/server-filesystem' via npx; pin a specific version.
.mcp.json: [HIGH] MCP004 (unsafe-fs): Overly broad filesystem path '/' exposed to MCP server.

GitHub Actions Code Scanning (SARIF)

Add a workflow (e.g., .github/workflows/mcp-security.yml) to surface MCP security findings directly in your repository's Security  Code scanning tab:

name: MCP Config Security Scan
on: [push, pull_request]

jobs:
  mcp-lint:
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      contents: read
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install mcp-guard-lint
        id: lint
      - run: mcp-lint --no-user-configs --format sarif --output mcp-lint.sarif
        continue-on-error: true
      - uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: mcp-lint.sarif
      - name: Fail if findings detected
        if: steps.lint.outcome == 'failure'
        run: exit 1

Pre-commit Hook

Add mcp-lint to your .pre-commit-config.yaml to block unpinned packages, broad mounts, or hardcoded secrets before they are committed:

repos:
  - repo: https://github.com/Staggerlee60/mcp-lint
    rev: v0.3.1
    hooks:
      - id: mcp-lint

Running Tests

pytest -v

License

MIT

Metadata

Release files for mcp-guard-lint 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-guard-lint 0.3.1
File Size Uploaded Provenance Actions
mcp_guard_lint-0.3.1.tar.gz 8.9 kB With provenance Details for mcp_guard_lint-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-guard-lint 0.3.1
File Interpreter ABI Platform Actions
mcp_guard_lint-0.3.1-py3-none-any.whl Python 3 none any Details for mcp_guard_lint-0.3.1-py3-none-any.whl

Total release size: 18.9 kB

Release files / mcp_guard_lint-0.3.1.tar.gz

Download URL mcp_guard_lint-0.3.1.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0b402653094b24ae78d9d6f6058dff279e74f615895391d9316b3fd33a1dd5f3
BLAKE2b-256 checksum
How to use checksums
4dcb5a3cc95f90b10bb3cd6295f39b814c73e0d2771cc7f34183adfedc38bf02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / mcp_guard_lint-0.3.1-py3-none-any.whl

Download URL mcp_guard_lint-0.3.1-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de463c9b4ca3fb868e126a1e72ceabdb3e2e543e2b71002412f0629c9e0fed8e
BLAKE2b-256 checksum
How to use checksums
2113156d995c0b6e6b3505091c5898d4df8ce2cc2678be1b6e115f85552797d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for mcp-guard-lint 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcp_guard_lint-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page