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.0.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.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: complexipy_mcp-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 c01cdad486659093db25da8eb73e3a98df3b02c847c23ad33165bd599a6160c1
MD5 a54ed05378e5112e65ab2d98c8be048b
BLAKE2b-256 cc4af9977ce8981c4d2cd25da922125d5643aac1e95490db25daadb14f8af602

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for complexipy_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8caa15a301c0c4d10e6b3e482af408548e42bae5604ac1f5c1786d857c4ae74a
MD5 683b52083800eda7f7810963b3ad6ccb
BLAKE2b-256 06a69c3dba74163dacb6c43f5b3cc25fa3c9983abf9db6cbec86c66aa640006f

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