Skip to main content

Security scanner and protocol fuzzer for MCP (Model Context Protocol) servers. Found and reported vulnerabilities in official Anthropic and GitHub MCP implementations.

Project description

mcpsec

License: MIT Python 3.11+ PyPI Bugs Found Fuzz Cases Semgrep Rules

Security scanner and protocol fuzzer for MCP servers.

Most MCP security tools do static analysis. mcpsec connects to live servers and proves exploitation.

InstallationUsageScannersFuzzing


Why mcpsec?

MCP is the protocol connecting AI agents (Claude, Cursor, VS Code) to external tools. Every major AI company uses it. Its security is often overlooked.

  • 82% of MCP implementations have path traversal vulnerabilities
  • 67% are vulnerable to code injection
  • ~2,000 internet-exposed MCP servers found with zero authentication
  • Anthropic's own Git MCP server had 3 critical RCE vulnerabilities

mcpsec has been used to discover and report 5 vulnerabilities across Anthropic and GitHub MCP implementations, affecting Python, TypeScript, and Go SDK ecosystems.


Installation

pip install mcpsec

For AI-powered features:

pip install mcpsec[ai]

Usage

Runtime Scanning

# Scan via stdio
mcpsec scan --stdio "npx @modelcontextprotocol/server-filesystem /tmp"

# Scan via HTTP with auth
mcpsec scan --http http://localhost:8080/mcp -H "Authorization: Bearer TOKEN"

# Enumerate attack surface
mcpsec info --stdio "python my_server.py"

Protocol Fuzzing

# Standard fuzzing (150+ cases)
mcpsec fuzz --stdio "python my_server.py"

# High intensity (500+ cases)
mcpsec fuzz --stdio "python my_server.py" --intensity high

# Target specific attack class
mcpsec fuzz --stdio "python my_server.py" -g protocol_state_machine
mcpsec fuzz --stdio "python my_server.py" -g id_confusion

# AI-powered payload generation
mcpsec fuzz --stdio "python my_server.py" --ai

Static Analysis

# Local source
mcpsec audit --path ./my-mcp-server

# GitHub repository
mcpsec audit --github https://github.com/user/mcp-server

# With AI validation
mcpsec audit --github https://github.com/user/mcp-server --ai

Rogue Server (Client Testing)

# Test MCP clients for vulnerabilities
mcpsec rogue-server --port 9999 --attack all

Scanners

Scanner Description
prompt-injection Hidden instructions in tool descriptions
command-injection OS command injection with proof of exploitation
path-traversal File traversal with proof of exploitation
ssrf Server-Side Request Forgery to internal services
auth-audit Missing auth, dangerous tool combinations
description-prompt-injection LLM manipulation via descriptions
resource-ssrf SSRF via MCP resource URIs
capability-escalation Undeclared capability abuse

Fuzz Generators

Generator Description
malformed_json Invalid JSON structures
protocol_violation JSON-RPC spec violations
type_confusion Type mismatch attacks
unicode_attacks Encoding edge cases
injection_payloads SQLi, XSS, command injection
protocol_state_machine MCP state violations
id_confusion JSON-RPC ID edge cases

Semgrep Rules

49 MCP-specific rules:

  • Command injection (exec, spawn, child_process)
  • SQL injection (raw queries, ORM bypass)
  • Path traversal (path.join with unsanitized input)
  • Description injection (dynamic tool descriptions)
  • Resource URI issues (SSRF vectors)
  • Protocol handler vulnerabilities

Configuration

AI Provider Setup

mcpsec setup

Supports: OpenAI, Anthropic, Google, Groq, DeepSeek, Ollama

Output Formats

# JSON
mcpsec scan --stdio "server" --output results.json

# SARIF (CI/CD)
mcpsec fuzz --stdio "server" --output results.sarif

How It Works

┌─────────┐     MCP Protocol      ┌────────────┐
│ mcpsec  │ ◄──── JSON-RPC ────►  │   Target   │
│         │    (stdio / HTTP)     │   Server   │
└────┬────┘                       └────────────┘
     │
     ├── Connect & enumerate attack surface
     ├── Run static scanners
     ├── Generate dynamic payloads  
     ├── Execute fuzzing campaigns
     └── Report findings with evidence

Disclaimer

For authorized security testing only. Only scan servers you own or have permission to test.


License

MIT


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpsec-2.0.1.tar.gz (140.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpsec-2.0.1-py3-none-any.whl (170.1 kB view details)

Uploaded Python 3

File details

Details for the file mcpsec-2.0.1.tar.gz.

File metadata

  • Download URL: mcpsec-2.0.1.tar.gz
  • Upload date:
  • Size: 140.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for mcpsec-2.0.1.tar.gz
Algorithm Hash digest
SHA256 af6cc4fe87eecffe4689de4cdc494059b072543afefde701733d9e6b907c841e
MD5 6c69e6aaaa434f3f982842cfe73ae4dc
BLAKE2b-256 901b5e820f5825260b17f80450fd5bffe446149db04aaa8bd6717c22d319ddc9

See more details on using hashes here.

File details

Details for the file mcpsec-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: mcpsec-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 170.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for mcpsec-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f84b2bb2b18a00e7a704627eb73c826342d0038d60127d2eba5cd5fec5bb7b41
MD5 90daa2a73c511932ed0c038cd4bbbdb8
BLAKE2b-256 7a0331741b1544f79b8cd9c492956c375128dc9f0483d5699add003286a8010d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page