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.
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
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"])
UML-MCP Server can integrate with the Cursor IDE through MCP support:
Ensure you have the latest version of Cursor IDE installed
Open the Cursor configuration file:
~/Library/Application Support/Cursor/config.json
%APPDATA%\Cursor\config.json
~/.config/Cursor/config.json
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"
}
}
}
Customize the paths in the configuration:
/Users/yourpath/UML-MCP-Server
with your actual project path/Users/yourpath/uml-output
with your desired output directorySave the configuration file and restart Cursor
Once configured, you can use UML tools directly within Cursor:
For example, you could input:
The UML-MCP Server returns three key components:
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:
If you encounter issues:
Common issues include:
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.
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"
]
}
}
}
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.
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.