analyze_code
Comprehensive Python code quality analysis with complexity, dead code, clone detection, and coupling metrics
path必填analysesrecursiveoutput_mode
io.github.ludo-technologies由 GitHub 账号 ludo-technologies 发布v1.33.2更新于 Nov 8, 2026
Python code analysis for AI agents: complexity, dead code, clones, coupling, and a health score.
把 pyscn 的 Python 代码质量分析(复杂度、死代码、重复代码、耦合与健康评分)以 MCP 工具形式提供给编码助手。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
参照 仓库 中的启动说明。
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
来源:README.md,提交 155305b
Comprehensive Python code quality analysis with complexity, dead code, clone detection, and coupling metrics
path必填analysesrecursiveoutput_modeAnalyze class cohesion (LCOM4 - Lack of Cohesion of Methods) metrics
path必填max_resultsoutput_modeAnalyze cyclomatic complexity of Python execution scopes
path必填max_resultsoutput_modeshow_detailsmax_complexitymin_complexityAnalyze class coupling (CBO - Coupling Between Objects) metrics
path必填min_cbomax_resultsoutput_modeDetect code clones using APTED tree edit distance and LSH acceleration
path必填min_linesmax_resultsoutput_modegroup_clonessimilarity_thresholdDetect Dependency Injection anti-patterns in Python code (constructor over-injection, hidden dependencies, concrete dependencies, service locator)
path必填min_severityconstructor_param_thresholdFind unreachable code using Control Flow Graph (CFG) analysis
path必填max_resultsoutput_modemin_severityGet overall code health score (0-100) with grade and category scores
path必填已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
# 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"