Convert PlantUML diagrams into Java code using an MCP (Model Code Prompting) server backed by OpenAI's GPT models.
git clone https://github.com/skurzyp/uml2code-mcp-server
cd uml2code-mcp-server
- Node.js v23.3
- pnpm
- OpenAI API Key (with access to
gpt-4o-mini
)
Get your key from: https://openai.com/api
cp .env.example .env
# Paste your OpenAI API key into the .env file
pnpm install
pnpm run dev
pnpm build
pnpm start
Open VSCode settings and add your MCP server configuration:
{
"mcp": {
"inputs": [],
"servers": {
"mcp-server-remote": {
"type": "sse",
"url": "http://localhost:3000/mcp"
},
"mcp-server-local": {
"command": "node",
"args": [
"D:\\<PATH TO YOUR PROJECT>\\uml2code-mcp-server\\build\\index.js"
],
"env": {
"CHAT_OPENAI_API_KEY": "sk-<your-api-key-here>"
}
}
}
},
"workbench.colorTheme": "Andromeda Bordered",
"files.autoSave": "afterDelay",
"window.zoomLevel": 2,
"liveServer.settings.donotShowInfoMsg": true,
"liveServer.settings.CustomBrowser": "chrome",
"workbench.editorAssociations": {
"*.ipynb": "jupyter.notebook.ipynb"
}
}
- Open the VSCode command palette and click "Start" next to your selected server.
- Create a
PlantUML
diagram (e.g.,diagram.puml
). - Attach it to a Copilot prompt like:
generate java code from this plant uml diagram.
- Accept permission to execute the MCP Server Tool.
- If the diagram is valid, Java code files will be returned.
- If not, you’ll receive suggested fixes from the server.
Use the following PowerShell commands to test the tool:
# Test calculate_sum tool
Invoke-RestMethod -Uri http://localhost:3000/test-tool `
-Method Post `
-Headers @{ "Content-Type" = "application/json" } `
-Body '{"name":"calculate_sum","arguments":{"a":123,"b":124}}'
# Test UML to code conversion
Invoke-RestMethod -Uri http://localhost:3000/test-tool `
-Method Post `
-Headers @{ "Content-Type" = "application/json" } `
-Body '{"name":"uml2code","arguments":{"plantUml":"@startuml\nclass User {\n +name: String\n}\n@enduml"}}'
├── build/ # Compiled output
├── src/ # Source files
├── .env.example # Environment template
├── README.md # You're here!
- The MCP server uses SSE (Server-Sent Events) for communication.
- You can run the server locally or point VSCode to a remote instance.
- Ensure your API key has access to GPT-4o Mini (
gpt-4o-mini
). - This project was developed on Windows but should be easy to set up on Linux in similar manner
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software under the terms of the license.
© 2025 UML2Code MCP Server contributors. Open source, open innovation.