Skip to main content

A Model Context Protocol server for cognitive complexity analysis using complexipy

Project description

Complexipy MCP Server

A Model Context Protocol (MCP) server that wraps complexipy to provide cognitive complexity analysis for Python codebases. This server uses the complexipy Python API for accurate and robust analysis.

Features

  • Directory Scanning: Recursively analyze all .py files in a directory and filter by complexity threshold.
  • File Scanning: Analyze a single Python file.
  • Data Processing: Uses pandas for efficient data filtering and sorting.
  • Clean Output: Returns JSON formatted results (list of objects).
  • No Emojis: Pure data output suitable for machine consumption.
  • Stdio Transport: Uses standard input/output for communication, making it compatible with most MCP clients.

Installation & Usage

Quick Start

You can run the server directly using uvx (no installation required):

uvx complexipy-mcp

Configuration for Claude Desktop

Add the following configuration to your MCP client settings (e.g., claude_desktop_config.json):

{
  "mcpServers": {
    "complexipy": {
      "command": "uvx",
      "args": [
        "complexipy-mcp"
      ]
    }
  }
}

Local Development

  1. Clone the repository.
  2. Install dependencies:
    uv sync
    
  3. Run the server locally:
    uv run complexipy-mcp
    

Local Configuration for Claude Desktop

If you are developing locally, point the configuration to your local setup:

{
  "mcpServers": {
    "complexipy": {
      "command": "uv",
      "args": [
        "--directory",
        "/ABSOLUTE/PATH/TO/complexipy-mcp",
        "run",
        "complexipy-mcp"
      ]
    }
  }
}

Tools

scan_directory

Scans a directory for files exceeding a cognitive complexity threshold.

  • Arguments:
    • directory_path (string): Absolute path to the directory to scan.
    • threshold (integer): Complexity limit (default: 15).
  • Returns: JSON string containing a list of files that exceed the threshold.
    [
      {
        "file_path": "/abs/path/to/file.py",
        "complexity": 25,
        "functions": [
          {
            "name": "function_name",
            "complexity": 10,
            "line_start": 5,
            "line_end": 15
          }
        ],
        "status": "exceeds_threshold"
      }
    ]
    

scan_file

Scans a single file for cognitive complexity.

  • Arguments:
    • file_path (string): Absolute path to the file.
    • threshold (integer): Complexity limit (default: 15).
  • Returns: JSON string containing the result if it exceeds the threshold.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

complexipy_mcp-0.1.1.tar.gz (96.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

complexipy_mcp-0.1.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file complexipy_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: complexipy_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 96.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.12

File hashes

Hashes for complexipy_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 726ea49fb6126d07fdf81f12cd211a87aa88c0d585056dc00e3a3084a84e6dc1
MD5 f449a3474e6d9883d0a59ebba3df0cc2
BLAKE2b-256 d5a3a3d0619947bc9b3f65284dc5033cd18a0455f1ae5755cc3be61aa5da6a5d

See more details on using hashes here.

File details

Details for the file complexipy_mcp-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for complexipy_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0561b12e43aa03d1153b30bbda0ab2ace76ad6874d4303742a750a832b49bbe
MD5 ebf01ed10ea11741e54a359de2d33964
BLAKE2b-256 a45c5fc0fa8d4b64851644d5033a0caee7fcf6749d3ba570ae69146c9ae8165e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page