Code2Flow MCP server

Generates visual code flow diagrams from source code to help understand program structure, execution paths, and architectural relationships without manual diagramming.
Back to servers
Setup instructions
Provider
kursk-ye
Release date
Mar 19, 2025
Language
Python
Stats
2 stars

The Code2Flow MCP server allows AI applications to generate and access code call graphs through the Model Context Protocol (MCP). It analyzes source code from multiple programming languages and outputs visualization diagrams in PNG format.

Installation Requirements

  • Python 3.7+
  • Windows 11 or other supported operating systems
  • PowerShell or other command line terminal
  • code2flow command line tool

Installation Steps

Clone the Repository

git clone https://github.com/kursk-ye/code2flow-mcp-server.git
cd code2flow-mcp-server

Set Up Environment

# Create and activate virtual environment (recommended)
python -m venv venv
.\venv\Scripts\Activate.ps1  # For PowerShell

# Install dependencies
pip install -r requirements.txt

# Install code2flow command line tool
pip install code2flow

Running the Server

Direct Python Execution

python server.py

Using MCP Tools

# Run with MCP Inspector
mcp dev server.py

# Install to Claude Desktop
mcp install server.py

Add to Cursor MCP Configuration

"code2flow": {
  "command": "cmd",
  "args": [
    "/c",
    "python",
    "path/to/server.py"
  ]
}

Available Tools

The server provides these MCP tools:

  • generate_call_graph - Creates code call graphs
  • check_code2flow_version - Checks the installed code2flow version
  • analyze_code_complexity - Analyzes code complexity

Available Resources

  • help://code2flow - Help documentation
  • languages://supported - List of supported languages
  • call-graph://imageID - Generated call graph images

Usage Examples

Using Python MCP Client

import asyncio
from mcp.client import MCPClient

async def main():
    # Connect to server
    client = MCPClient("http://localhost:8000")
    
    # Create new session
    session = await client.create_session()
    
    # Generate a call graph
    result = await session.call_tool("generate_call_graph", {
        "source_paths": ["path/to/your/code"],
        "language": "python"
    })
    
    # Get resource ID
    print(result)
    
    # Check code2flow version
    version_info = await session.call_tool("check_code2flow_version")
    print(version_info)
    
    # Analyze code complexity
    complexity = await session.call_tool("analyze_code_complexity", {
        "source_path": "path/to/your/code",
        "language": "python"
    })
    print(complexity)

if __name__ == "__main__":
    asyncio.run(main())

Configuration Options

When generating call graphs, you can use these parameters:

  • source_paths: List of source code files or directories to analyze
  • output_path: (Optional) Path for the output file
  • language: (Optional) Source code language (python, js, ruby, php)
  • exclude: (Optional) List of file patterns to exclude
  • include: (Optional) List of file patterns to include

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "code2flow" '{"command":"cmd","args":["/c","python","path/to/server.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "code2flow": {
            "command": "cmd",
            "args": [
                "/c",
                "python",
                "path/to/server.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "code2flow": {
            "command": "cmd",
            "args": [
                "/c",
                "python",
                "path/to/server.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later