Skip to main content

MCP server for manipulating Microsoft Visio documents

Project description

Visio MCP Server

A MCP server that provides tools for creating and editing Microsoft Visio diagrams programmatically via a standardized API.

Overview

Visio MCP Server allows you to automate Visio diagram creation and editing using Python. It leverages Microsoft's COM interface to control Visio, enabling you to programmatically create diagrams, add shapes, connect them, add text, and more.

Example

demo

Requirements

  • Windows operating system
  • Microsoft Visio (Professional or Standard) installed
  • Python 3.12+
  • Python packages:
    • mcp.server
    • win32com.client (pywin32)

Installation

  1. Ensure Microsoft Visio is installed on your system
  2. Install required Python packages:
pip install pywin32
pip install mcp-server
  1. Clone or download this repository
  2. Run the server:
python visio_mcp_server.py

Features

The server provides the following functionality:

Creating and Opening Files

  • Create new Visio diagrams
  • Open existing Visio diagrams

Shape Management

  • Add various shapes (Rectangle, Circle, Line, etc.)
  • Connect shapes with different connector types
  • Add text to shapes
  • List all shapes in a document

File Operations

  • Save documents to specified locations
  • Export diagrams as images
  • Close documents safely

MCP Configuration

Option 1: Local Python Server

Add the server to your MCP settings configuration file:

{
  "mcpServers": {
    "ppt": {
      "command": "python",
      "args": ["/path/to/ppt_mcp_server.py"],
      "env": {}
    }
  }
}

Option 2: Using UVX (No Local Installation Required)

If you have uvx installed, you can run the server directly from PyPI without local installation:

{
  "mcpServers": {
    "ppt": {
      "command": "uvx",
      "args": [
        "--from", "office-visio-mcp-server", "visio_mcp_server"
      ]
    }
  }
}

API Reference

Create a Visio File

Creates a new Visio diagram.

{
  "template_path": "[optional] Path to Visio template (.vstx, .vst)",
  "save_path": "[optional] Where to save the file"
}

Example:

{
  "save_path": "C:\\Users\\YourUsername\\Documents\\MyDiagram.vsdx"
}

Open a Visio File

Opens an existing Visio diagram.

{
  "file_path": "Path to the Visio file to open"
}

Add Shape

Adds a shape to a Visio diagram.

{
  "file_path": "Path to the Visio file",
  "shape_type": "Type of shape (Rectangle, Circle, Line, etc.)",
  "x": 1.0,
  "y": 1.0,
  "width": 1.0,
  "height": 1.0
}

Connect Shapes

Connects two shapes in a Visio diagram.

{
  "file_path": "Path to the Visio file",
  "shape1_id": 1,
  "shape2_id": 2,
  "connector_type": "Dynamic, Straight, or Curved"
}

Add Text

Adds text to a shape in a Visio diagram.

{
  "file_path": "Path to the Visio file",
  "shape_id": 1,
  "text": "Text to add to the shape"
}

List Shapes

Lists all shapes in a Visio diagram.

{
  "file_path": "Path to the Visio file"
}

Usage Example

Here's a complete workflow example:

  1. Create a new Visio file:
{
  "save_path": "C:\\Diagrams\\FlowChart.vsdx"
}
  1. Add a rectangle shape:
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx",
  "shape_type": "Rectangle",
  "x": 2.0,
  "y": 2.0,
  "width": 1.5,
  "height": 1.0
}
  1. Add another shape:
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx",
  "shape_type": "Circle",
  "x": 5.0,
  "y": 2.0,
  "width": 1.0,
  "height": 1.0
}
  1. Get shape IDs:
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx"
}
  1. Connect the shapes:
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx",
  "shape1_id": 1,
  "shape2_id": 2,
  "connector_type": "Straight"
}
  1. Add text to shapes:
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx",
  "shape_id": 1,
  "text": "Start"
}

Future Features

The following features are planned for future releases:

Enhanced Shape Styling

  • Color and fill pattern customization
  • Line weight, style, and color options
  • Text formatting (font, size, alignment)
  • Shadow and 3D effects

Advanced Visio Objects

  • Support for layers and pages
  • Group creation and manipulation
  • Container management
  • Text-only shapes and callouts

Template Management

  • Template library access
  • Custom template creation
  • Favorite templates list

Batch Operations

  • Bulk shape creation
  • Mass formatting changes
  • Import from CSV/JSON data sources

Custom Stencil Support

  • Loading custom stencils
  • Creating and saving custom stencils
  • Searching stencil shapes

Diagram Analysis

  • Shape relationship analysis
  • Path finding between shapes
  • Validation against diagram rules

Export Options

  • PDF export with options
  • SVG export for web use
  • PNG/JPG with custom resolution
  • Export specific pages or sections

Integration Capabilities

  • REST API wrapper
  • Webhook support for diagram changes
  • Version control integration
  • CI/CD pipeline support

Headless Operation

  • Server operation without visible Visio UI
  • Background diagram processing
  • Scheduled operations

Troubleshooting

Common Issues:

  1. Visio Not Launching:

    • Ensure Visio is correctly installed and can be opened manually
    • Check that you have sufficient permissions to launch COM applications
  2. Template Not Found:

    • The server will create a blank diagram if templates aren't found
    • Specify an absolute path to a template if needed
  3. Invalid Shape Type:

    • If a shape type isn't recognized, the server will default to a rectangle
    • Check spelling and case of shape names
  4. COM Errors:

    • Restarting Visio manually may help resolve COM interface issues
    • Ensure no existing Visio processes are hanging in Task Manager

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_gongrzhe_office_visio_mcp_server-1.0.1.tar.gz.

File metadata

  • Download URL: iflow_mcp_gongrzhe_office_visio_mcp_server-1.0.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_gongrzhe_office_visio_mcp_server-1.0.1.tar.gz
Algorithm Hash digest
SHA256 128473692d860c2756880a4383408dad957100e523f40416e7a44df3616105ef
MD5 cf60de4ed997ad2cb25525a047101544
BLAKE2b-256 8bc6cb19c46b9313463968109ead98f76ba587cfd7b9c4ca688de6d1c4c68d0b

See more details on using hashes here.

File details

Details for the file iflow_mcp_gongrzhe_office_visio_mcp_server-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_gongrzhe_office_visio_mcp_server-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_gongrzhe_office_visio_mcp_server-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97db0151e6ebad9c94fc6a133b6051a5fe7814a8729869e4eb77b433b635640f
MD5 936942075af751f339cbaf6be34fd51b
BLAKE2b-256 4b0abbf8c9f0b04d3621ba2f45291878e7e566fa121608db9d0e650c816e64c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page