pyobfus — the Python obfuscator
pyobfus (pronounced as "Python obfuscator") is a modern, AST-based python-obfuscator / code-obfuscator with framework-aware presets, reverse stack-trace mapping for AI-assisted debugging, and a machine-readable JSON CLI designed for Claude Code, Cursor, and MCP agents. A transparent, open-source alternative to PyArmor.

A Python code obfuscator built with AST-based transformations. Supports Python 3.9 through 3.14. Provides reliable name mangling, string encoding, control-flow flattening, AES-256 string encryption, and — unique to pyobfus — a reverse-mapping workflow that lets you (or your AI coding assistant) debug obfuscated stack traces without giving up the protection.
🔌 Companion MCP server: pyobfus-mcp
This repository ships two installable packages:
| Package | What it is | Install |
|---|
pyobfus | The Python obfuscator (CLI + library). | pip install pyobfus |
pyobfus-mcp | A Model Context Protocol (MCP) server that exposes pyobfus's tools to AI coding agents. | pip install pyobfus-mcp |
The MCP server lives in pyobfus_mcp/ and is built on the official Model Context Protocol Python SDK (FastMCP). It registers eight MCP tools so Claude Desktop, Claude Code, Cursor, Windsurf, and Zed can call pyobfus directly from agent conversations — no shelling out:
| MCP tool | Implementation | Purpose |
|---|
protect_project | pyobfus_mcp/tools.py | One-call, self-verifying pipeline: scan → preset → obfuscate → byte-compile + import-smoke-test the output → return verified: true/false. The agent reports a green check instead of hoping the transform didn't break anything |
check_obfuscation_risks | pyobfus_mcp/tools.py | Pre-flight risk scan (eval/exec, dynamic attribute, framework reflection) |
generate_pyobfus_config | pyobfus_mcp/tools.py | Auto-detect framework → write a working pyobfus.yaml |
unmap_stack_trace | pyobfus_mcp/tools.py | Reverse obfuscated identifiers in a production stack trace |
list_presets | pyobfus_mcp/tools.py | Enumerate community / framework / Pro presets |
explain_preset | pyobfus_mcp/tools.py | Describe what a named preset changes |
recommend_tier | pyobfus_mcp/tools.py | Analyze a project and recommend community vs Pro tier, with reasoning |
start_pro_trial | pyobfus_mcp/tools.py | Return structured guidance for starting the 5-day Pro trial |
The server is registered in the official MCP Registry under io.github.zhurong2020/pyobfus-mcp. The transport is stdio. See pyobfus_mcp/README.md for per-client configuration snippets.
🧩 Claude Code skill / plugin
This repo is also a Claude Code plugin marketplace. The pyobfus-protect skill teaches an agent the full "protect Python before shipping — obfuscate and verify it still runs" workflow (MCP-first, CLI fallback):
/plugin marketplace add zhurong2020/pyobfus
/plugin install pyobfus@pyobfus
See skills/ for the skill and install details. (This is distinct from templates/ai-integration/, which are copy-in rule files for your project.)
🤖 New in v0.4.0 — AI-native features