A MCP server that provides tools for creating and editing Microsoft Visio diagrams programmatically via a standardized API.
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.
- Windows operating system
- Microsoft Visio (Professional or Standard) installed
- Python 3.12+
- Python packages:
mcp.server
win32com.client
(pywin32)
- Ensure Microsoft Visio is installed on your system
- Install required Python packages:
pip install pywin32
pip install mcp-server
- Clone or download this repository
- Run the server:
python visio_mcp_server.py
The server provides the following functionality:
- Create new Visio diagrams
- Open existing Visio diagrams
- Add various shapes (Rectangle, Circle, Line, etc.)
- Connect shapes with different connector types
- Add text to shapes
- List all shapes in a document
- Save documents to specified locations
- Export diagrams as images
- Close documents safely
Add the server to your MCP settings configuration file:
{
"mcpServers": {
"ppt": {
"command": "python",
"args": ["/path/to/ppt_mcp_server.py"],
"env": {}
}
}
}
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"
]
}
}
}
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"
}
Opens an existing Visio diagram.
{
"file_path": "Path to the Visio file to open"
}
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
}
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"
}
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"
}
Lists all shapes in a Visio diagram.
{
"file_path": "Path to the Visio file"
}
Here's a complete workflow example:
- Create a new Visio file:
{
"save_path": "C:\\Diagrams\\FlowChart.vsdx"
}
- 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
}
- Add another shape:
{
"file_path": "C:\\Diagrams\\FlowChart.vsdx",
"shape_type": "Circle",
"x": 5.0,
"y": 2.0,
"width": 1.0,
"height": 1.0
}
- Get shape IDs:
{
"file_path": "C:\\Diagrams\\FlowChart.vsdx"
}
- Connect the shapes:
{
"file_path": "C:\\Diagrams\\FlowChart.vsdx",
"shape1_id": 1,
"shape2_id": 2,
"connector_type": "Straight"
}
- Add text to shapes:
{
"file_path": "C:\\Diagrams\\FlowChart.vsdx",
"shape_id": 1,
"text": "Start"
}
The following features are planned for future releases:
- Color and fill pattern customization
- Line weight, style, and color options
- Text formatting (font, size, alignment)
- Shadow and 3D effects
- Support for layers and pages
- Group creation and manipulation
- Container management
- Text-only shapes and callouts
- Template library access
- Custom template creation
- Favorite templates list
- Bulk shape creation
- Mass formatting changes
- Import from CSV/JSON data sources
- Loading custom stencils
- Creating and saving custom stencils
- Searching stencil shapes
- Shape relationship analysis
- Path finding between shapes
- Validation against diagram rules
- PDF export with options
- SVG export for web use
- PNG/JPG with custom resolution
- Export specific pages or sections
- REST API wrapper
- Webhook support for diagram changes
- Version control integration
- CI/CD pipeline support
- Server operation without visible Visio UI
- Background diagram processing
- Scheduled operations
-
Visio Not Launching:
- Ensure Visio is correctly installed and can be opened manually
- Check that you have sufficient permissions to launch COM applications
-
Template Not Found:
- The server will create a blank diagram if templates aren't found
- Specify an absolute path to a template if needed
-
Invalid Shape Type:
- If a shape type isn't recognized, the server will default to a rectangle
- Check spelling and case of shape names
-
COM Errors:
- Restarting Visio manually may help resolve COM interface issues
- Ensure no existing Visio processes are hanging in Task Manager
This project is licensed under the MIT License - see the LICENSE file for details.