Skip to content

skurzyp/uml2code-mcp-server

Repository files navigation

🌐 UML2Code MCP Server

Convert PlantUML diagrams into Java code using an MCP (Model Code Prompting) server backed by OpenAI's GPT models.


🚀 Prerequisites & Setup

1. Clone the Repository

git clone https://github.com/skurzyp/uml2code-mcp-server
cd uml2code-mcp-server

2. Requirements

3. Configure Environment

cp .env.example .env
# Paste your OpenAI API key into the .env file

4. Install Dependencies

pnpm install

🧪 Running the App

Option 1: Development Mode

pnpm run dev

Option 2: Build & Run

pnpm build
pnpm start

🛠 VSCode Integration

1. Configure settings.json

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"
  }
}

2. Start the MCP Server

  • Open the VSCode command palette and click "Start" next to your selected server.

📝 How to Use

  1. Create a PlantUML diagram (e.g., diagram.puml).
  2. Attach it to a Copilot prompt like:
    generate java code from this plant uml diagram.
    
  3. Accept permission to execute the MCP Server Tool.
  4. If the diagram is valid, Java code files will be returned.
  5. If not, you’ll receive suggested fixes from the server.

🧪 Local Testing

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"}}'

📦 Project Structure

├── build/                   # Compiled output
├── src/                     # Source files
├── .env.example             # Environment template
├── README.md                # You're here!

🧠 Notes

  • 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

📄 License

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published