Skip to main content
Glama
MCP Code Sanitizer

MCP Code Sanitizer

by notasandy

🔍 mcp-code-sanitizer

Claude Desktop, Cursor 또는 모든 MCP 호환 에이전트에서 Groq LLM을 통해 코드를 직접 검사하는 엄격한 AI 기반 코드 리뷰어입니다.

Python FastMCP Groq License

Claude Desktop  ──MCP──►  code-sanitizer  ──REST──►  Groq API
                            (server.py)               (llama-3.3-70b)

✨ 기능

도구

설명

analyze_code

엄격한 코드 리뷰 — 버그, 취약점, 점수 0–100

compare_code

두 버전 비교, 회귀 분석, 병합/변경 요청 권장

explain_code

주니어/중급/시니어 대상 단계별 설명

generate_tests

happy path, 엣지 케이스, 보안 테스트를 포함한 pytest/jest/go 테스트 생성

analyze_file

병렬 청킹을 사용하여 디스크의 전체 파일 분석

generate_report

모든 분석 결과로부터 아름다운 HTML 보고서 생성

cache_info

캐시 통계 및 삭제

응답 예시

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

Related MCP server: Claude Code Review MCP

🚀 빠른 시작

1. 저장소 복제

git clone https://github.com/YOUR_USERNAME/mcp-code-sanitizer
cd mcp-code-sanitizer

2. 가상 환경 생성 및 의존성 설치

python -m venv venv

# macOS / Linux
source venv/bin/activate

# Windows
venv\Scripts\activate

pip install -r requirements.txt

3. Groq API 키 추가

console.groq.com/keys에서 무료 키를 받으세요.

cp .env.example .env
# Open .env and set GROQ_API_KEY=gsk_...

4. 서버 테스트

python server.py

아무런 출력이 없으면 정상 작동 중입니다. 서버가 stdio를 통해 MCP 요청을 대기하고 있습니다.


🔌 Claude Desktop에 연결

설정 파일을 찾아 mcpServers 섹션을 추가하세요:

OS

설정 경로

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

Claude Desktop을 재시작하면 채팅창에 🔧 아이콘이 나타납니다.


🔌 Cursor에 연결

프로젝트 루트에 .cursor/mcp.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"}
    }
  }
}

🧪 MCP Inspector를 통한 테스트

source venv/bin/activate  # or venv\Scripts\activate on Windows
fastmcp dev inspector server.py

전체 도구 테스트 인터페이스가 포함된 브라우저 UI가 열립니다.


💬 채팅에서 사용하기

Claude Desktop에 연결한 후, 다음과 같이 작성하세요:

Review this code for vulnerabilities:

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

또는 도구를 명시적으로 호출하세요:

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: ...

🏗️ 아키텍처

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)

⚙️ 설정

모든 설정은 환경 변수 또는 .env를 통해 가능합니다:

변수

기본값

설명

GROQ_API_KEY

—

필수. console.groq.com에서 획득

GROQ_MODEL

llama-3.3-70b-versatile

Groq 모델

CACHE_TTL

3600

캐시 TTL (초 단위)

CACHE_MAX

200

최대 캐시 항목 수

사용 가능한 Groq 모델

모델

속도

품질

llama-3.3-70b-versatile

⚡⚡

⭐⭐⭐⭐⭐ (기본값)

llama-3.1-8b-instant

⚡⚡⚡

⭐⭐⭐

mixtral-8x7b-32768

⚡⚡

⭐⭐⭐⭐


📦 요구 사항

fastmcp>=2.3.0
httpx>=0.27.0
python-dotenv>=1.0.0

🤝 기여하기

PR과 이슈는 언제나 환영합니다! 특히 다음 분야에 관심이 있습니다:

  • 다른 LLM 제공업체 지원 (OpenAI, Anthropic)

  • 새로운 도구 (보안 감사, 의존성 검사, 복잡도 분석)

  • 프롬프트 개선


📄 라이선스

MIT — 자유롭게 사용하세요. GitHub 스타를 주시면 감사하겠습니다 ⭐


🔗 링크

Available Tools

7 tools
analyze_codeC

Strict analysis of a code fragment using Groq LLM.

Inputs: code (required), language, context. Returns: result

analyze_fileA

Analyzes a whole code file from disk. Automatically detects language by file extension. Large files are split into chunks and analyzed in parallel.

Inputs: file_path (required), language, context. Returns: result

cache_infoA

Shows cache statistics or clears the cache Args: clear: True - clears the cache, False - shows statistics.

Returns: JSON with cache stats or clear result.

Inputs: clear. Returns: result

compare_codeA

Compares two versions of code and evaluates whether the change is an improvement.

Performs a structured diff analysis: identifies what improved, what regressed, and what changed neutrally. Returns a merge recommendation based on the findings. Useful for code review, refactoring validation, and AI-generated code verification.

Inputs: code_before (required), code_after (required), language, context. Returns: result

explain_codeA

Explains what code does - step by step and clearly. Args: code: Code to explain. language: Programming language. audience: Target audience level - junior, middle, or senior. Returns: JSON with step-by-step explanation, key concepts, and gotchas.

Inputs: code (required), language, audience. Returns: result

generate_reportA

Generates a beautiful HTML report from analyze_code or analyze_file results. Args: analysis_json: JSON string from analyze_code or analyze_file. output_path: Path to save the HTML file (optional). source_name: File/fragment name for the report title. Returns: JSON with fields: html, saved_to, length.

Inputs: analysis_json (required), output_path, source_name. Returns: result

generate_testsA

Generates tests for the provided code. Args: code: Code to generate tests for. language: Programming language. framework: Test framework (optional - pytest, jest, unittest, etc.). Returns: JSON with test cases, runnable test code, and coverage estimate.

Inputs: code (required), language, framework. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: code fragment analysis, whole file analysis, cache management, code comparison, code explanation, report generation, and test generation. No overlap in functionality.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern using snake_case (e.g., analyze_code, generate_tests). No inconsistencies in style.

    Tool Count5/5

    7 tools is a well-scoped set for code analysis and sanitization tasks, covering the core operations without being overwhelming or too sparse.

    Completeness4/5

    The tool surface covers analysis, comparison, explanation, test generation, and reporting. A minor gap is the lack of code transformation or refactoring tools, but the set is reasonable for the stated domain.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A server that enables interaction with PostgreSQL, MySQL, MariaDB, or SQLite databases through Claude Desktop using natural language queries.
      1
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables comprehensive security scanning of code projects, detecting vulnerabilities in dependencies, code patterns (XSS, eval, etc.), and exposed secrets, with detailed reports in Spanish prioritized by severity.
      4
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      AI-powered code review tool that detects AI-generated code defects invisible to traditional linters — hallucinated packages, deprecated APIs, cross-file contradictions, hidden security anti-patterns, and over-engineering. Works as a standalone CLI, GitHub Action, or MCP server. Supports TypeScript, Python, Java, Go, and Kotlin. Free for individuals, no API key required.
      4
      41
      Business Source 1.1