Metadata-Version: 2.4
Name: iflow-mcp_gongrzhe-office-visio-mcp-server
Version: 1.0.1
Summary: MCP server for manipulating Microsoft Visio documents
Project-URL: Homepage, https://github.com/GongRzhe/Office-Visio-MCP-Server
Project-URL: Bug Tracker, https://github.com/GongRzhe/Office-Visio-MCP-Server/issues
Author-email: GongRzhe <gongrzhe@gmail.com>
License: MIT License
        
        Copyright (c) 2025 GongRzhe
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: mcp[cli]>=1.2.0
Provides-Extra: windows
Requires-Dist: pywin32>=305; extra == 'windows'
Description-Content-Type: text/markdown

# Visio MCP Server

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

![](https://badge.mcpx.dev?type=server "MCP Server")

## 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](./public/demo.gif)

## 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:

```bash
pip install pywin32
pip install mcp-server
```

3. Clone or download this repository
4. Run the server:

```bash
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:

```json
{
  "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:

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

## API Reference

### Create a Visio File
Creates a new Visio diagram.

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

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

### Open a Visio File
Opens an existing Visio diagram.

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

### Add Shape
Adds a shape to a Visio diagram.

```json
{
  "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.

```json
{
  "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.

```json
{
  "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.

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

## Usage Example

Here's a complete workflow example:

1. Create a new Visio file:
```json
{
  "save_path": "C:\\Diagrams\\FlowChart.vsdx"
}
```

2. Add a rectangle shape:
```json
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx",
  "shape_type": "Rectangle",
  "x": 2.0,
  "y": 2.0,
  "width": 1.5,
  "height": 1.0
}
```

3. Add another shape:
```json
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx",
  "shape_type": "Circle",
  "x": 5.0,
  "y": 2.0,
  "width": 1.0,
  "height": 1.0
}
```

4. Get shape IDs:
```json
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx"
}
```

5. Connect the shapes:
```json
{
  "file_path": "C:\\Diagrams\\FlowChart.vsdx",
  "shape1_id": 1,
  "shape2_id": 2,
  "connector_type": "Straight"
}
```

6. Add text to shapes:
```json
{
  "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.

