mcp-watch

A comprehensive security scanner for Model Context Protocol (MCP) servers that detects vulnerabilities and security issues in your MCP server implementations.

GitHub Stars

94

User Rating

Not Rated

Favorites

0

Views

25

Forks

7

Issues

4

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
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 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

Note: If you don't want to download npm then just substitute mcp-watch with node dist/main.js.

Example: node dist/main.js scan https://github.com/user/repo

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) or json
  • --severity <level> - Minimum severity: low, medium, high, critical
  • --category <cat> - Filter by vulnerability category
Categories
  • credential-leak - Hardcoded credentials and insecure storage
  • tool-poisoning - Malicious tool descriptions
  • data-exfiltration - Data theft and parameter injection
  • prompt-injection - Prompt manipulation attacks
  • tool-mutation - Dynamic tool changes
  • steganographic-attack - Hidden content in escape sequences
  • protocol-violation - MCP protocol security issues
  • input-validation - Command injection, SSRF, path traversal
  • server-spoofing - Server impersonation
  • toxic-flow - Dangerous data flows
  • access-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
  1. Create a new scanner in scanner/scanners/
  2. Extend AbstractScanner
  3. Implement the scan() method
  4. 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 found
  • 1 - Critical or high severity vulnerabilities detected
  • 1 - Scan error occurred
Contributing
  1. Fork the repository
  2. Create a feature branch
  3. Run type checking with npm run type-check
  4. Test your changes manually
  5. Submit a pull request
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
License

MIT License - see LICENSE file for details.

Support
  • Create an issue for bug reports or feature requests
  • Check existing issues before creating new ones
  • Include scan output and repository details when reporting issues
Docker Support ๐Ÿณ
  • Documentation: See DOCKER.md for detailed Docker usage
  • Issues: Include Docker version and Docker Compose version when reporting issues
  • Testing: Test with both production and development containers

โš ๏ธ Security Notice: This tool identifies potential security issues but should not be the only security measure. Always perform manual security reviews and follow security best practices.