{
  "markdown": "<!-- mcp-name: io.github.notasandy/mcp-code-sanitizer -->\n# mcp-code-sanitizer\n\n> Strict AI-powered code reviewer for Claude Desktop, Cursor, VS Code, and Claude Code CLI.\n> Finds bugs, vulnerabilities, and security issues — powered by Groq (free API).\n\n![Python](https://img.shields.io/badge/Python-3.10+-blue?logo=python&logoColor=white)\n![PyPI](https://img.shields.io/pypi/v/mcp-code-sanitizer?color=blue)\n![FastMCP](https://img.shields.io/badge/FastMCP-2.x-purple)\n![Groq](https://img.shields.io/badge/Groq-Free_API-orange)\n![License](https://img.shields.io/badge/License-MIT-green)\n\n```\nClaude / Cursor / VS Code  ──MCP──►  code-sanitizer  ──REST──►  Groq API\n                                        (server.py)              (llama-3.3-70b)\n```\n\n![demo](demo.svg)\n\n---\n\n## Features\n\n| Tool | What it does |\n|---|---|\n| `analyze_code` | Strict review — bugs, security issues, score 0–100 |\n| `compare_code` | Compares two versions, detects regressions, recommends merge/request_changes |\n| `explain_code` | Step-by-step explanation for junior / middle / senior audience |\n| `generate_tests` | Generates pytest / jest / go test — happy path, edge cases, security |\n| `analyze_file` | Analyzes a whole file from disk with parallel chunking |\n| `generate_report` | Builds an HTML report from any analysis result |\n| `cache_info` | Cache statistics and clearing |\n\n### Example output\n\n```json\n{\n  \"summary\": \"Critical SQL injection and secret exposed in logs\",\n  \"score\": 23,\n  \"issues\": [\n    {\n      \"severity\": \"critical\",\n      \"line\": 2,\n      \"title\": \"SQL Injection\",\n      \"description\": \"f-string directly interpolates user_id into query\",\n      \"fix\": \"cursor.execute('SELECT * FROM users WHERE id = %s', (user_id,))\"\n    }\n  ],\n  \"warnings\": [{\"title\": \"No exception handling\", \"description\": \"...\"}],\n  \"suggestions\": [\"Consider using an ORM instead of raw SQL\"]\n}\n```\n\n---\n\n## Installation\n\n> **Prerequisite:** Get a free Groq API key at [console.groq.com/keys](https://console.groq.com/keys) — no credit card required.\n\n### Claude Code CLI\n\n```bash\nclaude mcp add code-sanitizer -e GROQ_API_KEY=gsk_your_key -- uvx mcp-code-sanitizer\n```\n\n### Claude Desktop\n\n| OS | Config file |\n|---|---|\n| macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |\n| Windows | `%APPDATA%\\Claude\\claude_desktop_config.json` |\n| Linux | `~/.config/Claude/claude_desktop_config.json` |\n\n```json\n{\n  \"mcpServers\": {\n    \"code-sanitizer\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-code-sanitizer\"],\n      \"env\": {\n        \"GROQ_API_KEY\": \"gsk_your_key_here\"\n      }\n    }\n  }\n}\n```\n\n### Cursor\n\nCreate `.cursor/mcp.json` in your project (or `~/.cursor/mcp.json` globally):\n\n```json\n{\n  \"mcpServers\": {\n    \"code-sanitizer\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-code-sanitizer\"],\n      \"env\": {\n        \"GROQ_API_KEY\": \"gsk_your_key_here\"\n      }\n    }\n  }\n}\n```\n\n### VS Code\n\nRequires VS Code 1.99+ with GitHub Copilot. Create `.vscode/mcp.json` in your project:\n\n```json\n{\n  \"servers\": {\n    \"code-sanitizer\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-code-sanitizer\"],\n      \"env\": {\n        \"GROQ_API_KEY\": \"gsk_your_key_here\"\n      }\n    }\n  }\n}\n```\n\nOr add globally via **Ctrl+Shift+P → \"MCP: Add Server\"**.\n\n> **Don't have `uvx`?** Install it with `pip install uv`, then use the commands above.\n\n---\n\n## Manual install (alternative)\n\nIf you prefer cloning the repo:\n\n```bash\ngit clone https://github.com/notasandy/mcp-code-sanitizer\ncd mcp-code-sanitizer\npip install -r requirements.txt\ncp .env.example .env   # add your GROQ_API_KEY\npython server.py\n```\n\nThen point the client config to:\n```json\n{\n  \"command\": \"python\",\n  \"args\": [\"/full/path/to/server.py\"],\n  \"env\": { \"GROQ_API_KEY\": \"gsk_your_key_here\" }\n}\n```\n\n---\n\n## GitHub Action — automatic PR review\n\nAdd AI code review to any repository in 5 lines.\nThe action posts a structured comment on every PR with score, issues, and fix suggestions.\n\n```yaml\n# .github/workflows/ai-review.yml\nname: AI Code Review\non:\n  pull_request:\n    types: [opened, synchronize]\n\npermissions:\n  contents: read\n  pull-requests: write\n\njobs:\n  review:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: notasandy/mcp-code-sanitizer@v1\n        with:\n          groq_api_key: ${{ secrets.GROQ_API_KEY }}\n```\n\nAdd `GROQ_API_KEY` to your repository secrets → **Settings → Secrets → Actions**.\n\nThe action automatically:\n- Reviews only changed files (up to 10 per PR)\n- Posts a score and structured issue list as a PR comment\n- Fails the check if critical issues are found\n\n---\n\n## Usage in chat\n\nAfter connecting, just write naturally:\n\n```\nReview this code for vulnerabilities:\n\ndef get_user(user_id):\n    query = f\"SELECT * FROM users WHERE id = {user_id}\"\n    return db.execute(query)\n```\n\nOr call tools explicitly:\n\n```\nanalyze_file /path/to/my_script.py\ngenerate_tests for this function: ...\ncompare_code — before vs after refactor, did it get better?\ngenerate_report and save to /tmp/report.html\n```\n\n---\n\n## Architecture\n\n```\nmcp-code-sanitizer/\n├── server.py          # FastMCP entry point\n├── config.py          # Constants — keys, limits, extension map\n├── groq_client.py     # Async Groq client with auto-retry on 429\n├── cache.py           # In-memory LRU cache with TTL\n├── prompts.py         # System prompts for all tools\n└── tools/\n    ├── analyze.py     # analyze_code\n    ├── compare.py     # compare_code\n    ├── explain.py     # explain_code\n    ├── tests.py       # generate_tests\n    ├── file_tool.py   # analyze_file — chunking + parallel analysis\n    ├── cache_tool.py  # cache_info\n    └── report.py      # generate_report — HTML output\n```\n\n---\n\n## Configuration\n\nAll settings via `.env` or environment variables:\n\n| Variable | Default | Description |\n|---|---|---|\n| `GROQ_API_KEY` | — | **Required.** Get at console.groq.com |\n| `GROQ_MODEL` | `llama-3.3-70b-versatile` | Groq model to use |\n| `CACHE_TTL` | `3600` | Cache TTL in seconds |\n| `CACHE_MAX` | `200` | Max cached entries |\n\n### Available Groq models\n\n| Model | Speed | Quality |\n|---|---|---|\n| `llama-3.3-70b-versatile` | Fast | Best (default) |\n| `llama-3.1-8b-instant` | Fastest | Good |\n| `mixtral-8x7b-32768` | Fast | Great |\n\n---\n\n## Contributing\n\nPRs and Issues are welcome. Most wanted:\n\n- Support for other LLM providers (OpenAI, Anthropic)\n- New tools: dependency audit, complexity score, docstring generator\n- Prompt improvements and new language support\n\n---\n\n## License\n\nMIT — do whatever you want. A star would be appreciated.\n\n---\n\n## Links\n\n- [PyPI](https://pypi.org/project/mcp-code-sanitizer/)\n- [Groq Console — free API key](https://console.groq.com)\n- [FastMCP docs](https://gofastmcp.com)\n- [MCP specification](https://modelcontextprotocol.io)\n- [Smithery](https://smithery.ai/server/io.github.notasandy/mcp-code-sanitizer)\n- [MCP Registry](https://registry.modelcontextprotocol.io)\n",
  "bytes": 6863,
  "sha": "8fdffed23a3003506c27defe0891d0530f1d4563ab0ca0295630c806bd17841e",
  "repo_slug": "notasandy/mcp-code-sanitizer",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_notasandy_mcp_code_sanitizer_6ce28554/readme"
}