Mcp Code Sanitizer

io.github.notasandy由 GitHub 帳號 notasandy 發布v0.1.0更新於 Oct 24, 2026

Strict AI code reviewer powered by Groq. Finds bugs and vulnerabilities.

概覽

AI 產生的概覽

一個使用 Groq 託管大型模型審查程式碼缺陷、安全性問題並產生測試的 MCP 伺服器。

可以做什麼
它提供多種工具:分析程式碼片段、比較兩個版本以找出回歸、依不同經驗程度解釋程式碼、為 pytest、jest 或 go test 產生測試、對磁碟上的整個檔案進行平行分塊分析,以及產生 HTML 報告。結果包含 0–100 的分數、依嚴重程度排序的問題與修正建議,以及警告。內建含 TTL 的記憶體 LRU 快取會保存先前的分析。
適用情境
當你希望助理進行嚴格程式碼審查、找出 SQL 注入等漏洞、比較重構前後的版本,或起草單元測試時使用。適合個人開發者,也適合為提取要求新增自動審查的團隊。
執行需求
以本機 Python 程序執行,通常透過 uvx 或 python server.py 啟動。需要 Groq API 金鑰,透過 GROQ_API_KEY 環境變數提供,並需要連線至 Groq API 的網路。選用設定包括 GROQ_MODEL、CACHE_TTL 與 CACHE_MAX。
安裝前請注意
必須提供 GROQ_API_KEY 密鑰,該密鑰會傳送給 Groq,請勿寫入共用設定檔。提交分析的程式碼會傳輸到 Groq API,避免傳送專有或敏感原始碼。GitHub Action 需要提取要求寫入權限,並會在 PR 上張貼留言。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Code Sanitizer,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

mcp-code-sanitizer

Strict AI-powered code reviewer for Claude Desktop, Cursor, VS Code, and Claude Code CLI. Finds bugs, vulnerabilities, and security issues — powered by Groq (free API).

[Python] [PyPI] [FastMCP] [Groq] [License]

Claude / Cursor / VS Code  ──MCP──►  code-sanitizer  ──REST──►  Groq API                                        (server.py)              (llama-3.3-70b)

[demo]


Features

ToolWhat it does
analyze_codeStrict review — bugs, security issues, score 0–100
compare_codeCompares two versions, detects regressions, recommends merge/request_changes
explain_codeStep-by-step explanation for junior / middle / senior audience
generate_testsGenerates pytest / jest / go test — happy path, edge cases, security
analyze_fileAnalyzes a whole file from disk with parallel chunking
generate_reportBuilds an HTML report from any analysis result
cache_infoCache statistics and clearing

Example output

json
{  "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"]}

Installation

Prerequisite: Get a free Groq API key at console.groq.com/keys — no credit card required.

Claude Code CLI

bash
claude mcp add code-sanitizer -e GROQ_API_KEY=gsk_your_key -- uvx mcp-code-sanitizer

Claude Desktop

OSConfig file
macOS~/Library/Application Support/Claude/claude_desktop_config.json
Windows%APPDATA%\Claude\claude_desktop_config.json
Linux~/.config/Claude/claude_desktop_config.json
json
{  "mcpServers": {    "code-sanitizer": {      "command": "uvx",      "args": ["mcp-code-sanitizer"],      "env": {        "GROQ_API_KEY": "gsk_your_key_here"      }    }  }}

Cursor

Create .cursor/mcp.json in your project (or ~/.cursor/mcp.json globally):

json
{  "mcpServers": {    "code-sanitizer": {      "command": "uvx",      "args": ["mcp-code-sanitizer"],      "env": {        "GROQ_API_KEY": "gsk_your_key_here"      }    }  }}

VS Code

Requires VS Code 1.99+ with GitHub Copilot. Create .vscode/mcp.json in your project:

json
{  "servers": {    "code-sanitizer": {      "command": "uvx",      "args": ["mcp-code-sanitizer"],      "env": {        "GROQ_API_KEY": "gsk_your_key_here"      }    }  }}

Or add globally via Ctrl+Shift+P → "MCP: Add Server".

Don't have uvx? Install it with pip install uv, then use the commands above.


Manual install (alternative)

If you prefer cloning the repo:

bash
git clone https://github.com/notasandy/mcp-code-sanitizercd mcp-code-sanitizerpip install -r requirements.txtcp .env.example .env   # add your GROQ_API_KEYpython server.py

Then point the client config to:

json
{  "command": "python",  "args": ["/full/path/to/server.py"],  "env": { "GROQ_API_KEY": "gsk_your_key_here" }}

GitHub Action — automatic PR review

Add AI code review to any repository in 5 lines. The action posts a structured comment on every PR with score, issues, and fix suggestions.

yaml
# .github/workflows/ai-review.ymlname: AI Code Reviewon:  pull_request:    types: [opened, synchronize]
permissions:  contents: read  pull-requests: write
jobs:  review:    runs-on: ubuntu-latest    steps:      - uses: notasandy/mcp-code-sanitizer@v1        with:          groq_api_key: ${{ secrets.GROQ_API_KEY }}

Add GROQ_API_KEY to your repository secrets → Settings → Secrets → Actions.

The action automatically:

  • Reviews only changed files (up to 10 per PR)
  • Posts a score and structured issue list as a PR comment
  • Fails the check if critical issues are found

Usage in chat

After connecting, just write naturally:

Review this code for vulnerabilities:
def get_user(user_id):    query = f"SELECT * FROM users WHERE id = {user_id}"    return db.execute(query)

Or call tools explicitly:

analyze_file /path/to/my_script.pygenerate_tests for this function: ...compare_code — before vs after refactor, did it get better?generate_report and save to /tmp/report.html

Architecture

mcp-code-sanitizer/├── server.py          # FastMCP entry point├── config.py          # Constants — keys, limits, extension map├── groq_client.py     # Async Groq client with auto-retry on 429├── cache.py           # In-memory LRU 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 output

Configuration

All settings via .env or environment variables:

VariableDefaultDescription
GROQ_API_KEY—Required. Get at console.groq.com
GROQ_MODELllama-3.3-70b-versatileGroq model to use
CACHE_TTL3600Cache TTL in seconds
CACHE_MAX200Max cached entries

Available Groq models

ModelSpeedQuality
llama-3.3-70b-versatileFastBest (default)
llama-3.1-8b-instantFastestGood
mixtral-8x7b-32768FastGreat

Contributing

PRs and Issues are welcome. Most wanted:

  • Support for other LLM providers (OpenAI, Anthropic)
  • New tools: dependency audit, complexity score, docstring generator
  • Prompt improvements and new language support

License

MIT — do whatever you want. A star would be appreciated.


Links

來源:README.md,提交 9fa6a25

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分