UML Diagramming MCP server

Integrates with UML diagramming tools to generate visual representations of system architecture, class relationships, and process flows directly from code or text descriptions within conversational interfaces.
Back to servers
Provider
Swayingleaves
Release date
Mar 16, 2025
Language
Python
Stats
8 stars

The UML-MCP Server is a powerful tool that generates UML diagrams through natural language descriptions or direct PlantUML code. It supports multiple diagram types and integrates with MCP-compatible clients like Claude, providing both URL links and local file storage for easy sharing and viewing.

Installation

Prerequisites

  • Python
  • Git

Setup Steps

git clone https://github.com/yourusername/UML-MCP-Server.git
cd UML-MCP-Server

Create and activate a virtual environment:

# Create virtual environment
python -m venv uml-mcp-venv

# Activate on Linux/Mac
source uml-mcp-venv/bin/activate

# Activate on Windows
uml-mcp-venv\Scripts\activate

Install required dependencies:

pip install -r requirements.txt

Usage

Using as a Python Library

You can directly import and use the UML generation functionality in your Python code:

from fix_plantuml import generate_uml

# Create UML code
uml_code = """
@startuml
Title: Simple Class Diagram

class User {
-String name
-String email
+login()
+logout()
}

class Order {
-int id
-Date date
+process()
}

User "1" -- "many" Order: places
@enduml
"""

# Generate URLs, code, and local paths for UML diagrams
result = generate_uml(uml_code)

# Output result
print("PlantUML code: ")
print(result["code"])
print("\nPlantUML URL:")
print(result["url"])
print("\nLocal file path: ")
print(result["local_path"])

Configuring with Cursor IDE

UML-MCP Server can integrate with the Cursor IDE through MCP support:

  1. Ensure you have the latest version of Cursor IDE installed

  2. Open the Cursor configuration file:

    • macOS: ~/Library/Application Support/Cursor/config.json
    • Windows: %APPDATA%\Cursor\config.json
    • Linux: ~/.config/Cursor/config.json
  3. Add or modify the 'mcpServer' section:

{
    "mcpServers": {
        "UML-MCP-Server": {
            "command": "uv",
            "args": [
                "--directory",
                "/Users/yourpath/UML-MCP-Server",
                "run",
                "uml_mcp_server.py"
            ],
            "output_dir": "/Users/yourpath/uml-output"
        }
    }
}
  1. Customize the paths in the configuration:

    • Replace /Users/yourpath/UML-MCP-Server with your actual project path
    • Replace /Users/yourpath/uml-output with your desired output directory
  2. Save the configuration file and restart Cursor

Using in Cursor

Once configured, you can use UML tools directly within Cursor:

  1. Open a new chat window
  2. Find the "UML-MCP Server" tool icon in the toolbar
  3. Select your desired UML diagram type (Class Diagram, Sequence Diagram, etc.)
  4. Enter your prompt or requirements

For example, you could input:

  • "Understand the certification process of the project"
  • "Generate UML code for the authentication process and generate a flowchart"

Understanding Results

The UML-MCP Server returns three key components:

  • PlantUML Code: Raw code you can reuse in other PlantUML tools
  • PlantUML URL: A direct link to view the diagram in a browser
  • Local file path: Where the generated image is stored on your system

Example output:

Class diagram generated:

PlantUML code:
@startuml
Title: User and Order System
class User {
-String name
-String email
+login()
+logout()
}
class Order {
-int id
-Date date
+process()
}
User "1" -- "many" Order: places
@enduml

PlantUML URL:
http://www.plantuml.com/plantuml/png/~1UDgCqB5Bn0G1k1zYWM_EfPYQYY0Qd9oQc9oQaPcKYYcKc9gMYaiKc9gK...

Local file path:
/Users/username/projects/UML-MCP-Server/output/class_diagram_12345.png

You can view the generated diagram by:

  • Opening the URL in a browser
  • Accessing the local file path directly
  • Using Markdown to display the image in Cursor's chat window

Troubleshooting

If you encounter issues:

  • Check log files in the 'logs' directory for error details
  • Verify dependencies are correctly installed
  • Ensure network access to PlantUML server (www.plantuml.com)
  • Check permissions for the output directory

Common issues include:

  • Diagram generation failure due to network issues
  • Local image saving problems due to permission restrictions
  • MCP server startup failures due to port conflicts

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later