pyscn
Lets your AI agent analyze Python code for dead code, duplicates, complexity, bad structure and an overall health score.
1.1k stars on GitHubby ludo-technologiesLicense MITUpdated 21 days ago
How to install
This MCP is local: it runs on your computer.
It works in apps installed on your PC (Claude Desktop, Claude Code, Cursor, VS Codeβ¦). Choose your app:
Paste in the terminal:
claude mcp add pyscn -- uvx pyscn-mcp
What to fill in
| Name | What it is | Required |
|---|---|---|
PYSCN_CONFIG | Path to a .pyscn.toml configuration file. Defaults to the usual config discovery (.pyscn.toml, then pyproject.toml) starting from the analyzed directory. | No |
Ready! Now test it
Restart the app and paste one of these requests in the chat:
Analyze the code quality of the app/ directory.
Find duplicate code and help me refactor it.
What it is
pyscn is a code quality analyzer for Python. One command scores the whole codebase from 0 to 100 with an A-F grade and builds an HTML report showing what to fix first. The bundled pyscn-mcp server gives AI agents the same analyses as MCP tools.
What it can do
- Find dead code you can safely delete
- Detect duplicate and similar code (clone types 1-4)
- Measure cyclomatic and cognitive complexity
- Spot circular imports and layer rule violations
- Check class design with coupling and cohesion measures
pyscn check: a fast pass or fail check for CI
When to use
- βΊWhen you use AI to write Python and want to keep the code maintainable
- βΊWhen you want to know which duplicate code to merge first
- βΊWhen you want a quality gate that fails the build on high complexity
What you need
Skills that pair well
MCP or skill?
The MCP gives the agent the hands. The skill teaches the right way to use them. Together, the result is better and uses fewer tokens.
codebase-refactoringHelps your agent improve a codebase's health by fixing duplicated code, removing dead code and simplifying the most complex files, in that order.agent-analyze-code-qualityHelps your agent review code for quality, finding code smells, technical debt and refactoring ideas without changing the files.code-healthHelps your agent score code health file by file, find the riskiest files and pick what to refactor next, using Repowise analysis.Frequently asked questions
Is it free and open source?
Yes. It is released under the MIT License.
Does it only check Python?
pyscn is the Python analyzer of polyscan. For JavaScript, TypeScript, Go, Rust and C++, the readme says to run npx polyscan analyze.
How fast is it?
The readme says it handles 100,000+ lines per second and is built with Go and tree-sitter.
Is the MCP server required?
No. The readme calls the MCP server optional and recommends Agent Skills as the main way to use it with an agent.
How do I set thresholds?
Create a .pyscn.toml file with pyscn init, or add [tool.pyscn] to pyproject.toml.
Can I use it in CI?
Yes. pyscn check is a CI-friendly gate with flags such as --max-complexity and --max-cycles.
If it does not work
- βΊOn an Intel Mac, install with brew install pyscn or go install, since uvx and pipx cannot install it there.
- βΊCheck that uvx is installed, because the MCP server starts with uvx pyscn-mcp.
- βΊSet PYSCN_CONFIG to your .pyscn.toml path if the server ignores your settings.
5 new skills a week. 1 minute to read.