analyze_code
Comprehensive Python code quality analysis with complexity, dead code, clone detection, and coupling metrics
pathrequiredanalysesrecursiveoutput_mode
io.github.ludo-technologiesPublished by GitHub account ludo-technologiesv1.33.2Updated Nov 8, 2026
Python code analysis for AI agents: complexity, dead code, clones, coupling, and a health score.
Local MCP server that lets an assistant run Python code-quality analysis: complexity, dead code, clones, coupling, cohesion and a 0-100 health score.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Follow the launch instructions in the repository.
English | 日本語 | 简体中文 | Français
Code quality analysis for Python in the age of AI coding.
Building with Cursor, Claude, or ChatGPT? pyscn keeps AI-generated code maintainable with structural analysis.
One command scores your whole codebase (0-100 with an A-F grade) and generates an HTML report that shows what to fix first.
pyscn looks at your code from five angles:
100,000+ lines/sec • Built with Go + tree-sitter
pyscn is the Python analyzer of polyscan. For JavaScript, TypeScript, Go, Rust and C++, run:
Same five angles, same 0-100 score, one HTML report.
Polyscan App files a weekly audit report as a GitHub Issue. Free for public repositories.
[Install Polyscan App for free]
pyscn ships Agent Skills that teach AI coding agents when and how to run each analysis: health checks, refactoring, architecture review, and CI-friendly reports.
This installs the Skills into your project. They work with Claude Code, Cursor, Codex, Gemini CLI, and many other agents (add --agent cursor etc. to target one, --global for all projects).
Then just ask your agent:
"Analyze the code quality of the app/ directory"
"Find duplicate code and help me refactor it"
"Show me complex code and help me simplify it"
For tighter integration, the bundled pyscn-mcp server exposes the same analyses as MCP tools to Claude Code, Cursor, ChatGPT, and other MCP clients.
Claude Code plugin (sets up the MCP server and the Skills together):
Manual setup for Claude Code:
Cursor / Claude Desktop: add to your MCP settings (~/.config/claude-desktop/config.json or Cursor settings):
Dive deeper in mcp/README.md for setup walkthroughs and docs/MCP_INTEGRATION.md for architecture details.
macOS Intel (x86_64): PyPI wheels are built for Apple Silicon only (the Intel wheel was dropped in v1.5.1), so
uvx,pipx,uv, andpipcannot install pyscn on Intel Macs. Usebrew install pyscnorgo install github.com/ludo-technologies/pyscn/cmd/pyscn@latestinstead.
pyscn analyzeRun comprehensive analysis with HTML report
pyscn checkFast CI-friendly quality gate
pyscn initCreate configuration file
💡 Run
pyscn --helporpyscn <command> --helpfor complete options
Create a .pyscn.toml file or add [tool.pyscn] to your pyproject.toml:
⚙️ Run
pyscn initto generate a full configuration file with all available options
📖 pyscn documentation site — installation, rule catalog, CLI reference, configuration, output specification
For contributors: Development Guide • Architecture • Testing
For commercial support, custom integrations, or consulting services, contact us at [email protected]
MIT License — see LICENSE
Built with ❤️ using Go and tree-sitter
Source: README.md at commit 155305b
Comprehensive Python code quality analysis with complexity, dead code, clone detection, and coupling metrics
pathrequiredanalysesrecursiveoutput_modeAnalyze class cohesion (LCOM4 - Lack of Cohesion of Methods) metrics
pathrequiredmax_resultsoutput_modeAnalyze cyclomatic complexity of Python execution scopes
pathrequiredmax_resultsoutput_modeshow_detailsmax_complexitymin_complexityAnalyze class coupling (CBO - Coupling Between Objects) metrics
pathrequiredmin_cbomax_resultsoutput_modeDetect code clones using APTED tree edit distance and LSH acceleration
pathrequiredmin_linesmax_resultsoutput_modegroup_clonessimilarity_thresholdDetect Dependency Injection anti-patterns in Python code (constructor over-injection, hidden dependencies, concrete dependencies, service locator)
pathrequiredmin_severityconstructor_param_thresholdFind unreachable code using Control Flow Graph (CFG) analysis
pathrequiredmax_resultsoutput_modemin_severityGet overall code health score (0-100) with grade and category scores
pathrequired90% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
# Run analysis without installationuvx pyscn@latest analyze .# orpipx run pyscn analyze .npx polyscan analyze .uvx add-skills ludo-technologies/pyscnclaude plugin marketplace add ludo-technologies/pyscnclaude plugin install pyscn-mcp@pyscn-marketplaceclaude mcp add pyscn-mcp uvx -- pyscn-mcp{ "mcpServers": { "pyscn-mcp": { "command": "uvx", "args": ["pyscn-mcp"], "env": { "PYSCN_CONFIG": "/path/to/.pyscn.toml" } } }}# Install with pipx (recommended)pipx install pyscn
# Or with uvuv tool install pyscngit clone https://github.com/ludo-technologies/pyscn.gitcd pyscnmake buildgo install github.com/ludo-technologies/pyscn/cmd/pyscn@latestpyscn analyze . # All analyses with HTML reportpyscn analyze --json . # Generate JSON reportpyscn analyze --json --output - . | jq # JSON report on stdoutpyscn analyze --json --html --no-open . # JSON and HTML reports from one runpyscn analyze --select complexity . # Only complexity analysispyscn analyze --select deps . # Only dependency analysispyscn analyze --select complexity,deps,deadcode . # Multiple analysespyscn analyze --skip-communities . # Skip module community detectionpyscn check . # Quick pass/fail checkpyscn check --max-complexity 15 . # Custom thresholdspyscn check --max-cycles 0 . # Only allow 0 cycle dependencypyscn check --select deps . # Check only for circular dependenciespyscn check --select di . # Detect DI anti-patterns (opt-in)pyscn check --allow-circular-deps . # Allow circular dependencies (warning only)pyscn init # Generate .pyscn.toml# .pyscn.toml[complexity]max_complexity = 15
[dead_code]min_severity = "warning"
[output]directory = "reports"