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 分