code-visualizer-mcp

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.

Category
Visit Server

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.

Python License MCP

Code Visualizer Output


โœจ Features

  • Single-file traces โ€” All iterations in ONE .excalidraw diagram
  • 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

  1. Open Cursor Settings > Features > MCP.
  2. Click + Add New MCP Server.
  3. Set Name: code-visualizer, Type: stdio
  4. 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

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.

Official
Featured
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured