Secure Code Review MCP Server
Local MCP server that scans code for security issues (secrets, dependencies, configurations, risky patterns) and integrates with GitHub Copilot in VS Code for automated pre-commit reviews.
README
Secure Code Review MCP Server
A local MCP (Model Context Protocol) server that helps software engineers review their code for security issues before committing or raising a PR. This server integrates directly with GitHub Copilot in VS Code.
🎯 What Problem Does This Solve?
Developers often commit code with:
- Hardcoded secrets (API keys, passwords)
- Duplicate or risky dependencies
- Insecure configuration settings
- Dangerous code patterns (eval, SQL injection)
- Missing security hygiene files
This MCP server provides automated security scanning right inside VS Code through GitHub Copilot, catching issues before they reach your repository.
🏗️ Architecture
┌─────────────────────────────────────────────────────────────┐
│ VS Code │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ GitHub Copilot Chat │ │
│ │ "Scan my code for security issues" │ │
│ └────────────────────────┬────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ MCP Client (STDIO) │ │
│ └────────────────────────┬────────────────────────────┘ │
└───────────────────────────┼─────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Secure Code Review MCP Server │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ server.py │ │
│ │ (MCP SDK + Tool Handlers) │ │
│ └────────────────────────┬────────────────────────────┘ │
│ │ │
│ ┌────────────┬───────────┼───────────┬────────────────┐ │
│ │ │ │ │ │ │
│ ▼ ▼ ▼ ▼ ▼ │
│ ┌────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐│
│ │Sec │ │ Dep │ │ Config │ │ Code │ │ PR ││
│ │rets│ │Scanner │ │Scanner │ │Pattern │ │Readine-││
│ │Scan│ │ │ │ │ │Scanner │ │ ss ││
│ └────┘ └────────┘ └────────┘ └────────┘ └────────┘│
└─────────────────────────────────────────────────────────────┘
│
▼
┌──────────────┐
│ Local Files │
│ (Read-Only) │
└──────────────┘
📁 Project Structure
secure-code-review-mcp/
├── README.md # This file
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore rules
│
├── src/
│ ├── __init__.py
│ ├── server.py # Main MCP server with 6 tools
│ │
│ ├── scanners/
│ │ ├── __init__.py
│ │ ├── base_scanner.py # Abstract base scanner
│ │ ├── secrets_scanner.py # Hardcoded secrets detection
│ │ ├── dependency_scanner.py # Dependency issues
│ │ ├── config_scanner.py # Insecure configurations
│ │ ├── code_pattern_scanner.py # Risky code patterns
│ │ └── pr_readiness_scanner.py # PR checklist generator
│
├── sample_project/ # Test project with vulnerabilities
│ ├── app.py # Python with dangerous patterns
│ ├── index.js # JavaScript with dangerous patterns
│ ├── config.py # Insecure configurations
│ ├── requirements.txt # Dependencies with issues
│ ├── package.json # Node.js dependencies with issues
│ ├── Dockerfile # Docker with security issues
│ ├── .env.example # Environment variables template
│ └── README.md # Sample project notes
Note:
docs/,tests/,pyproject.toml, andmcp_config.jsonwere intentionally removed to keep this project minimal and focused on local MCP usage.
✨ MCP Tools Available
| Tool | Description |
|---|---|
scan_hardcoded_secrets |
Scan for passwords, API keys, tokens, AWS credentials, private keys, database connection strings |
scan_dependencies |
Check for duplicate packages, unpinned versions, risky packages, missing lock files |
scan_insecure_configs |
Detect DEBUG=true, CORS=*, root user in Docker, latest tag usage |
scan_risky_code_patterns |
Find eval(), exec(), SQL injection, weak hashing (MD5/SHA1), unsafe yaml.load |
generate_pr_security_checklist |
Generate PR readiness checklist with pass/fail status |
run_full_security_review |
Run all scanners and produce comprehensive summary |
🚀 Prerequisites
- Python 3.10+
- VS Code with GitHub Copilot extension
- GitHub Copilot Chat enabled
📦 Installation
Step 1: Clone/Navigate to the Project
cd path/to/secure-code-review-mcp
Step 2: Create Virtual Environment (Recommended)
# Windows
python -m venv venv
.\venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activate
Step 3: Install Dependencies
pip install -r requirements.txt
Step 4: Verify Installation
python -c "import mcp; print('MCP SDK installed successfully!')"
🔌 Connecting to GitHub Copilot in VS Code
Step 1: Create MCP Configuration
Create or verify .vscode/mcp.json in your workspace root:
{
"servers": {
"secure-code-review": {
"type": "stdio",
"command": "python",
"args": [
"${workspaceFolder}/mcp-client-server/secure-code-review-mcp/src/server.py"
],
"env": {
"PYTHONPATH": "${workspaceFolder}/mcp-client-server/secure-code-review-mcp/src"
}
}
}
}
Note: Adjust the path based on your folder structure.
Step 2: Reload VS Code
- Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) - Type "Developer: Reload Window"
- Press Enter
Step 3: Verify MCP Server is Connected
- Open GitHub Copilot Chat (
Ctrl+Alt+Ior click the Copilot icon) - Click the 🔧 Tools icon in the chat
- You should see "secure-code-review" listed with 6 tools
🧪 Testing the MCP Server
Test with Sample Project
The sample_project/ folder contains intentionally vulnerable code for testing.
Example Prompts for GitHub Copilot
Open GitHub Copilot Chat and try these prompts:
1. "Scan sample_project for hardcoded secrets"
2. "Check dependencies in the sample_project folder"
3. "Find insecure configurations in sample_project"
4. "Scan sample_project for risky code patterns"
5. "Generate a PR security checklist for sample_project"
6. "Run a full security review on sample_project"
Expected Output Example
For scan_hardcoded_secrets:
{
"scanner": "SecretsScanner",
"files_scanned": 5,
"total_findings": 12,
"findings": [
{
"file_path": "sample_project/app.py",
"line_number": 15,
"matched_pattern_type": "Hardcoded Password",
"severity": "High",
"recommendation": "Remove hardcoded password and use environment variables"
}
],
"summary": {
"high_severity": 10,
"medium_severity": 2,
"low_severity": 0
}
}
For run_full_security_review:
{
"project_path": "sample_project",
"summary": {
"total_findings": 45,
"high_severity_count": 25,
"medium_severity_count": 15,
"low_severity_count": 5
},
"pr_readiness": {
"overall_status": "🔴 Needs Fixes",
"checklist_items": [...]
},
"final_recommendation": "🔴 DO NOT RAISE PR - Fix all high severity issues first"
}
🔍 What Each Scanner Detects
Secrets Scanner
password=,passwd=,pwd=api_key=,apikey=secret=,token=AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY-----BEGIN PRIVATE KEY------ Database connection strings with credentials
- JWT secrets
Dependency Scanner
- Duplicate packages in requirements.txt
- Duplicate dependencies across package.json sections
- Unpinned versions (
pandaswithout==x.x.x) - Wildcard versions (
*,latest) - Known risky packages (pycrypto, event-stream, etc.)
- Missing lock files
Config Scanner
DEBUG=trueENV=developmentin production configsCORS=*,ALLOW_ORIGINS=*- Root user in Dockerfile
:latesttag in Docker images- Exposed sensitive ports (22, 3389)
- Hardcoded passwords in Docker ENV
Code Pattern Scanner
Python:
eval(),exec()subprocess.run(..., shell=True)os.system()pickle.load()with untrusted datayaml.load()without SafeLoader- SQL string formatting
hashlib.md5(),hashlib.sha1()
JavaScript:
eval()new Function()setTimeout/setIntervalwith stringschild_process.exec().innerHTMLassignmentdocument.write()- SQL template literals
crypto.createHash('md5'/'sha1')
📄 License
MIT License - Free for personal and commercial use.
🤝 Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
⚠️ Disclaimer: This is a basic security scanner for learning and demonstration purposes. It should NOT be used as the sole security review tool for production applications. Always use professional security tools and conduct thorough security audits.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。