Skip to main content
Glama
README.md
# labview-mcp-linux

[![CI](https://github.com/KazimMammadli/labview-mcp-linux/actions/workflows/ci.yml/badge.svg)](https://github.com/KazimMammadli/labview-mcp-linux/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)
![LabVIEW 2026](https://img.shields.io/badge/LabVIEW-2026%20(Linux)-yellow.svg)

A [Model Context Protocol](https://modelcontextprotocol.io) server that lets an AI assistant build and edit LabVIEW
VIs on Linux: create VIs, place and wire functions, build front panels, set any VI Server property, call any method,
run VIs and read results back. Every action is text in, text out; no screenshots.

```
MCP client --stdio--> lvmcp (Python) --TCP 127.0.0.1:6340--> Bridge.vi --> Gateway.vi (VI Scripting)
```

## Features

- **Block diagram**: place any of ~1,170 palette objects, library VIs and subVIs; wire, insert nodes into existing
  wires, replace objects, Case/Event Structure frames, loops with shift registers and tunnels, Formula Nodes, comments.
- **Front panel**: every Controls-palette object (349 of 349, Modern/Silver/System/Classic/NXG), Tab Control pages,
  decorations and labels, typed controls (`U8`, `enum(Idle, Run)`, `cluster(DBL[][], bool)[]`, paths).
- **Any property, any method**: `set_prop` / `get_prop` / `invoke` reach every VI Server property and method of 38
  object classes plus the VI and the application, by name, with catalogs to search them.
- **Run and inspect**: run VIs, read indicator values (arrays, clusters, variants decoded), list objects, wires,
  broken wires and compile errors.
- **Project files**: type definitions (`.ctl`), libraries (`.lvlib`), LabVIEW classes (`.lvclass`) with member VIs,
  projects (`.lvproj`), icons, connector panes.
- **Safe by default**: writes only inside configured folders, a `.bak` copy before the first edit of a VI, and a
  guard against LabVIEW's one-VI-per-name memory silently editing the wrong file.

Example prompt: *"Create ~/Projects/thermo.vi: a While Loop that reads a simulated temperature every 200 ms, shows it
on a chart, and stops with a Stop button."*

## Requirements

- Linux with an X11 or XWayland desktop session (`open`/`run`/`close` send key events to LabVIEW windows).
- LabVIEW 2026 Q3 64-bit or newer with the English user interface (window titles and the file dialog are matched by
  their English names). The VIs in `vendor/` are saved in LabVIEW 2026, so older versions cannot open them.
- Python 3.12+.

Tested on LabVIEW 2026 Q3 Community Edition, Fedora 44.

## Installation

```bash
git clone https://github.com/KazimMammadli/labview-mcp-linux.git
cd labview-mcp-linux
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
```

LabVIEW's TCP listener has no bind address, so block Bridge's port from the network (loopback stays open), e.g.
with firewalld:

```bash
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" port port="6340" protocol="tcp" reject'
sudo firewall-cmd --reload
```

### MCP client configuration

Register the `lvmcp` script from the venv as a stdio server:

```json
{
  "mcpServers": {
    "lvmcp": {
      "command": "/abs/path/labview-mcp-linux/.venv/bin/lvmcp",
      "env": { "LVMCP_ROOTS": "/home/you/Projects" }
    }
  }
}
```

The first tool call starts LabVIEW with `vendor/Bridge.vi` if it is not running (or call `start_bridge`).
Check the connection with `.venv/bin/python -c "from lvmcp.client import send; print(send('ping'))"`.

### Configuration

All settings are optional environment variables:

| Variable | Default | Meaning |
|---|---|---|
| `LVMCP_ROOTS` | `~/Projects` | folders the server may write VIs in, `:`-separated |
| `LVMCP_LABVIEW_DIR` | newest `/usr/local/natinst/LabVIEW-*-64` | LabVIEW install folder (palette and library search) |
| `LVMCP_LABVIEW_BIN` | `labview64` on `PATH`, else `/usr/local/bin/labview64` | LabVIEW executable |
| `LVMCP_CACHE` | `$XDG_CACHE_HOME/lvmcp` (`~/.cache/lvmcp`) | generated helper VIs and state |
| `LVMCP_TIMEOUT` | `30` | seconds to wait for one LabVIEW call |

The first use of a property, method or helper builds a small VI in the cache (a few seconds); later calls reuse it.

## Tools

`target` is a VI path with a resolver suffix: `a.vi%WhileLoop|L1`, `a.vi%NumericConstant|N`, `a.vi%Control|Speed`.
Placing with a resolver puts the object inside that structure. The `guide` tool serves `lvmcp/guide.md`: terminal
orders, wire kinds, value formats and recipes an AI client needs to build VIs without trial and error.

### Build

| Tool | What it does |
|---|---|
| `new_vi(path)` | create and save an empty VI |
| `place(vi_path, type, location, label)` | place an object: palette name (`While Loop`, `Wait (ms)`), library VI name, subVI or `.ctl` path, `any:<style code>` |
| `create(vi_path, type, location, label, what)` | typed constants, controls, indicators: numbers, bool, string, path, `enum(..)`, arrays, clusters, typedef instances |
| `wire(vi_path, "src\|dst", "kind\|idx\|kind\|idx")` | connect two terminals |
| `insert(vi_path, src, dst, node, node_in, node_out)` | put a placed node into an existing wire |
| `delete(vi_path, "L:label" or "U:uid", cls)` | remove an object or wire |
| `loop(target, action, mode)` / `case(target, action, arg)` | shift registers and tunnels; Case Structure frames |
| `event_case(target, frame, event, control)` | make an Event Structure frame handle an event |
| `move_into(target, owner, frame, x, y, copy)` / `move(target, x, y)` | move or copy objects into structure frames; move objects |
| `to_page(vi_path, label, tab, page, location)` | move a front-panel object onto a Tab Control page |
| `note(vi_path, text, location, panel)` | a free label (comment) on the diagram or panel |
| `label_object(vi_path, uid, label, panel)` | label an unlabelled or duplicate object so other tools can address it |
| `connector(vi_path, label, cell)` | put a control/indicator on a connector-pane cell |
| `cleanup(vi_path)` | Block Diagram Clean Up |

### Properties and methods

| Tool | What it does |
|---|---|
| `set_prop(target, prop, value, type, cls)` / `get_prop(target, prop)` | any VI Server property by name (`Visible`, `Label.Text`, `Strings[]`, `Formula Expression`, VI properties on a bare VI path) |
| `invoke(target, method, args, types, cls, then)` | any method with arguments and outputs; `cls="App"` for application methods; `then` chains calls |
| `props(cls, query)` / `methods(cls, query)` | search the property and method catalogs |
| `configure_node(target, names)` | point your own Property / Invoke Node at properties or a method |
| `set_value` / `get_value` / `save_defaults` | constant and control values of any type |
| `chart_scale` / `legend` | chart and graph scales and legends |

### Files and projects

| Tool | What it does |
|---|---|
| `new_typedef(path, type, label)` | a type definition `.ctl` |
| `new_library(path, files)` / `new_class(path, files)` | a `.lvlib` / `.lvclass` with member VIs |
| `new_project(path, files)` | a `.lvproj` listing VIs and controls |

### Run and inspect

| Tool | What it does |
|---|---|
| `run(vi_path, seconds)` / `status(vi_path)` | run a VI (refused if it has errors), abort after `seconds` or leave it running; running / idle / closed |
| `open(vi_path)` / `close(vi_path, unsaved)` | open a front panel; close, answering the save dialog |
| `analyze(vi_path, part)` / `wires(vi_path)` / `errors(vi_path)` | objects, wires (with broken ones), compile errors |
| `terms(vi_path, label)` | a node's terminals, or a VI's connector pane |
| `find(query)` | search palette objects and ~19k library and example VIs |
| `restore(vi_path)` | put back the `.bak` copy |
| `batch(steps)` / `raw(verb, ...)` | many calls in one request; any Gateway verb |
| `ping` / `start_bridge` / `guide(topic)` | health check; start LabVIEW and Bridge; the usage guide |

Errors come back to the client as tool errors with LabVIEW's reason in the text.

## How it works

`Bridge.vi` runs inside LabVIEW and serves one request at a time on `127.0.0.1:6340`; `Gateway.vi` executes
VI Scripting verbs (place, wire, analyze, ...). Everything Gateway lacks runs through small helper VIs: class
templates in `vendor/tpl` cast an object to a VI Server class, and `PropSetup.vi` / `MethodSetup.vi` point a copy's
Property or Invoke Node at any property or method by name. These copies are cached per class and property.
`open`, `run` and `close` drive LabVIEW's own windows with X11 key events, because LabVIEW on Linux has no other
way to open a VI in a running instance without VI Server TCP.

## Safety

- Write tools only touch absolute `.vi`/`.vit`/`.ctl` paths under `LVMCP_ROOTS` and the cache.
- Before the first write to an existing VI a copy is saved as `<name>.bak.vi`; an existing backup is never
  overwritten, so it keeps the oldest state.
- LabVIEW holds one VI per name. If `x.vi` is loaded from one folder, an edit of `x.vi` in another folder would
  silently change the loaded one and save it over that file. Calls are refused while a same-named VI is loaded from
  another path (including subVIs of open callers); `close` it first.

## Limitations

- One request at a time; a request that times out may still finish inside LabVIEW.
- Not scriptable in LabVIEW: Express VI configuration dialogs, strict typedefs, resizing existing controls, undo
  (use `restore`), LabVIEW class private data, polymorphic VI instances.
- Decorations and panel labels are created at their default size and without a label.
- A VI opened by hand in Bridge's LabVIEW blocks calls on it until it is closed (its path is unknown).
- Application builds (EXE) are not covered: LabVIEWCLI needs VI Server TCP, which this server does not enable.
- Linux only.

## Development

```bash
.venv/bin/pytest                          # unit tests, no LabVIEW needed
.venv/bin/python -m tools.live_check      # 37 end-to-end checks against a running LabVIEW
.venv/bin/python -m examples.demo         # build an example VI (also examples.pid_control, examples.weather_station)
```

- `tools/probe_palette.py` / `tools/probe_panel.py` re-check which palette objects can be placed.
- `tools/catalog_props.py` regenerates `lvmcp/properties.json` and `methods.json` from LabVIEW.
- `tools/templates.py` rebuilds class templates in `vendor/tpl`; it drives LabVIEW menus and needs Tools > Options >
  VI Server > "Show VI Scripting functions, properties and methods".

See [CONTRIBUTING.md](CONTRIBUTING.md).

## Credits

`vendor/gateway/` (Gateway.vi and subVIs), `lvmcp/style_codes.json` and `lvmcp/lv_flat.py` come from
work by LabView skill contributors (MIT, see `vendor/gateway/LICENSE`). Changes
here: Gateway.vi's connector pane assigned, the VIs re-saved for LabVIEW 2026, strings switched to UTF-8.

## License

[MIT](LICENSE)

TDQS

C2.6/5.0

Scored across 46 tools

Disambiguation3/5

Most tools map to distinct LabVIEW concepts, but several boundaries are genuinely blurry: set_value vs set_prop vs invoke vs create vs place all write to an object, and move vs move_into, insert vs wire, props vs get_prop vs methods are easy to misselect. The detailed descriptions help an expert disambiguate, but an agent must read carefully to pick the right one.

Naming Consistency3/5

Style is uniformly lowercase snake_case, but the convention is mixed: some tools are verb_noun (set_value, move_into, new_vi, configure_node), many are bare nouns (wires, errors, case, terms, connector, props, methods, status), and some are single verbs (run, place, create, find, raw). It is readable but not a predictable pattern.

Tool Count2/5

46 tools is heavy for a single MCP surface, well past the 25-tool threshold. The LabVIEW scripting domain is genuinely large, but several tools (raw, batch, props, methods, get_prop) are escape hatches or sub-facets of set_prop/invoke that could be consolidated, and the sheer count raises selection cost.

Completeness4/5

Coverage is impressively broad: creation, wiring, structures, properties/methods, connector panes, typedefs, projects, libraries, classes, running, restore, and even a guide. Minor gaps exist (no explicit save tool separate from write operations, no VI-level delete/rename, limited icon/documentation editing), but core lifecycle is well covered.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues