pyscn

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.

VerifiedSTDIODesktop onlyDeveloper ToolsData & Analytics

Overview

AI-generated overview

Local MCP server that lets an assistant run Python code-quality analysis: complexity, dead code, clones, coupling, cohesion and a 0-100 health score.

What you can do
  • Run a combined quality analysis covering complexity, dead code, clone detection and coupling metrics
  • Measure cyclomatic complexity of Python execution scopes
  • Detect code clones using tree edit distance and LSH acceleration
  • Find unreachable code via control flow graph analysis
  • Check class design metrics: LCOM4 cohesion and CBO coupling
  • Detect dependency injection anti-patterns such as constructor over-injection and hidden dependencies
When to use it
Useful when reviewing or refactoring a Python codebase and you want the assistant to quantify complexity, duplication, dead code and class design problems, or to produce a health score and prioritized fix list instead of reading files by hand.
Requirements
Runs as a local stdio process, typically launched with uvx (Python/uv tooling) or installed via pipx; the pyscn-mcp package is on PyPI. Optional PYSCN_CONFIG environment variable points to a .pyscn.toml file; otherwise config is discovered from .pyscn.toml or pyproject.toml in the analyzed directory. Intel macOS needs brew or go install instead of PyPI wheels.
Before you install
Reads and analyzes source code in the directories it is pointed at, so the assistant sees that code. It is analysis-only per the listed tools, but the underlying CLI can write HTML/JSON reports to disk. Configuration is read from PYSCN_CONFIG or discovered config files, so a project-supplied config can change thresholds and output behavior.

Installation

In SourceWeft

  1. Open pyscn in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

English | 日本語 | 简体中文 | Français


[pyscn]

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.

[Article] [PyPI] [Downloads] [Go] [License]

[Install Polyscan App for free]

Quick Start

bash
# Run analysis without installationuvx pyscn@latest analyze .# orpipx run pyscn analyze .

Demo

[pyscn analysis report]

Features

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:

  • 🧹 Dead code - unreachable code you can safely delete
  • 📋 Duplicate code - copy-pasted and structurally similar code worth merging (Type 1-4 clone detection)
  • 🌀 Complexity - functions and executable class suites that are hard to read and test (cyclomatic and cognitive complexity)
  • 🔥 Module and directory hotspots - per-file quality and per-directory complexity rollups for prioritizing refactors
  • 🏗️ Architecture - circular imports, layer rule violations (clean / layered / hexagonal / MVC presets), and auto-detected module communities that reveal how your code is actually structured
  • 🧩 Class design - classes that do too much or depend on too much (CBO coupling, LCOM4 cohesion)

100,000+ lines/sec • Built with Go + tree-sitter

Other Languages

pyscn is the Python analyzer of polyscan. For JavaScript, TypeScript, Go, Rust and C++, run:

bash
npx polyscan analyze .

Same five angles, same 0-100 score, one HTML report.

Polyscan for GitHub

Polyscan App files a weekly audit report as a GitHub Issue. Free for public repositories.

[Install Polyscan App for free]

AI Agent Integration

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.

Agent Skills (Recommended)

bash
uvx add-skills ludo-technologies/pyscn

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:

  1. "Analyze the code quality of the app/ directory"

  2. "Find duplicate code and help me refactor it"

  3. "Show me complex code and help me simplify it"

MCP Server (Optional)

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

bash
claude plugin marketplace add ludo-technologies/pyscnclaude plugin install pyscn-mcp@pyscn-marketplace

Manual setup for Claude Code:

bash
claude mcp add pyscn-mcp uvx -- pyscn-mcp

Cursor / Claude Desktop: add to your MCP settings (~/.config/claude-desktop/config.json or Cursor settings):

json
{  "mcpServers": {    "pyscn-mcp": {      "command": "uvx",      "args": ["pyscn-mcp"],      "env": {        "PYSCN_CONFIG": "/path/to/.pyscn.toml"      }    }  }}

Dive deeper in mcp/README.md for setup walkthroughs and docs/MCP_INTEGRATION.md for architecture details.

Installation

bash
# Install with pipx (recommended)pipx install pyscn
# Or with uvuv tool install pyscn

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, and pip cannot install pyscn on Intel Macs. Use brew install pyscn or go install github.com/ludo-technologies/pyscn/cmd/pyscn@latest instead.

Alternative installation methods

Build from source

bash
git clone https://github.com/ludo-technologies/pyscn.gitcd pyscnmake build

Go install

bash
go install github.com/ludo-technologies/pyscn/cmd/pyscn@latest

Common Commands

pyscn analyze

Run comprehensive analysis with HTML report

bash
pyscn 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 detection

pyscn check

Fast CI-friendly quality gate

bash
pyscn 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

Create configuration file

bash
pyscn init                         # Generate .pyscn.toml

💡 Run pyscn --help or pyscn <command> --help for complete options

Configuration

Create a .pyscn.toml file or add [tool.pyscn] to your pyproject.toml:

toml
# .pyscn.toml[complexity]max_complexity = 15
[dead_code]min_severity = "warning"
[output]directory = "reports"

⚙️ Run pyscn init to generate a full configuration file with all available options


Documentation

📖 pyscn documentation site — installation, rule catalog, CLI reference, configuration, output specification

For contributors: Development Guide • Architecture • Testing

Enterprise Support

For commercial support, custom integrations, or consulting services, contact us at [email protected]

License

MIT License — see LICENSE


Built with ❤️ using Go and tree-sitter

Source: README.md at commit 155305b

Tools

8

analyze_code

Comprehensive Python code quality analysis with complexity, dead code, clone detection, and coupling metrics

Parameterspathrequiredanalysesrecursiveoutput_mode

check_cohesion

Analyze class cohesion (LCOM4 - Lack of Cohesion of Methods) metrics

Parameterspathrequiredmax_resultsoutput_mode

check_complexity

Analyze cyclomatic complexity of Python execution scopes

Parameterspathrequiredmax_resultsoutput_modeshow_detailsmax_complexitymin_complexity

check_coupling

Analyze class coupling (CBO - Coupling Between Objects) metrics

Parameterspathrequiredmin_cbomax_resultsoutput_mode

detect_clones

Detect code clones using APTED tree edit distance and LSH acceleration

Parameterspathrequiredmin_linesmax_resultsoutput_modegroup_clonessimilarity_threshold

detect_di_antipatterns

Detect Dependency Injection anti-patterns in Python code (constructor over-injection, hidden dependencies, concrete dependencies, service locator)

Parameterspathrequiredmin_severityconstructor_param_threshold

find_dead_code

Find unreachable code using Control Flow Graph (CFG) analysis

Parameterspathrequiredmax_resultsoutput_modemin_severity

get_health_score

Get overall code health score (0-100) with grade and category scores

Parameterspathrequired

Version history

8
  1. v1.33.2LatestNov 8, 2026
  2. v1.33.1Oct 29, 2026
  3. v1.33.0Oct 24, 2026
  4. v1.32.5Oct 16, 2026
  5. v1.32.3Oct 3, 2026
  6. v1.32.2Sep 30, 2026
  7. v1.32.1Sep 20, 2026
  8. v1.32.0Sep 16, 2026

Score

90% 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.

  • Reached in the last 30 days25 pts
  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts