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.
git clone https://github.com/kursk-ye/code2flow-mcp-server.git
cd code2flow-mcp-server
# 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
python server.py
# Run with MCP Inspector
mcp dev server.py
# Install to Claude Desktop
mcp install server.py
"code2flow": {
"command": "cmd",
"args": [
"/c",
"python",
"path/to/server.py"
]
}
The server provides these MCP tools:
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())
When generating call graphs, you can use these parameters:
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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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