Content
# Code2Flow MCP Server
This is a project that wraps the code2flow command-line tool as an MCP (Model Context Protocol) server. It allows AI applications to generate and access code call graphs through the standardized MCP protocol.
## Features
- Analyzes source code and generates call graphs
- Supports multiple programming languages (Python, JavaScript, Ruby, PHP)
- Provides services via the MCP protocol, making it easy to integrate with AI applications
- Outputs images in PNG format
- Offers version checking and code complexity analysis features
## Installation Requirements
- Python 3.7+
- Windows 11 or other supported operating systems
- PowerShell or other command-line terminals
- The code2flow command-line tool must be installed
## Installation Steps
1. Clone this repository
```
git clone https://github.com/kursk-ye/code2flow-mcp-server.git
cd code2flow-mcp-server
```
2. Create and activate a virtual environment (recommended)
```
python -m venv venv
.\venv\Scripts\Activate.ps1 # In PowerShell
```
3. Install dependencies
```
pip install -r requirements.txt
```
4. Install the code2flow command-line tool
```
pip install code2flow
```
## Usage
### Run Directly with Python
1. Start the MCP server
```
python server.py
```
### Run with MCP Tools
1. Use the MCP Inspector tool
```
mcp dev server.py
```
2. Install to Claude Desktop
```
mcp install server.py
```
3. Add to Cursor MCP configuration
```json
"code2flow": {
"command": "cmd",
"args": [
"/c",
"python",
"path/to/server.py"
]
}
```
## Available Tools
The server provides the following MCP tools:
1. `generate_call_graph` - Generates a code call graph
2. `check_code2flow_version` - Checks the code2flow version
3. `analyze_code_complexity` - Analyzes code complexity
## Available Resources
The server provides the following MCP resources:
1. `help://code2flow` - Help documentation
2. `languages://supported` - List of supported languages
3. `call-graph://imageID` - Generated call graph image
### Example (Using Python MCP Client)
```python
import asyncio
from mcp.client import MCPClient
async def main():
# Connect to the server
client = MCPClient("http://localhost:8000")
# Create a new session
session = await client.create_session()
# Call the tool to 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
The following parameters are supported when generating a call graph:
- `source_paths`: A list of paths to the source code files or directories to analyze
- `output_path`: (optional) The path for the output file
- `language`: (optional) The source code language (python, js, ruby, php)
- `exclude`: (optional) A list of file patterns to exclude
- `include`: (optional) A list of file patterns to include
## File Structure
- `server.py` - Main server code
- `mcp_client_example.py` - Client example code
- `test_server.py` - Test code
- `requirements.txt` - Dependency file
## License
MIT
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.
git
A Model Context Protocol server for Git automation and interaction.