notasandy/mcp-code-sanitizer

πŸ’» Developer Tools
0 Views
0 Installs

🐍 🏠 🍎 πŸͺŸ 🐧 - Strict AI code reviewer powered by Groq. Finds bugs, vulnerabilities and SQL injections. Tools: analyzecode, comparecode, explaincode, generatetests, analyzefile, HTML reports.

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "notasandy-mcp-code-sanitizer": {
      "command": "npx",
      "args": [
        "-y",
        "notasandy-mcp-code-sanitizer"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

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

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

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
{
  "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):

{
  "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:

{
  "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:

git clone https://github.com/notasandy/mcp-code-sanitizer
cd mcp-code-sanitizer
pip install -r requirements.txt
cp .env.example .env   # add your GROQ_API_KEY
python server.py

Then point the client config to:

{
  "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.

# .github/workflows/ai-review.yml
name: AI Code Review
on:
  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.py
generate_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

Related MCP Servers

Moxie-Docs-MCPβ˜… Featured

MCP & Agent Skills for Automated Documentation, and codebase conventions + context

πŸ’» Developer Tools2 views
3KniGHtcZ/codebeamer-mcp

πŸ“‡ ☁️ 🍎 πŸͺŸ 🐧 - Codebeamer ALM integration for managing work items, trackers, and projects. Provides 17 tools for reading and writing items, associations, references, comments, and risk management data via Codebeamer REST API v3.

πŸ’» Developer Tools1 views
21st-dev/Magic-MCP

Create crafted UI components inspired by the best 21st.dev design engineers.

πŸ’» Developer Tools0 views
a-25/ios-mcp-code-quality-server

πŸ“‡ 🏠 🍎 - iOS code quality analysis and test automation server. Provides comprehensive Xcode test execution, SwiftLint integration, and detailed failure analysis. Operates in both CLI and MCP server modes for direct developer usage and AI assistant integration.

πŸ’» Developer Tools0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it β†’
β˜… Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.