| Crates.io | mcpsec |
| lib.rs | mcpsec |
| version | 0.3.0 |
| created_at | 2025-07-19 16:28:55.383142+00 |
| updated_at | 2025-07-19 20:30:37.905034+00 |
| description | Security scanner for Model Context Protocol (MCP) servers |
| homepage | https://github.com/augmnt/mcpsec |
| repository | https://github.com/augmnt/mcpsec |
| max_upload_size | |
| id | 1760371 |
| size | 302,517 |
🔍 Find security vulnerabilities in Model Context Protocol (MCP) servers before they find you.
cargo install mcpsec
Requirements:
# Launch interactive interface
mcpsec tui
# Launch with target pre-selected
mcpsec tui ./my-mcp-server
# Scan local MCP server
mcpsec scan ./my-mcp-server
# Scan GitHub repository
mcpsec scan https://github.com/user/mcp-server
# Get JSON output for CI/CD
mcpsec scan ./server --output json --fail-below 70
mcpsec currently supports MCP servers built with:
| SDK | Language | Status | MCP-Specific Rules |
|---|---|---|---|
| FastMCP | Python | ✅ Fully Supported | ✅ 5 specialized rules |
| @modelcontextprotocol/sdk | TypeScript/JavaScript | ✅ Fully Supported | ✅ 5 specialized rules |
| Other SDKs | C#, Java, Kotlin, Ruby, Rust, Swift | ❌ Limited Support | ⚠️ Generic rules only |
Note: For unsupported SDKs, mcpsec will still detect generic security issues (command injection, file operations, etc.) but may miss MCP-specific vulnerability patterns.
mcpsec detects these vulnerability categories:
Detected in Python FastMCP and TypeScript/JavaScript MCP SDK servers
| Category | Examples | Severity |
|---|---|---|
| MCP Tool Injection | subprocess.run(user_cmd, shell=True) in tools |
🔴 Critical |
| MCP Resource Traversal | open(../../../etc/passwd) in resources |
🟠 High |
| MCP Prompt Injection | "Ignore previous instructions" in descriptions | 🟠 High |
| MCP Input Validation | Missing validation in tool parameters | 🟡 Medium |
| MCP Auth Bypass | DISABLE_AUTH=true, hardcoded credentials |
🟠 High |
Detected in all supported languages
| Category | Examples | Severity |
|---|---|---|
| Command Injection | exec(userInput), system(command) |
🔴 Critical |
| Network Exposure | Binding to 0.0.0.0 without auth |
🟠 High |
| Input Validation | Unsafe file operations | 🟡 Medium |
┌─ Security Assessment ────────────────────────────────┐
│ Overall Score: 15/100 (CRITICAL) │
│ │
│ 🔴 3 Critical Issues │
│ 🟠 2 High Issues │
│ 🟡 1 Medium Issue │
│ │
│ ❌ DO NOT USE - Fix critical issues first │
└─────────────────────────────────────────────────────┘
🔴 CRITICAL: MCP Tool Command Injection in server.ts:52
MCP tool 'execute-command' uses unsafe execSync() with user input
Fix: Use subprocess with shell=False and validated arguments
Ref: CWE-78, OWASP Command Injection
🟠 HIGH: MCP Resource Path Traversal in server.py:67
Resource allows ../../../etc/passwd access via path parameter
Fix: Validate paths with Path.resolve() and allowlists
Ref: CWE-22, Path Traversal
🟠 HIGH: MCP Auth Bypass in config.ts:12
DISABLE_AUTH=true exposes server without authentication
Fix: Remove auth bypass flags and implement proper authentication
Ref: CWE-306, Missing Authentication
The interactive TUI provides:
q or Esc - Quit/Go back? or F1 - Toggle help↑↓ or j/k - Navigate listsEnter - Select/ConfirmTab - Switch focuss - Start scanr - Browse rules/Rescanmcpsec tui # Launch TUI interface
mcpsec tui ./my-mcp-server # Launch with target selected
mcpsec scan ./my-mcp-server # Basic scan with table output
mcpsec scan ./server --output json # JSON output for CI/CD
mcpsec scan ./server --fail-below 80 # Exit with error if score < 80
mcpsec rules list # Show all available rules
mcpsec rules info mcp-tool-injection-001 # Rule details
mcpsec doctor # System health check
mcpsec --version # Show version
mcpsec --help # Show help
mcpsec --help for full command referencemcpsec rules list to see all available rulesWe welcome contributions! Please see:
git clone https://github.com/augmnt/mcpsec
cd mcpsec
cargo build
cargo test
cargo run -- scan examples/vulnerable-mcp-typescript
# Test with Python FastMCP example
cargo run -- scan examples/vulnerable-mcp-python
Want to contribute? See CONTRIBUTING.md for guidance on adding language support.
| Score Range | Risk Level | Recommendation |
|---|---|---|
| 0-19 | CRITICAL | ❌ Do not use |
| 20-39 | HIGH | 🔴 High risk - fix issues first |
| 40-69 | MEDIUM | 🟠 Use with caution |
| 70-89 | LOW | ⚠️ Review issues before use |
| 90-100 | SAFE | ✅ Safe to use |
Licensed under the MIT License.