Pyscn logo

Pyscn

MCP tools for analyzing Python complexity, dead code, clones, dependencies, architecture, and code health.

Install Pyscn

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "pyscn": {
      "command": "uvx",
      "args": [
        "pyscn-mcp"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Install not yet sandbox-tested— we haven't run this command through our automated sandbox yet. Not a red flag; we're working through the catalog.

Overview

pyscn MCP server exposes Python code-quality analyses as MCP tools for agents such as Claude Code, Cursor, ChatGPT, and Claude Desktop. It runs the same checks as the pyscn command-line analyzer, covering complexity, dead code, duplicate code, dependencies, architecture, class design, and health scoring. Reach for it when an agent needs structured codebase analysis before refactoring or reviewing a Python project. The bundled server runs through uvx and can read a project-specific .pyscn.toml configuration.

Use cases

  • Analyze a Python package before a refactor
  • Find duplicate functions for consolidation
  • Review circular imports and layer violations
  • Identify complex code that needs simplification
  • Run agent-assisted quality checks in CI

Key features

  • Complexity analysis with cyclomatic and cognitive metrics
  • Dead-code and Type 1–4 clone detection
  • Dependency, architecture, and module-community analysis
  • Class coupling and cohesion metrics
  • 0–100 health score with A–F grade
  • MCP integration through the pyscn-mcp command

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

51/51 checks healthy over the last 63d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 2d ago via OSV.dev · pyscn-mcp (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars1.1kStargazers on the source repository.
Last commitTodayMost recent push to the default branch.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How Pyscn works

What pyscn does

pyscn MCP server gives coding agents access to structural analysis for Python projects. Its analyses cover several dimensions of maintainability:

  • Complexity at function and executable class-suite level, including cyclomatic and cognitive measures
  • Unreachable or otherwise dead code
  • Copy-pasted and structurally similar code, including Type 1 through Type 4 clone detection
  • Module and directory hotspots for prioritizing refactoring
  • Circular imports, dependency relationships, layer-rule violations, and detected module communities
  • Class coupling and cohesion through CBO and LCOM4 metrics

The analyzer combines these findings into a 0–100 health score with an A–F grade. The underlying pyscn CLI can also produce HTML and JSON reports, while its check command provides a faster quality gate for CI workflows.

How it works

The MCP package is invoked as the pyscn-mcp command. A compatible client starts it over the standard input/output MCP transport, and the agent can then request the available analyses against a Python project. The server exposes the same analysis family used by the command-line application rather than introducing a separate ruleset.

pyscn is implemented with Go and tree-sitter. The command-line analyzer supports running all checks together or selecting areas such as complexity, dependencies, and dead code. Community detection can also be skipped when it is not needed.

Setup and configuration

Install the command through uvx as part of the client configuration. For Claude Code, the direct setup is:

Terminal
claude mcp add pyscn-mcp uvx -- pyscn-mcp

Claude Code also has a plugin installation path that configures the MCP server and the related Agent Skills together. Cursor and Claude Desktop use an MCP settings entry such as:

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

PYSCN_CONFIG points the server at a configuration file. pyscn can create a starter file with pyscn init; configuration may also live in .pyscn.toml or under [tool.pyscn] in pyproject.toml. Settings include complexity thresholds, dead-code severity, and report output directories.

Tools and capabilities

Use the MCP server for agent-directed health checks, refactoring investigations, architecture reviews, and CI-oriented reporting. The companion Agent Skills package can teach supported agents when to run health, refactoring, architecture, and CI analyses, but the MCP server itself provides the analysis interface.

The underlying CLI supports JSON output, HTML output, combined JSON and HTML generation, selected analysis groups, and configurable checks such as maximum complexity and allowed dependency cycles. These capabilities make it possible to use the server for both exploratory code review and repeatable quality checks.

Limitations and notes

pyscn focuses on Python. The related Polyscan project provides analysis for JavaScript, TypeScript, Go, Rust, and C++, but those languages are outside this server’s scope.

On Intel Macs, PyPI wheels are unavailable. Installation on macOS x86_64 requires Homebrew or building through go install; Apple Silicon installation can use the documented Python tooling. The project is released under the MIT License.

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Pyscn

pyscn is an MCP server that connects AI coding agents to Python code-quality analysis. Its main tools cover complexity, dead code, duplicate code, dependencies, architecture, class design, and health scoring, using the same analysis family as the pyscn command-line tool for project reviews and refactoring.

Install it through an MCP client with `uvx` and the `pyscn-mcp` command. For Claude Code, run `claude mcp add pyscn-mcp uvx -- pyscn-mcp`; Cursor and Claude Desktop can use an MCP settings entry with `command` set to `uvx` and `args` set to `["pyscn-mcp"]`.

Yes, pyscn works with Cursor through its MCP settings. Add a server named `pyscn-mcp`, set the command to `uvx`, pass `pyscn-mcp` as the argument, and optionally set `PYSCN_CONFIG` to the path of a `.pyscn.toml` configuration file.

pyscn analyzes Python code. JavaScript, TypeScript, Go, Rust, and C++ analysis is provided by the related Polyscan project rather than by the pyscn analyzer.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewPyscn AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/pyscn?style=directory)](https://allmcps.com/mcp/pyscn)
HTML Embed
<a href="https://allmcps.com/mcp/pyscn"><img src="https://allmcps.com/api/badge/pyscn?style=directory" alt="Pyscn on AllMCPs" /></a>