# Cursor Integration

Connect UML-MCP to Cursor to generate diagrams in the editor.

## Overview

Cursor connects to UML-MCP as an MCP server so you can generate and view UML and other supported diagram types in the editor.

## Setup

### 1. Install UML-MCP

Install the server on your machine. See [Installation](../installation.md).

#### Add the server from the registry (Smithery CLI)

If you use the [Smithery CLI](https://smithery.ai/docs/concepts/cli) (Node.js 20+), you can add the published **UML** server to Cursor without hand-editing JSON:

```bash
npm install -g @smithery/cli@latest
smithery auth login
smithery mcp add antoinebou12/uml --client cursor
```

Restart Cursor after the command finishes. This is the supported registry flow; some docs or clients may phrase it informally as “install MCP server uml.” The server id on Smithery is **`antoinebou12/uml`** (same project as this repo’s UML-MCP).

Legacy one-liner (older CLI shape):

```bash
npx -y @smithery/cli install antoinebou12/uml --client cursor
```

#### Try a backend-to-frontend diagram

After the server is connected, you can render PlantUML from the repo, for example **[`examples/backend-to-frontend.puml`](https://github.com/antoinebou12/uml-mcp/blob/main/examples/backend-to-frontend.puml)**. Ask the assistant to run **`generate_uml`** with `diagram_type` **`component`** (or **`deployment`**) and the file’s source, or paste the `@startuml` … `@enduml` block into the tool.

### 2. Cursor Configuration

1. Open the MCP config for Cursor (or use **Cursor Settings → MCP**):
   - **Windows:** `%APPDATA%\Cursor\User\globalStorage\cursor.mcp\mcp.json`
   - **macOS:** `~/Library/Application Support/Cursor/User/globalStorage/cursor.mcp/mcp.json`
   - **Linux:** `~/.config/Cursor/User/globalStorage/cursor.mcp/mcp.json`

2. Merge the `mcpServers` block from **[`config/cursor_config.json`](https://github.com/antoinebou12/uml-mcp/blob/main/config/cursor_config.json)** in this repo, or copy the same structure from **[`config/README.md`](https://github.com/antoinebou12/uml-mcp/blob/main/config/README.md)**. The example uses server key **`uml-mcp`**, **`args`**: `["-u", "server.py"]` (relative to **`cwd`**), and **`env`** for `KROKI_SERVER`, `MCP_OUTPUT_DIR`, and `MCP_DIAGRAM_FALLBACK`. Set **`cwd`** to your repo root (the sample uses `${workspaceFolder}` if your Cursor build expands it; otherwise use an absolute path). See [Configuration](../configuration.md) for environment variables.

### 3. Test the Integration

1. Restart Cursor after saving the configuration
2. In a conversation with Cursor, ask it to create a UML diagram
3. Cursor can call the UML-MCP server and show the diagram

Example prompt:
```
Create a UML class diagram for the current project structure.
```

## Troubleshooting

### Server Connection Issues

If Cursor cannot connect to the UML-MCP server:

1. Verify the server is running by launching it manually first
2. Check paths in your configuration are correct and absolute
3. Ensure you have the required permissions for the directories
4. Check Cursor logs for connection errors

### Diagram Generation Problems

If diagrams aren't being generated correctly:

1. Verify the UML-MCP server is running without errors
2. Check the output directory permissions
3. Try generating different diagram types to isolate the issue
4. Verify that all required dependencies are installed

## Advanced configuration

### Custom Templates

You can customize how diagrams appear in Cursor by modifying the templates in the UML-MCP server. See [Advanced Configuration](../configuration.md#custom-templates) for details.

### Output Formats

Cursor works well with SVG and PNG formats. You can specify the preferred format in your prompts or configure defaults in the UML-MCP server.

### Optional: Sequential Thinking MCP

UML-MCP does **not** include Sequential Thinking. For multi-step reasoning before calling `generate_uml`, add a **second** MCP server entry alongside `uml-mcp` in your Cursor MCP configuration (for example install **Sequential Thinking** from the Cursor MCP server directory if you use that distribution). The assistant can call its `sequentialthinking` tool (`thought`, `thoughtNumber`, `totalThoughts`, `nextThoughtNeeded`, and related fields), then call UML-MCP’s `generate_uml` with the final diagram source. Worked narratives appear under [Mermaid tutorials](../tutorials/mermaid.md) and [PlantUML prompts and SVG](../tutorials/plantuml-prompts-svg.md).

## Related resources

- [Configuration Options](../configuration.md)
- [UML Diagram Examples](../examples.md)
- [Supported Diagram Types](../diagrams/uml.md)
