MCP Code Sanitizer
Strict AI code reviewer powered by Groq. Finds bugs, vulnerabilities and security issues in your code. Supports analyze, compare versions, explain code, generate tests, and HTML reports.
README
<!-- mcp-name: io.github.notasandy/mcp-code-sanitizer -->
🔍 mcp-code-sanitizer
A strict AI-powered code reviewer that runs your code through Groq LLM directly from Claude Desktop, Cursor, or any MCP-compatible agent.
Claude Desktop ──MCP──► code-sanitizer ──REST──► Groq API
(server.py) (llama-3.3-70b)
✨ Features
| Tool | Description |
|---|---|
analyze_code |
Strict code review — bugs, vulnerabilities, score 0–100 |
compare_code |
Compares two versions, finds regressions, recommends merge/request_changes |
explain_code |
Step-by-step explanation for junior/middle/senior audience |
generate_tests |
Generates pytest/jest/go test with happy path, edge cases, security tests |
analyze_file |
Analyzes a whole file from disk with parallel chunking |
generate_report |
Builds a beautiful HTML report from any analysis result |
cache_info |
Cache statistics and clearing |
Example response
{
"summary": "Critical SQL injection and secret exposed in logs",
"score": 23,
"issues": [
{
"severity": "critical",
"line": 2,
"title": "SQL Injection",
"description": "f-string directly interpolates user_id into query",
"fix": "cursor.execute('SELECT * FROM users WHERE id = %s', (user_id,))"
}
],
"warnings": [{"title": "No exception handling", "description": "..."}],
"suggestions": ["Consider using an ORM instead of raw SQL"]
}
🚀 Quick Start
1. Clone the repository
git clone https://github.com/YOUR_USERNAME/mcp-code-sanitizer
cd mcp-code-sanitizer
2. Create virtual environment and install dependencies
python -m venv venv
# macOS / Linux
source venv/bin/activate
# Windows
venv\Scripts\activate
pip install -r requirements.txt
3. Add your Groq API key
Get a free key at console.groq.com/keys
cp .env.example .env
# Open .env and set GROQ_API_KEY=gsk_...
4. Test the server
python server.py
Silence means it's working — the server is listening for MCP requests via stdio.
🔌 Connect to Claude Desktop
Find your config file and add the mcpServers section:
| OS | Config path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
{
"mcpServers": {
"code-sanitizer": {
"command": "/full/path/to/venv/bin/python",
"args": ["/full/path/to/server.py"],
"env": {
"GROQ_API_KEY": "gsk_your_key_here"
}
}
}
}
Restart Claude Desktop — you'll see the 🔧 icon in chat.
🔌 Connect to Cursor
Create .cursor/mcp.json in your project root:
{
"mcpServers": {
"code-sanitizer": {
"command": "/full/path/to/venv/bin/python",
"args": ["/full/path/to/server.py"],
"env": {"GROQ_API_KEY": "gsk_your_key_here"}
}
}
}
🧪 Testing via MCP Inspector
source venv/bin/activate # or venv\Scripts\activate on Windows
fastmcp dev inspector server.py
A browser UI opens with full tool testing interface.
💬 Usage in chat
After connecting to Claude Desktop, just write:
Review this code for vulnerabilities:
def get_user(user_id):
query = f"SELECT * FROM users WHERE id = {user_id}"
return db.execute(query)
Or explicitly call a tool:
Use analyze_file on /path/to/my_script.py
Generate tests for this function: ...
Compare these two versions and tell me if it got better: ...
🏗️ Architecture
mcp-code-sanitizer/
├── server.py # FastMCP entry point (39 lines)
├── config.py # Constants — keys, limits, mappings
├── groq_client.py # Groq API client with auto-retry on rate limits
├── cache.py # In-memory cache with TTL
├── prompts.py # System prompts for all tools
└── tools/
├── analyze.py # analyze_code
├── compare.py # compare_code
├── explain.py # explain_code
├── tests.py # generate_tests
├── file_tool.py # analyze_file (chunking + parallel analysis)
├── cache_tool.py # cache_info
└── report.py # generate_report (HTML)
⚙️ Configuration
All settings via environment variables or .env:
| Variable | Default | Description |
|---|---|---|
GROQ_API_KEY |
— | Required. Get at console.groq.com |
GROQ_MODEL |
llama-3.3-70b-versatile |
Groq model |
CACHE_TTL |
3600 |
Cache TTL in seconds |
CACHE_MAX |
200 |
Max cache entries |
Available Groq models
| Model | Speed | Quality |
|---|---|---|
llama-3.3-70b-versatile |
⚡⚡ | ⭐⭐⭐⭐⭐ (default) |
llama-3.1-8b-instant |
⚡⚡⚡ | ⭐⭐⭐ |
mixtral-8x7b-32768 |
⚡⚡ | ⭐⭐⭐⭐ |
📦 Requirements
fastmcp>=2.3.0
httpx>=0.27.0
python-dotenv>=1.0.0
🤝 Contributing
PRs and Issues are welcome! Especially interested in:
- Support for other LLM providers (OpenAI, Anthropic)
- New tools (security audit, dependency check, complexity analysis)
- Prompt improvements
📄 License
MIT — do whatever you want. A GitHub star would be appreciated ⭐
🔗 Links
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。