Skip to main content
Glama

visio-mcp

An MCP server that drives Microsoft Visio desktop via COM automation to draw diagrams for you: flowcharts, block diagrams, and Azure/AWS architecture diagrams using the official stencils. Claude (or any MCP client) drops real Visio masters, glues dynamic connectors, runs Visio's auto-layout, and exports a PNG of the page so the AI can see the result and iterate.

Runs on Windows only (it automates the Visio desktop app through COM). The codebase is developed and unit-tested cross-platform, but the server must run on a Windows machine with Visio installed.

Requirements

  • Windows 10/11

  • Microsoft Visio desktop (any recent version; must be installed and activated)

  • Python 3.10+ and uv

  • Claude Code (or Claude Desktop) on the same machine

Related MCP server: VisioMCP

Setup (on the Windows machine)

git clone <this repo> C:\tools\visio_mcp   # or copy the folder
cd C:\tools\visio_mcp
uv sync

Azure / AWS icons

Visio ships them built-in — no downloads needed. Visio 16 / Microsoft 365 installs include ~130 stencils (Azure, AWS, networking, and more) under <Office install>\root\Office16\Visio Content\<locale>\ — e.g. AZURESTORAGE_U.VSSX, AWSSTORAGE_U.VSSX. They resolve by bare filename, so open_stencil("AZURESTORAGE_U.VSSX") (or a fuzzy match like open_stencil("azurestorage")) works out of the box. visio_status lists them in builtin_cloud_stencils, and there are also dedicated Azure Diagrams / AWS Diagrams templates (Azure, AWS) that create_document can start from.

Some masters go by different names than you might guess — the server auto-resolves common ones (Private Endpoint → Private Link, Amazon S3 → Bucket with Objects, IAM → Security Identity and Compliance) and tells you when a concept is a container rather than a master (subnets, VNets, VPCs → add_container).

For older Visio versions or extra vendor packs, download stencils and unzip the .vssx files into your My Shapes folder (visio_status reports the exact path, typically Documents\My Shapes):

open_stencil("azure") fuzzy-matches any .vssx/.vss file under My Shapes, and find_masters("virtual machine") searches inside whatever is open.

Custom icons (no built-in master)

A few concepts have no Visio master at all — notably the newer Azure Subnet glyph. For these the server keeps a local icon folder: drop labeled image files (subnet.svg, private-endpoint.png, …) into it and they become first-class, reusable icons.

  • list_local_icons reports the folder path and its contents. It defaults to ~/.visio-mcp/icons and can be moved with the VISIO_MCP_ICONS_DIR environment variable.

  • The file name without its extension is the label. Labels are surfaced by find_masters (marked stencil: "(local icon)") and placed with drop_shape("subnet", x, y) — real Visio masters always take precedence; the local icon is the fallback before the "no master" error.

  • For a one-off (or a direct image URL) you can still import_image(source, x, y) without saving a file. Icon-gallery web pages (e.g. az-icons.com) are single-page apps that return HTML rather than the image, so download the file (its Download button) or pass a direct raw image URL.

Icons are yours to supply — nothing is bundled — so respect each vendor's icon terms of use (e.g. Microsoft's / AWS's) for anything you place there.

Smoke test

Verifies the full pipeline end-to-end (launches Visio, builds a small styled flowchart, auto-lays it out, exports a PNG, saves/reopens the .vsdx):

uv run python scripts/smoke_test.py

Register with Claude Code

claude mcp add visio -- uv --directory C:\tools\visio_mcp run visio-mcp

Then ask Claude something like: "Draw a 5-step login flowchart in Visio and show me the result."

Tools

Tool

Purpose

visio_status

Version, open docs/stencils, My Shapes path; launches Visio if needed

create_document

New drawing, optionally from a template (BASFLO_U.VSTX = basic flowchart)

open_document / save_document

Open/save .vsdx files

export_page_png

Export the page as PNG and return the image for visual iteration

open_stencil

Open a stencil by built-in name, path, or fuzzy My Shapes match

find_masters

Search droppable shapes across open stencils

drop_shape / drop_shapes

Drop masters at (x, y) inches with optional text/size

update_shape / style_shape / delete_shapes

Edit text/position/size, colors/fonts, delete

connect_shapes

Glued dynamic connector: label, arrows, right-angle/straight/curved routing, solid/dashed/dotted patterns, weight, color

add_container / container_members

Wrap shapes in real Visio containers (VNets, VPCs, subnets, trust zones) — members move with the container

drop_text

Text-only labels (no border/fill) for titles, legends, and callouts

set_page_size

Resize the page (or fit to contents) — do this before wide architecture diagrams

pages

List/add/activate pages

auto_layout

Visio's automatic layout (flowchart top-bottom/left-right, tree, radial, circular)

get_page_state

Everything on a page: ids, masters, positions, text, connector endpoints, container membership

Coordinate system: inches, origin at the page bottom-left, y grows upward, and drop coordinates are the shape's center. Rough placement is fine — finish with auto_layout. The default page is US Letter (8.5×11): call set_page_size first for wide architecture diagrams, since PNG export crops to the page bounds.

Architecture

Claude (stdio) → FastMCP server (asyncio; no COM imports)
                    ↓ submits callables
                 ComWorker — single STA thread owns ALL COM objects
                    ↓
                 VisioClient — the only module that touches win32com
                    ↓
                 Visio.Application

COM objects are apartment-threaded, so every COM call is funneled through one dedicated STA worker thread (runtime.py); tool bodies just await results. This also serializes concurrent tool calls safely.

Development (any OS)

Unit tests run against a duck-typed fake of the Visio COM surface — no Windows needed:

uv sync
uv run pytest

Troubleshooting

Symptom

Fix

"Visio is busy — close any open dialog"

A modal dialog is open in the Visio window; close it and retry

"Visio desktop is not installed"

Install Visio desktop; Visio for the web cannot be automated

"Could not open a stencil matching …"

Download the stencil pack into Documents\My Shapes, then retry; use visio_status to confirm the path

First run shows Visio setup/license dialogs

Start Visio manually once, dismiss the dialogs, then retry

Roadmap

  • Agent skills encoding Azure/AWS diagram conventions (zones/containers, brand colors, icon naming)

  • Optional HTTP transport to drive a Windows Visio box from another machine

  • A scripts/install_stencils.py helper that downloads stencil packs into My Shapes

Available Tools

23 tools
add_containerA

Wrap existing shapes in a real Visio container (for VNets, VPCs, subnets, resource groups, trust zones). The container is sized around its members plus padding, and members MOVE WITH the container afterwards. Nest zones by creating inner containers first, then outer ones.

Args: label: Container heading text. member_ids: shape_ids to place inside. master: Optional container style name from Visio's built-in container stencil (defaults to the first available style).

To recolor the container afterwards (e.g. brand colors per zone), use style_shape on the returned shape_id — theme guards are overridden.

Inputs: label (required), member_ids (required), page, master, +1 more.

auto_layoutB

Run Visio's automatic layout on the page — arranges shapes and re-routes connectors. Great after dropping shapes at rough positions. 'flowchart_tb' = top-to-bottom flowchart, '_lr' = left-to-right.

Inputs: page, style, spacing_in, resize_page.

badge_containerA

Badge a container (zone) with a small header icon — e.g. the VNet icon on a VNet container, or the Subnet/Subscription icon on those boundaries.

Placement is deterministic: the icon is dropped just inside the chosen corner of the container (computed from the container's bounds — no manual coordinate math) and added as a container member so it moves with the zone. icon resolves to a built-in Visio master first (e.g. 'Virtual Networks'), then to a labeled image in the local icon folder (e.g. a saved 'subnet.svg' — see list_local_icons); errors with guidance when neither exists. Returns the badge's shape_id.

Inputs: icon (required), container_id (required), page, corner, +1 more.

connect_shapesA

Connect two shapes with a dynamic connector glued to both (Visio auto-picks the best sides and re-routes when shapes move).

Args: label: Optional text on the connector (e.g. 'Yes' / 'No'). route: 'right_angle' (default), 'straight', or 'curved'. line_pattern: 'dashed'/'dotted' are the convention for control-plane, auth, or reference flows in architecture diagrams. line_weight_pt: Thicker lines (e.g. 2) suit peering/trust boundaries. line_color: Hex like '#808080'.

Inputs: to_id (required), from_id (required), page, label, +6 more.

container_membersB

Add shapes to or remove shapes from an existing container.

Inputs: action (required), member_ids (required), container_id (required), page.

create_documentA

Create a new drawing document in Visio.

Args: template: Visio template name or absolute path. Examples: 'BASFLO_U.VSTX' (Basic Flowchart, US units) or bare 'BASFLO' (units suffix added from measurement). Omit for a blank drawing. measurement: 'us' (inches) or 'metric' — used when template has no _U/_M suffix.

Inputs: template, measurement.

delete_shapesB

Delete shapes (or connectors) by id.

Inputs: shape_ids (required), page.

drop_shapeB

Drop one master onto the page. (x, y) is the shape CENTER in inches from the bottom-left. Returns the shape_id used by other tools.

Inputs: x (required), y (required), master (required), page, +4 more.

drop_shapesA

Drop many masters in one call (preferred when building a diagram). Executed in a single undo scope. Returns a shape_id per item, in order.

Inputs: shapes (required), page.

drop_textA

Drop a text-only label (no border, no fill) — for diagram titles, legends, and callouts. (x, y) is the CENTER in inches. Size is estimated from the text if omitted. Auto-layout ignores unconnected text shapes.

Inputs: x (required), y (required), text (required), bold, +6 more.

export_page_pngA

Export a page as PNG and RETURN THE IMAGE so you can visually inspect the diagram. Use this after dropping/connecting/layout to verify the result and iterate.

Args: path: Output .png path; omit for an auto-named temp file. page: Page name; defaults to the active page.

Inputs: page, path.

find_mastersA

Search masters (droppable shapes) in the open stencils by name substring. Omit query to list everything (capped at 100). Matching custom icons from the local icon folder are included too, marked with stencil '(local icon)'.

Inputs: query, stencil.

get_page_stateA

List everything on a page: shape ids, master names, positions (inches, center), sizes, text, connector endpoints (from_id/to_id), and container membership (container_ids). Call this to (re)discover shape ids, e.g. after open_document.

Inputs: page.

import_imageA

Insert an external image (SVG, PNG, JPG, EMF, ...) onto the page as a shape — for custom icons that have NO Visio master (e.g. the newer Azure 'Subnet' glyph) or vendor logos.

Args: source: a LOCAL file path OR a direct http(s) IMAGE URL. A URL must point at the raw image bytes; icon web pages (single-page-app galleries such as az-icons.com) return HTML and are rejected with guidance — download the file in the browser and pass its path. x, y: shape CENTER in inches from the bottom-left. width_in / height_in: size in inches. Give just one to scale the other automatically and preserve the image's aspect ratio; omit both to keep the image's native size.

Prefer built-in masters (drop_shape) when Visio has the icon; use this for the gaps. Returns the shape_id.

Inputs: x (required), y (required), source (required), page, +2 more.

list_local_iconsA

List the local custom-icon folder and the labeled image files in it.

Users manually download icons (e.g. from az-icons.com) and save them into this folder; each file's name without its extension is its label. Labels are discoverable via find_masters and can be placed with drop_shape('', x, y) when Visio has no built-in master. The folder defaults to ~/.visio-mcp/icons and moves with the VISIO_MCP_ICONS_DIR environment variable.

Inputs: no named parameters.

open_documentB

Open an existing Visio file (.vsdx/.vsd) for viewing or editing.

Inputs: path (required).

open_stencilA

Open a stencil (shape library) so its masters can be dropped.

Accepts a built-in name ('BASFLO_U.VSSX' basic flowchart, 'PERIPH_U.VSSX' peripherals...), an absolute path, or a fuzzy name matched against files in the My Shapes folder (where downloaded Azure/AWS stencil packs live).

Inputs: name_or_path (required).

pagesB

List pages, add a page (optionally named), or activate a page by name.

Inputs: action (required), name.

save_documentA

Save the active drawing. Pass an absolute path ending in .vsdx the first time; afterwards you can omit it to save in place.

Inputs: path.

set_page_sizeA

Resize the page. Do this BEFORE building a wide architecture diagram — the default page is US Letter (8.5 x 11 in) and export_page_png crops to the page bounds, so shapes placed beyond them are invisible.

Args: width_in / height_in: New page size in inches (e.g. 20 x 12 for a hybrid-cloud reference diagram). orientation: Print orientation; inferred from the size if omitted. fit_to_contents: True = shrink/grow the page to fit what's on it (alternative to explicit width/height).

Inputs: page, width_in, height_in, orientation, +1 more.

style_shapeA

Style a shape, connector, or container. Colors are hex like '#0078D4' (Azure blue) or '#FF9900' (AWS orange). Only the provided fields are changed. Works on containers too: theme-guarded cells are force- overridden, so recoloring a VNet/subscription boundary is supported.

Inputs: shape_id (required), bold, page, fill_color, +5 more.

update_shapeA

Change a shape's text, position (center, inches), or size. Only the provided fields are changed.

Inputs: shape_id (required), x, y, page, +3 more.

visio_statusA

Report Visio state: version, open documents and stencils, active page, the My Shapes folder path, and the built-in stencil library — including builtin_cloud_stencils, the Azure/AWS stencil files Visio ships with (openable by bare filename, no download needed). Launches Visio if it is not already running. Call this first.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 23 tools

    Disambiguation5/5

    Each tool targets a distinct resource/action: document lifecycle, stencil discovery, shape placement, container management, styling, layout, and export. Even related pairs like drop_shape/drop_shapes or add_container/badge_container are cleanly separated by singular-vs-multiple or create-vs-badge semantics. An agent should be able to select the right tool reliably.

    Naming Consistency4/5

    Most tools follow a clear verb_noun pattern (create_document, save_document, open_stencil, connect_shapes, set_page_size). A few noun-style names deviate (visio_status, pages, container_members, auto_layout), but the overall convention is readable and predictable.

    Tool Count3/5

    23 tools is on the heavy side for a single server, fitting the '16-25 feels heavy' range. The breadth is understandable given the full Visio authoring workflow, but the count is borderline rather than clearly well-scoped.

    Completeness5/5

    The tool surface covers the complete diagram-building lifecycle: stencil discovery, document/page setup, shape placement, text/images, containerization, connection, styling, layout, and PNG export. Missing operations like close_document or undo are not essential to the stated purpose. There are no obvious dead ends for creating and editing diagrams.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers