{
  "markdown": "# CodeSafer (cleaner-code)\n\n> **AI code security scanner as a Model Context Protocol (MCP) server.**\n> Detects hidden threats in AI-generated code that traditional linters miss.\n\n[![npm](https://img.shields.io/badge/mcp-server-blue)](https://modelcontextprotocol.io)\n[![license: ISC](https://img.shields.io/badge/license-ISC-green)](#license)\n[![Node](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)\n\n**Website:** [codesafer.org](https://codesafer.org/) &nbsp;·&nbsp; **MCP Clients:** Claude Code, Cursor, VS Code + Copilot, Cline\n\n---\n\n## Why CodeSafer?\n\nAI coding assistants generate code fast — but who's checking it for hidden threats?\n\nRecent supply-chain attacks show that malicious code can hide in ways human reviewers and traditional linters routinely miss:\n\n- **Invisible Unicode characters** injected into identifiers (30+ variants)\n- **BiDi / Trojan Source** attacks that reorder how code is displayed vs. executed (CVE-2021-42574)\n- **Homoglyphs** — Cyrillic characters masquerading as Latin (CVE-2021-42694)\n- **Glassworm-style Unicode steganography** hiding payloads in whitespace\n- **Rules file backdoors** planted in `.cursorrules`, `CLAUDE.md`, and other AI config files\n- **Typosquatted dependencies** in `package.json`\n- **Obfuscation patterns** — `eval` + base64, reverse shells, packed payloads\n\nCodeSafer scans for all of these before the code runs on your machine.\n\n---\n\n## How it works\n\nCodeSafer runs as a local MCP server. Your AI client (Claude Code, Cursor, etc.) calls its tools when reviewing or generating code, and findings are returned inline.\n\n**Hybrid detection:**\n\n1. **8 static analysis scanners** — deterministic rules for known attack categories (fast, zero false-negatives on the patterns they cover).\n2. **CodeBERT deep analysis** — transformer model classifies code chunks as malicious/benign with confidence scores. Catches obfuscated or novel patterns that static rules miss.\n\nNothing leaves your machine. The AI analysis runs locally against a tokenizer server.\n\n---\n\n## Features\n\n| Capability | Details |\n|---|---|\n| Invisible character detection | 30+ Unicode variants including Zero-Width Space, Mongolian Vowel Separator |\n| BiDi / Trojan Source | Full CVE-2021-42574 coverage |\n| Homoglyph detection | Cyrillic/Greek/Latin confusables (CVE-2021-42694) |\n| Unicode steganography | Glassworm-style whitespace payloads |\n| Rules file backdoors | Scans `.cursorrules`, `CLAUDE.md`, `.claude/`, Cursor rules |\n| Dependency scanning | Typosquatting + suspicious install scripts in `package.json` |\n| Obfuscation detection | `eval` + base64, reverse shells, packed payloads |\n| AI deep analysis | CodeBERT transformer classifier with confidence scores |\n| MCP native | 6 MCP tools, stdio transport |\n| Local-first | No code uploaded — runs entirely on your machine |\n\n---\n\n## MCP Tools\n\nCodeSafer exposes six tools to your MCP client:\n\n| Tool | Purpose |\n|---|---|\n| `scan_file` | Scan a single file for hidden malicious code patterns |\n| `scan_directory` | Recursively scan a directory across all source files |\n| `scan_rules_file` | Scan an AI configuration/rules file for prompt injection and Rules File Backdoor attacks |\n| `check_dependencies` | Check `package.json` for typosquatting, suspicious install scripts, and dependency risks |\n| `ai_analyze` | Deep AI analysis using the trained CodeBERT model (classifies chunks as malicious/benign with confidence) |\n| `explain_finding` | Get detailed explanation of a specific threat category, with attack scenarios and remediation |\n\n---\n\n## Installation\n\n### Prerequisites\n\n- Node.js 18 or later\n- An MCP-compatible client (Claude Code, Cursor, VS Code + Copilot, Cline)\n\n### From source\n\n```bash\ngit clone https://github.com/goldmembrane/cleaner-code.git\ncd cleaner-code\nnpm install\nnpm run build\n```\n\n### Configure your MCP client\n\n**Claude Code** (`~/.claude.json` or project `.mcp.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"codesafer\": {\n      \"command\": \"node\",\n      \"args\": [\"/absolute/path/to/cleaner-code/dist/index.js\"]\n    }\n  }\n}\n```\n\n**Cursor** (`.cursor/mcp.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"codesafer\": {\n      \"command\": \"node\",\n      \"args\": [\"/absolute/path/to/cleaner-code/dist/index.js\"]\n    }\n  }\n}\n```\n\nRestart your client, and CodeSafer tools will appear in the tool picker.\n\n---\n\n## Usage\n\nOnce configured, ask your AI client things like:\n\n- *\"Scan this file for hidden security issues.\"*\n- *\"Check the dependencies in package.json for typosquatting.\"*\n- *\"Scan `.cursorrules` for a rules-file backdoor.\"*\n- *\"Run a deep AI analysis of `src/auth.ts`.\"*\n- *\"Explain what a Trojan Source attack is and how to fix the finding above.\"*\n\nThe client will call the appropriate MCP tool and return findings with severity, line numbers, and remediation guidance.\n\n---\n\n## Free tier & Plans\n\nCodeSafer is free to use. Static analysis (`scan_file`, `scan_directory`, `scan_rules_file`, `check_dependencies`, `explain_finding`) has no limits.\n\nAI deep analysis (`ai_analyze`) includes **10 free runs per session**. Paid plans for higher AI quotas are available at [codesafer.org](https://codesafer.org/).\n\n---\n\n## Detection categories\n\nCodeSafer detects threats across **9 categories**:\n\n1. **Invisible Unicode characters** — 30+ variants including Zero-Width Space, Zero-Width Joiner\n2. **BiDi / Trojan Source attacks** — CVE-2021-42574\n3. **Homoglyphs** — Cyrillic/Greek characters masquerading as Latin (CVE-2021-42694)\n4. **Unicode steganography** — Glassworm patterns in whitespace\n5. **Rules file backdoors** — malicious instructions in `.cursorrules`, `CLAUDE.md`, etc.\n6. **Dependency risks** — typosquatting and suspicious install scripts\n7. **Obfuscation patterns** — `eval` + base64, packed payloads, reverse shells\n8. **Static analysis findings** — 8 deterministic scanners\n9. **AI deep analysis** — CodeBERT transformer for novel and obfuscated threats\n\n---\n\n## Project structure\n\n```\ncleaner-code/\n├── src/\n│   ├── index.ts           # MCP server entry point\n│   ├── api-server.ts      # Optional HTTP API server\n│   ├── types.ts           # Scanner interfaces\n│   ├── utils.ts           # File collection, summary formatting\n│   └── scanner/\n│       ├── invisible.ts       # Invisible Unicode scanner\n│       ├── bidi.ts            # BiDi / Trojan Source scanner\n│       ├── homoglyph.ts       # Homoglyph scanner\n│       ├── encoding.ts        # Encoding / charset scanner\n│       ├── obfuscation.ts     # Obfuscation pattern scanner\n│       ├── steganography.ts   # Unicode steganography scanner\n│       ├── rules-backdoor.ts  # Rules file backdoor scanner\n│       ├── dependency.ts      # Dependency risk scanner\n│       └── ai-analyzer.ts     # CodeBERT deep analyzer\n├── ml/                    # ML model assets and tokenizer\n├── functions/             # Cloud function deployments\n├── deploy/                # Deployment manifests\n└── web/                   # Landing page assets\n```\n\n---\n\n## License\n\nISC — see the `LICENSE` file for details.\n\n---\n\n## Links\n\n- **Website:** [codesafer.org](https://codesafer.org/)\n- **Model Context Protocol:** [modelcontextprotocol.io](https://modelcontextprotocol.io/)\n- **Report issues:** [GitHub Issues](https://github.com/goldmembrane/cleaner-code/issues)\n",
  "bytes": 7261,
  "sha": "9e9a4db246ddcbbb23ff828dc93b089d77ade4080366e99bd2af9eaaf100054e",
  "repo_slug": "goldmembrane/cleaner-code",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_goldmembrane_codesafer_2ff4e988/readme"
}