code-visualizer-mcp
An MCP server that generates Excalidraw diagrams to visualize algorithm execution step-by-step, supporting multiple data structures and integration with AI assistants.
README
๐จ Code Visualizer MCP
An MCP server that generates Excalidraw diagrams to visualize algorithm execution step-by-step. Give it your code + an example input, and get a single .excalidraw file showing every iteration.

โจ Features
- Single-file traces โ All iterations in ONE
.excalidrawdiagram - 12 data structures โ Array, LinkedList, Tree, Graph, HashMap, Stack, Queue, Matrix, Heap, Trie, Priority Queue, Set
- Dark-mode palette โ YouTube-friendly colors with semantic highlighting
- MCP + CLI โ Use via AI assistants (Claude, Cursor, Gemini) or command line
๐ Supported Data Structures
| Data Structure | Type Key | Visualization |
|---|---|---|
| Array | array |
Horizontal cells with index labels + pointer arrows |
| Linked List | linkedlist |
Nodes with next-pointers and cycle detection |
| Binary Tree | tree |
Hierarchical layout with parent-child edges |
| Graph | graph |
Circular layout with directed/undirected edges |
| HashMap | hashmap |
Vertical key-value pair list |
| Stack | stack |
Vertical cells with TOP label |
| Queue | queue |
Horizontal cells with FRONT/REAR labels |
| Matrix | matrix |
2D grid with row/col labels |
| Heap | heap |
Binary tree + array representation |
| Priority Queue | priority_queue |
Same as heap |
| Trie | trie |
Tree with character-labeled edges |
| Set | set |
Rounded-rectangle collection |
๐ Quick Start
Prerequisites
- Python 3.10+
- uv (recommended) or pip
Installation
git clone https://github.com/your-username/code-visualizer-mcp.git
cd code-visualizer-mcp
uv sync
๐ Client Integration & Ways to Use
This MCP server is standard Model Context Protocol compliant and works with a variety of AI assistants and IDEs:
1. Claude Desktop
Add to claude_desktop_config.json (~/Library/Application Support/Claude/claude_desktop_config.json on macOS or %APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"code-visualizer": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/code-visualizer-mcp",
"run",
"code-visualizer"
]
}
}
}
2. Google Antigravity (AGY)
Add to your Antigravity MCP config file (~/.gemini/antigravity/mcp_config.json or your project settings):
{
"mcpServers": {
"code-visualizer": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/code-visualizer-mcp",
"run",
"code-visualizer"
]
}
}
}
3. Cursor IDE
- Open Cursor Settings > Features > MCP.
- Click + Add New MCP Server.
- Set Name:
code-visualizer, Type:stdio - Set Command:
uv --directory /absolute/path/to/code-visualizer-mcp run code-visualizer
4. VS Code (Cline / Roo Code / Continue)
Add to your extension's MCP settings file (e.g. cline_mcp_settings.json):
{
"mcpServers": {
"code-visualizer": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/code-visualizer-mcp",
"run",
"code-visualizer"
]
}
}
}
5. MCP Inspector (Interactive Testing)
To test and debug tools directly in a browser UI without an AI assistant:
npx @modelcontextprotocol/inspector uv --directory /absolute/path/to/code-visualizer-mcp run code-visualizer
CLI Usage
# Generate an array diagram
uv run python examples/generate_cli.py array \
--title "Two Sum" \
--data "2,7,11,15" \
--highlights "0:visited,1:found" \
--pointers "i:1"
# Generate a full algorithm trace
uv run python examples/sliding_window_maximum.py
Output files are saved to the output/ directory as .excalidraw files. Open them at excalidraw.com or in the VS Code Excalidraw extension.
๐๏ธ Project Structure
code-visualizer-mcp/
โโโ pyproject.toml # Project config, dependencies, entry points
โโโ LICENSE
โโโ README.md
โ
โโโ src/code_visualizer/ # Main package
โ โโโ __init__.py
โ โโโ server.py # MCP server entry point (FastMCP)
โ โโโ renderer.py # Excalidraw JSON file writer
โ โ
โ โโโ primitives/ # Low-level element factories
โ โ โโโ elements.py # make_rectangle, make_ellipse, make_arrow, ...
โ โ โโโ colors.py # Semantic color palette (PALETTE, get_color)
โ โ โโโ styles.py # Style presets (CELL_STYLE, NODE_STYLE, ...)
โ โ
โ โโโ layout/ # Spatial position calculators
โ โ โโโ linear.py # Arrays, matrices, stacks, queues, hashmaps, sets
โ โ โโโ tree_layout.py # Binary trees, heaps, tries
โ โ โโโ graph_layout.py # Circular graph layout
โ โ
โ โโโ tools/ # MCP tool implementations
โ โโโ visualize_array.py # Array + hashmap diagrams
โ โโโ visualize_linkedlist.py
โ โโโ visualize_tree.py
โ โโโ visualize_graph.py
โ โโโ visualize_trace.py # โญ Multi-step trace (primary tool)
โ
โโโ tests/ # Test suite
โ โโโ conftest.py # Shared fixtures
โ โโโ test_primitives.py # Element factory tests
โ โโโ test_tools.py # Tool integration tests
โ
โโโ examples/ # Usage examples
โ โโโ generate_cli.py # CLI diagram generator
โ โโโ sliding_window_maximum.py # Full algorithm trace example
โ
โโโ docs/
โ โโโ architecture.md # System architecture & workflow guide
โ
โโโ output/ # Generated .excalidraw files
๐งช Running Tests
uv run pytest -v
๐จ Color Palette
| Color Name | Use Case | Preview |
|---|---|---|
default |
Unvisited elements | โฌ |
current |
Currently processing | ๐ง |
highlighted |
Active window/range | ๐ฆ |
visited |
Already processed | โฌ |
found |
Match / answer found | ๐จ |
comparing |
Being compared | ๐ |
swapping |
Being swapped | ๐ฉท |
pointer_a / pointer_b / pointer_c |
Named pointers | ๐ฉ๐ช๐ |
success / error |
Result indicators | โ โ |
๐ License
MIT โ see LICENSE.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.