ramus-mcp
README.md
# ramus-mcp
Model Context Protocol (MCP) server for **Ramus** (IDEF0, DFD, and DFDS business process modeling in `.rsf` format).
`ramus-mcp` connects AI coding assistants (Antigravity, Claude Desktop, Cursor, etc.) directly to the native Ramus Java engine in headless mode—allowing you to create, inspect, decompose, validate, and export `.rsf` models to PNG, SVG, PDF, and IDL without manually clicking through the desktop UI.
## Features
- **Full `.rsf` read/write support** via the official Ramus engine (`FileIEngineImpl`, `NDataPluginFactory`, `IDEF0Plugin`, `PIDEF0painter`).
- **All 3 Ramus notations:** `IDEF0`, `DFD` (including External References & Data Stores), and `DFDS`.
- **Automatic diagram layout & smart arrow routing:** diagonal block placement, ICOM edge spreading, and automatic merging/branching of parent boundary flows without `[ ]` tunnels.
- **Model tree registration:** registers newly created models in `F_MODEL_TREE` so they appear immediately in Ramus Desktop GUI.
- **Modern JDK compatibility:** includes a flexible `DateFormat` wrapper for `.rsf` XML timestamps on Java 11–26+.
- **Vector & raster exports:** PNG, SVG, JPEG, BMP, EMF, multi-page Cyrillic-ready PDF, and IDL.
## Prerequisites
1. **Ramus** (tested with Ramus 2.0.2) installed on the machine.
2. **Node.js** `>= 18.0.0`.
3. **Java JDK** `>= 11` (`java` and `javac` available in `PATH`, or specified via `JAVA_BIN` / `JAVAC_BIN`).
## Installation
### Option 1: Via npm (Recommended)
You can run `ramus-mcp` directly with `npx` without cloning the repository, or install it globally:
```bash
npm install -g ramus-mcp
```
### Option 2: From Source (GitHub)
```bash
git clone https://github.com/buli-cachalot/ramus-mcp.git
cd ramus-mcp
npm install
npm run build
```
> Note: `npm install` runs `postinstall` (`node scripts/build-java.mjs --optional`), which automatically compiles `java/src/*.java` into `java/bin/` if Ramus is found in a standard path or `RAMUS_HOME`. On first tool invocation, `server.mjs` also auto-compiles `java/bin/` if `.class` files are missing or outdated.
## Configuration
Add the server to your MCP client configuration (`~/.gemini/config/mcp_config.json`, `claude_desktop_config.json`, or `.cursor/mcp.json`):
### Using `npx` (npm package)
```json
{
"mcpServers": {
"ramus": {
"command": "npx",
"args": ["-y", "ramus-mcp"],
"env": {
"RAMUS_HOME": "C:\\Program Files (x86)\\Ramus"
}
}
}
}
```
### Using local source (`node`)
```json
{
"mcpServers": {
"ramus": {
"command": "node",
"args": ["/absolute/path/to/ramus-mcp/server.mjs"],
"env": {
"RAMUS_HOME": "C:\\Program Files (x86)\\Ramus"
}
}
}
}
```
### Environment Variables
| Variable | Description | Default |
| :--- | :--- | :--- |
| `RAMUS_HOME` | Path to the Ramus installation directory (containing `lib/ramus`) | Auto-detected (`C:\Program Files (x86)\Ramus`, `C:\Program Files\Ramus`, `/opt/ramus`, `/usr/share/ramus`, etc.) |
| `JAVA_BIN` | Path to the `java` executable | `java` |
| `JAVAC_BIN` | Path to the `javac` compiler | `javac` |
## Available Tools (19)
| Tool | Description |
| :--- | :--- |
| `ramus_get_project` | Read `.rsf` metadata, all IDEF0/DFD/DFDS models, function tree (`A0`, `A1`...), and classifiers. |
| `ramus_create_project` | Create a new `.rsf` file initialized with a model, frame header metadata, and context block `A0`. |
| `ramus_create_model` | Add an additional IDEF0/DFD/DFDS model inside an existing `.rsf` file. |
| `ramus_update_metadata` | Update frame header fields (`projectName`, `author`, `usedAt`, `definition`, `newModelName`). |
| `ramus_get_diagram` | Inspect blocks (codes, types, bounds) and arrows on a diagram (`TOP`, `A0`, `A1`, ...). |
| `ramus_decompose_function` | Decompose a function (`A0`, `A1`, ...) into child functions in `IDEF0`, `DFD`, or `DFDS`. |
| `ramus_build_diagram` | Batch-create blocks (with diagonal auto-layout) and named ICOM/DFD arrows in one atomic transaction. |
| `ramus_add_function` | Add a single `PROCESS`, `EXTERNAL_REFERENCE`, `DATA_STORE`, `DFDS_ROLE`, `OPERATION`, or `ACTION`. |
| `ramus_update_function` | Rename, move, resize, or recolor a block. |
| `ramus_delete_function` | Delete a block and its decomposition subtree. |
| `ramus_add_arrow` | Add a single arrow between blocks or diagram borders. |
| `ramus_rename_arrow` | Rename an arrow / stream on a diagram. |
| `ramus_delete_arrow` | Delete an arrow from a diagram. |
| `ramus_validate_model` | Validate an IDEF0/DFD model (missing Outputs/Controls, unnamed arrows, block count rules). |
| `ramus_export_image` | Render any diagram (`TOP`, `A0`, `A1`...) with its IDEF0/DFD frame to `PNG`, `SVG`, `JPEG`, `BMP`, or `EMF`. |
| `ramus_export_pdf` | Export all diagrams in a model to a multi-page vector PDF with embedded Cyrillic fonts. |
| `ramus_export_idl` | Export an IDEF0 model to standard IDL text format. |
| `ramus_manage_classifiers` | List streams and manage reference classifiers (`list_streams`, `list_qualifiers`, `get_elements`, `upsert_element`, `delete_element`). |
| `ramus_open_in_gui` | Launch the local Ramus desktop application and open the `.rsf` file. |
## License
MIT