Scan MCP servers for vulnerabilities and security issues
A security scanner for MCP servers that detects credential leaks, tool poisoning, prompt injection, and protocol-level attacks.
Why it matters
Ensure your Model Context Protocol server implementations are secure by running comprehensive security scans that detect vulnerabilities and configuration issues before they become exploitable weaknesses.
Outcomes
What it gets done
Scan MCP server implementations for known vulnerabilities
Detect security misconfigurations in server setups
Identify potential attack vectors in MCP deployments
Generate structured security reports with findings
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/mcp-mcpwatch | bash Overview
MCPWatch
A security scanner for MCP servers that checks for hardcoded credentials, tool poisoning, prompt injection, protocol violations, and other MCP-specific vulnerabilities, scanning either a GitHub repo or a local project. Use it before adopting or shipping an MCP server, as an automated first pass against known MCP attack classes - paired with manual security review, not as a replacement for it.
What it does
MCP Watch is a security scanner purpose-built for Model Context Protocol (MCP) servers, checking implementations against 12 distinct vulnerability categories: credential detection (hardcoded API keys and insecure storage), tool poisoning (hidden malicious instructions in tool descriptions), parameter injection (magic parameters that extract sensitive AI context), prompt injection, tool mutation ("rug-pull" risk from dynamic tool changes), conversation exfiltration, ANSI/steganographic injection via escape sequences, MCP protocol violations, input-validation issues (command injection, SSRF, path traversal), server spoofing, toxic data-flow patterns, and excessive-permission or access-control problems. It can scan a remote MCP server directly from its GitHub repository URL or scan a local project directory, and reports findings with a severity level (low/medium/high/critical), category, exact file location, and the offending evidence snippet - for example flagging a hardcoded const apiKey = "sk-***REDACTED***" at a specific file and line.
When to use - and when NOT to
Use it before trusting a third-party or self-built MCP server: run it against a GitHub repo or local project to surface credential leaks, tool poisoning, and protocol-level attacks before that server is wired into an agent. Its own docs are explicit that it's a detection layer, not a complete security program - "this tool identifies potential security issues but should not be the only security measure" - so it should be paired with manual security review rather than treated as a pass/fail certification. Its scanner set is also meant to be extended rather than treated as fixed - contributors add a new checker by subclassing AbstractScanner and registering it in MCPScanner.ts, so teams with their own MCP-specific attack patterns aren't limited to the 12 shipped categories.
Inputs and outputs
Input is either a GitHub repository URL (mcp-watch scan <url>) or a local project path (mcp-watch scan-local <path>), filterable by minimum severity (--severity) or vulnerability category (--category). Output defaults to a console report (severity summary plus per-finding ID, severity, category, file location, and evidence) or structured JSON via --format json. The CLI exits 0 when no critical or high-severity vulnerabilities are found, and 1 both when critical or high findings exist and when the scan itself errors.
Integrations
Built from published security research: the VulnerableMCP Database, HiddenLayer's parameter-injection research, Invariant Labs' tool-poisoning and toxic-agent-flow findings, Trail of Bits' protocol-level and credential-storage research, and PromptHub's vulnerability-prevalence analysis (which found command injection in 43% of public MCP servers, SSRF via arbitrary URL fetching in 30%, and path traversal leaking files outside the intended directory in 22%). Ships as an npm package, a buildable TypeScript source tree, and a Docker image with a Docker Compose setup, with GitHub Actions running CI, daily security scans, and weekly dependency updates. MIT licensed.
npm install -g mcp-watch
Who it's for
Teams and security researchers auditing MCP servers - their own, or third-party servers before adoption - who want an automated first pass against known MCP-specific attack classes like tool poisoning, parameter injection, and protocol violations, rather than relying on generic static-analysis tools that don't understand the MCP protocol.
Source README
MCP Watch π
A comprehensive security scanner for Model Context Protocol (MCP) servers that detects vulnerabilities and security issues in your MCP implementations.
Features
- π Credential Detection - Finds hardcoded API keys, tokens, and insecure credential storage
- π§ͺ Tool Poisoning - Detects hidden malicious instructions in tool descriptions
- π― Parameter Injection - Identifies magic parameters that extract sensitive AI context
- π Prompt Injection - Scans for prompt manipulation and injection attacks
- π Tool Mutation - Detects dynamic tool changes and rug-pull risks
- π¬ Conversation Exfiltration - Finds triggers that steal conversation history
- π¨ ANSI Injection - Detects steganographic attacks using escape sequences
- π Protocol Violations - Identifies MCP protocol security violations
- π‘οΈ Input Validation - Finds command injection, SSRF, and path traversal issues
- π Server Spoofing - Detects servers impersonating popular services
- π Toxic Flows - Identifies dangerous data flow patterns
- π Permission Issues - Finds excessive permissions and access control problems
Quick Start π
Option 1: NPM Package (Recommended)
# Install globally
npm install -g mcp-watch
# Scan any GitHub MCP repository
mcp-watch scan https://github.com/user/mcp-server
# Scan your local MCP project
mcp-watch scan-local /path/to/your/mcp-project
Option 2: From GitHub Source
# Clone and use immediately
git clone https://github.com/kapilduraphe/mcp-watch.git
cd mcp-watch
npm install
npm run build
# Scan GitHub repos
npm run scan:github https://github.com/user/mcp-server
# Scan local projects
npm run scan:local /path/to/your/mcp-project
Option 3: Docker (No Installation)
# Scan without installing anything
docker run --rm mcp-watch scan https://github.com/user/mcp-server
docker run --rm -v $(pwd):/workspace mcp-watch scan-local /workspace
Installation
Global Installation
npm install -g mcp-watch
Local Installation
npm install mcp-watch
From Source
git clone https://github.com/kapilduraphe/mcp-watch.git
cd mcp-watch
npm install
npm run build
Docker Installation π³
Quick Start with Docker
# Build and run locally
docker build -t mcp-watch .
docker run --rm mcp-watch scan https://github.com/user/mcp-server
# Build from source
git clone https://github.com/kapilduraphe/mcp-watch.git
cd mcp-watch
docker build -t mcp-watch .
Docker Compose (Recommended for Production)
# Build and run with Docker Compose
docker compose build
docker compose up mcp-watch
# Or run a one-off scan
docker compose run --rm mcp-watch scan https://github.com/user/repo
Docker Features
- π Security: Non-root user, minimal attack surface
- π¦ Optimized: Multi-stage builds, Alpine Linux base
- π Production: Ready for deployment and CI/CD
- π§Ή Simplified: Single optimized Dockerfile for all use cases
Usage
Command Line
Scan GitHub Repositories
# Scan a GitHub repository
mcp-watch scan https://github.com/user/mcp-server
# Scan with JSON output
mcp-watch scan https://github.com/user/mcp-server --format json
# Filter by severity
mcp-watch scan https://github.com/user/mcp-server --severity high
# Filter by category
mcp-watch scan https://github.com/user/mcp-server --category credential-leak
Scan Local Projects
# Scan current directory
mcp-watch scan-local .
# Scan specific directory (absolute path)
mcp-watch scan-local /path/to/your/mcp-project
# Scan specific directory (relative path)
mcp-watch scan-local ../my-mcp-server
# Local scan with JSON output
mcp-watch scan-local . --format json
# Local scan with severity filter
mcp-watch scan-local . --severity high
Installation Method Usage
From NPM Package
# Global installation (recommended)
npm install -g mcp-watch
mcp-watch scan https://github.com/user/mcp-server
mcp-watch scan-local /path/to/project
From GitHub Source
# Clone and build
git clone https://github.com/kapilduraphe/mcp-watch.git
cd mcp-watch
npm install
npm run build
# Use built version
node dist/main.js scan https://github.com/user/mcp-server
node dist/main.js scan-local /path/to/project
# Or use npm scripts
npm run scan https://github.com/user/mcp-server
npm run scan-local /path/to/project
Docker Usage π³
# Production container
docker run --rm mcp-watch scan https://github.com/user/mcp-server
docker run --rm mcp-watch scan https://github.com/user/mcp-server --format json --severity high
# Docker Compose
docker compose run --rm mcp-watch scan https://github.com/user/repo
docker compose run --rm mcp-watch scan https://github.com/user/repo --format json
# Interactive container
docker run -it --rm mcp-watch sh
Options
--format <type>- Output format:console(default) orjson--severity <level>- Minimum severity:low,medium,high,critical--category <cat>- Filter by vulnerability category
Categories
credential-leak- Hardcoded credentials and insecure storagetool-poisoning- Malicious tool descriptionsdata-exfiltration- Data theft and parameter injectionprompt-injection- Prompt manipulation attackstool-mutation- Dynamic tool changessteganographic-attack- Hidden content in escape sequencesprotocol-violation- MCP protocol security issuesinput-validation- Command injection, SSRF, path traversalserver-spoofing- Server impersonationtoxic-flow- Dangerous data flowsaccess-control- Permission and access issues
Example Output
π Scanning repository: https://github.com/user/mcp-server
π Based on vulnerablemcp.info, HiddenLayer, Invariant Labs, and Trail of Bits research
π Scanning for credential vulnerabilities...
π§ͺ Scanning for tool poisoning vulnerabilities...
π― Scanning for parameter injection vulnerabilities...
π Scanning for prompt injection vulnerabilities...
π MCP SECURITY SCAN RESULTS
===============================
π Summary by Severity:
π¨ CRITICAL: 2
β οΈ HIGH: 1
β‘ MEDIUM: 3
π Detailed Results:
--------------------
1. π¨ Hardcoded credentials detected
π ID: HARDCODED_CREDENTIALS
π― Severity: CRITICAL
π Category: credential-leak
π Location: src/config.ts:15
π Evidence: const apiKey = "sk-***REDACTED***"
Development
Project Structure
mcp-watch/
βββ main.ts # CLI entry point
βββ types/
β βββ Vulnerability.ts # Type definitions
βββ scanner/
β βββ MCPScanner.ts # Main scanner orchestrator
β βββ BaseScanner.ts # Base scanner utilities
β βββ scanners/ # Individual vulnerability scanners
β βββ CredentialScanner.ts
β βββ ParameterInjectionScanner.ts
β βββ ...
βββ utils/
β βββ reportFormatter.ts # Report formatting
βββ Docker/ # Containerization
βββ Dockerfile # Production image
βββ docker-compose.yml # Multi-service orchestration (Docker Compose v2)
βββ .dockerignore # Build optimization
Development Scripts
# Build the project
npm run build
# Run in development mode
npm run dev scan https://github.com/user/repo
# Quick scan during development
npm run scan https://github.com/user/repo
# Clean build artifacts
npm run clean
# Type checking
npm run type-check
Development Workflow π
Local Development (Recommended)
# Install dependencies
npm install
# Run development server
npm run dev
# Run scans during development
npm run scan https://github.com/user/repo
# Type checking
npm run type-check
Docker Development π³
# Build Docker image
docker compose build
# Test the image
docker run --rm mcp-watch scan https://github.com/user/repo
# Test Docker Compose
docker compose run --rm mcp-watch scan --help
Adding New Scanners
- Create a new scanner in
scanner/scanners/ - Extend
AbstractScanner - Implement the
scan()method - Add to
MCPScanner.ts
Example:
import { AbstractScanner } from "../BaseScanner";
import { Vulnerability } from "../../types/Vulnerability";
export class MyScanner extends AbstractScanner {
async scan(projectPath: string): Promise<Vulnerability[]> {
console.log("π Scanning for my vulnerability type...");
const vulnerabilities: Vulnerability[] = [];
// Your scanning logic here
return vulnerabilities;
}
}
Security Research
This tool is based on security research from leading organizations in AI and cybersecurity, identifying novel attack vectors specific to MCP environments including:
- Parameter injection attacks that extract sensitive AI context
- Tool poisoning with hidden malicious instructions
- Conversation exfiltration using trigger phrases
- Steganographic attacks via ANSI escape sequences
- Toxic agent flows across repository boundaries
Research Sources
VulnerableMCP Database (vulnerablemcp.info)
- Comprehensive database of MCP vulnerabilities
- Real-world attack patterns and examples
- Regular updates on new attack vectors
HiddenLayer Research (Exploiting MCP Tool Parameters)
- Parameter injection attacks that extract sensitive data
- Tool call history and conversation exfiltration
- System prompt extraction vulnerabilities
- Chain of thought manipulation
- Model name disclosure risks
Invariant Labs Research (GitHub MCP Vulnerability)
- Tool poisoning detection
- Toxic agent flows
- Cross-repository security issues
- Rug-pull updates in tool functionality
- Server spoofing prevention
Trail of Bits Research (MCP Security Research)
- Conversation exfiltration methods
- ANSI injection attacks
- Protocol-level vulnerabilities
- Insecure credential storage patterns
- Cross-server shadowing attacks
PromptHub Analysis (5 MCP Security Vulnerabilities)
- Command injection patterns (43% of public MCP servers affected)
- SSRF vulnerability statistics (30% allow arbitrary URL fetching)
- Path traversal attack vectors (22% leak files outside intended directories)
- Retrieval-Agent Deception (RADE) attacks
- Tool poisoning prevention strategies
Exit Codes
0- No critical or high severity vulnerabilities found1- Critical or high severity vulnerabilities detected1- Scan error occurred
GitHub Actions π
This repository uses automated workflows for CI/CD, security scanning, and dependency management:
- CI: Automated testing and Docker verification on every push/PR
- Security Scan: Daily security audits and vulnerability checks
- Dependency Update: Weekly dependency maintenance and security fixes
- Release: Automated release asset creation
- Docker Test: Docker-specific testing and validation
Dependabot π€
Automated dependency management with:
- npm: Weekly updates with auto-merge for minor/patch versions
- GitHub Actions: Automated action updates
- Docker: Base image updates
See GITHUB_ACTIONS.md for detailed workflow documentation.
Docker Development Workflow π³
# Clone and setup
git clone https://github.com/kapilduraphe/mcp-watch.git
cd mcp-watch
# Build Docker image
docker compose build
# Test the image
docker run --rm mcp-watch --help
# Run a scan
docker compose run --rm mcp-watch scan https://github.com/user/repo
FAQ
Common questions
Discussion
Questions & comments Β· 0
Sign In Sign in to leave a comment.