code-visualizer-mcp
Generates Excalidraw diagrams that visualize algorithm execution step-by-step, producing .excalidraw files with support for multiple data structures such as arrays, linked lists, trees, graphs, and more.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code-visualizer-mcpTrace the two-sum algorithm on the list [2,7,11,15]"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐จ 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
.excalidrawdiagram12 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
Related MCP server: AI Charts
๐ Supported Data Structures
Data Structure | Type Key | Visualization |
Array |
| Horizontal cells with index labels + pointer arrows |
Linked List |
| Nodes with next-pointers and cycle detection |
Binary Tree |
| Hierarchical layout with parent-child edges |
Graph |
| Circular layout with directed/undirected edges |
HashMap |
| Vertical key-value pair list |
Stack |
| Vertical cells with TOP label |
Queue |
| Horizontal cells with FRONT/REAR labels |
Matrix |
| 2D grid with row/col labels |
Heap |
| Binary tree + array representation |
Priority Queue |
| Same as heap |
Trie |
| Tree with character-labeled edges |
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:stdioSet 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-visualizerCLI 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.pyOutput 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 |
| Unvisited elements | โฌ |
| Currently processing | ๐ง |
| Active window/range | ๐ฆ |
| Already processed | โฌ |
| Match / answer found | ๐จ |
| Being compared | ๐ |
| Being swapped | ๐ฉท |
| Named pointers | ๐ฉ๐ช๐ |
| Result indicators | โ โ |
๐ License
MIT โ see LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
AI agent draws editable hand-drawn diagrams (flowchart, ER, architecture) via MCP, not static images
MCP server for building and testing AI agents with multi-model experimentation and insights.
Real-time collaborative whiteboard โ AI agents and humans edit the same board live over MCP.
Collaborative whiteboard MCP server โ create objects, connectors, C4 diagrams, and manage boards
Related MCP Servers
- AlicenseBqualityAmaintenanceAn MCP server that generates beautiful Excalidraw architecture diagrams with perfect auto-layout, stateful editing, and architecture-aware component styling.26150MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to programmatically create and manage flowcharts, ERDs, and swimlane diagrams. It provides tools for manipulating diagram structures, performing auto-layouts, and exporting to Mermaid or Markdown formats.2MIT
- AlicenseAqualityBmaintenanceAn MCP server for Excalidraw diagram creation and headless rendering, enabling interactive canvas editing and automated SVG/PNG export via Playwright.41MIT
- AlicenseAqualityDmaintenanceMCP server that converts Mermaid diagrams to styled Excalidraw files, saving them directly to disk without token overhead.2MIT