pyscn MCP Server

Structural quality checks for Python code: complexity, clones, dead code, coupling and a health score

By ludo-technologies Go Local · stdio Developer tools

45 popularity score ★ 1.1k ↓ 2.5k/mo

Connect your client

Local (PyPI)

Add in one click

Opens the app, which asks before it adds the server.

Or add it by command or config

Claude CodeTerminal
claude mcp add pyscn -- uvx pyscn-mcp
Claude Desktopclaude_desktop_config.json
{
  "mcpServers": {
    "pyscn": {
      "command": "uvx",
      "args": [
        "pyscn-mcp"
      ]
    }
  }
}
Cursor~/.cursor/mcp.json
{
  "mcpServers": {
    "pyscn": {
      "command": "uvx",
      "args": [
        "pyscn-mcp"
      ]
    }
  }
}
VS Code.vscode/mcp.json
{
  "servers": {
    "pyscn": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "pyscn-mcp"
      ]
    }
  }
}
Codex~/.codex/config.toml
[mcp_servers.pyscn]
command = "uvx"
args = ["pyscn-mcp"]
Gemini CLITerminal
gemini mcp add --scope user pyscn uvx -- pyscn-mcp

Settings 1

PYSCN_CONFIG Optional: Path to a .pyscn.toml file. Without it, the server looks upward from its working directory for .pyscn.toml or pyproject.toml.

What it does

pyscn is a Python code quality analyzer written in Go on tree-sitter, and pyscn-mcp is its MCP server. It gives an assistant the same analyses as the pyscn command line, so the assistant can check a file or directory it has just edited without a shell. You pass a path and get JSON back. The checks cover cyclomatic complexity, near-duplicate code (Type 1-4 clones), unreachable code, class coupling (CBO) and cohesion (LCOM4), dependency-injection anti-patterns, and an overall 0-100 health score with an A-F grade.

The broadest tool, analyze_code, runs every analysis by default, including module community detection. With output_mode set to "full", it also returns a context map that groups modules by their import structure, so an agent can see which files belong together in a review. The narrower tools return a summary by default and can return detailed or full output. max_results caps the findings, and 0 (the default) means no cap.

The server registers 8 tools in mcp/tools.go at v1.32.4, but the tool table in the MCP README lists only 6. It leaves out check_cohesion and detect_di_antipatterns, and the server's startup log also names only 6. Settings come from a .pyscn.toml file, or from a [tool.pyscn] section in pyproject.toml. The server finds that file by searching upward from its working directory, or loads the path given in PYSCN_CONFIG.

What it needs

RuntimePython

uv, for the uvx command its docs give. pipx or pip also install the pyscn-mcp package from PyPI. The Python code you want analysed must be on the same machine. The package ships a compiled binary, and the main README says pyscn's PyPI wheels have been built for Apple Silicon only since v1.5.1, so they do not install on Intel Macs (there it points to Homebrew or go install).

Limits

It analyses Python only. Its makers point to their separate polyscan tool for JavaScript, TypeScript, Go, Rust and C++. It reports problems but does not fix or edit code. If PYSCN_CONFIG names a file that fails to load, the server still starts with built-in defaults, but analyze_code then returns the configuration error instead of results. The README warns about this case. Without PYSCN_CONFIG, the configuration is looked up from the server's working directory, which may not be your project when a client starts it elsewhere.

Who it suits

It suits Python developers who want an assistant to measure structural quality (complexity, duplication, dead code, coupling) as it refactors, all on their own machine with no account. It reads files only and changes nothing. If your agent can already run shell commands, the makers recommend their Agent Skills, which call the pyscn CLI, and present the MCP server as optional. For codebases that are not Python, look elsewhere.

Tools 8

analyze_code
Runs all or chosen analyses on a path and returns a health summary or the full report
check_complexity
Reports cyclomatic complexity and nesting per function, with risk levels
detect_clones
Finds duplicated or structurally similar code above a similarity threshold
check_coupling
Measures coupling between classes (CBO) and flags highly coupled ones
check_cohesion
Measures class cohesion with LCOM4
find_dead_code
Finds unreachable code from control-flow analysis, filtered by severity
get_health_score
Gives a 0-100 score and A-F grade with per-category scores
detect_di_antipatterns
Flags dependency-injection problems such as too many constructor parameters or service locators

Similar servers