Skip to main content
Glama

๐ŸŽจ 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

Related MCP server: AI Charts

๐Ÿ“ 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.

A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • AI agent draws editable hand-drawn diagrams (flowchart, ER, architecture) via MCP, not static images

  • Real-time collaborative whiteboard โ€” AI agents and humans edit the same board live over MCP.

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoโ€ฆ

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vishwavinayak/code-visualizer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server