Skip to main content
Glama
rov-telemetry-mcp

rov-telemetry-mcp

README.md
# rov-telemetry-mcp

[![CI](https://github.com/priyanshu3027/rov-telemetry-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/priyanshu3027/rov-telemetry-mcp/actions/workflows/ci.yml)

A read-only [Model Context Protocol](https://modelcontextprotocol.io) server that lets an AI assistant read live telemetry from an underwater vehicle (ROV) that speaks MAVLink, such as one running [ArduSub](https://www.ardusub.com/).

Ask "how deep is the vehicle and is it safe to keep diving?" and the assistant calls the tools below, gets depth, attitude, battery and link state in real units, and checks them against your operating limits.

It ships with a built-in dive simulator, so it runs with no vehicle and no extra software.

## Why read-only

Every tool only reads. There is no tool to arm the vehicle, move it, change a mode or set a parameter, and the HTTP client only ever issues `GET` requests. A language model can misread a situation, so this server lets it observe and advise while a human stays in control of the thrusters. Both properties are covered by tests.

## Tools

| Tool | Returns |
|---|---|
| `get_telemetry_snapshot` | Status, depth, attitude and battery in one call |
| `check_vehicle_health` | Overall verdict (`ok`, `warning`, `critical`) plus each finding, checked against the configured limits |
| `get_vehicle_status` | Armed state, flight mode, autopilot state, seconds since the last heartbeat |
| `get_depth` | Depth (m), vertical speed (m/s), water temperature (°C), absolute pressure (hPa) |
| `get_attitude` | Roll and pitch (degrees), compass heading |
| `get_battery` | Voltage (V), current (A), remaining charge (%) |
| `list_available_messages` | Names of the MAVLink messages the vehicle is sending |
| `get_raw_message` | The latest raw MAVLink message of one type, wire units untouched |

There is also one prompt, `pre_dive_check`, which asks the assistant for a go / no-go review.

Each tool returns a short readable summary and typed `structuredContent` with a published output schema. A reading the vehicle has not reported comes back as `null`, never as `0` or a default, so the model cannot mistake "no data" for "zero metres".

### Health rules

| Finding | Severity | Trigger |
|---|---|---|
| `NO_HEARTBEAT` | critical | No heartbeat has ever been received |
| `STALE_TELEMETRY` | critical | Last heartbeat older than `ROV_STALE_AFTER_S` |
| `AUTOPILOT_FAILSAFE` | critical | Autopilot reports `MAV_STATE_CRITICAL` or `MAV_STATE_EMERGENCY` |
| `LOW_BATTERY_VOLTAGE` | critical | Voltage below `ROV_MIN_BATTERY_V` |
| `BATTERY_NEARLY_EMPTY` / `BATTERY_LOW` | critical / warning | Under 10% / under 20% remaining |
| `DEPTH_LIMIT_EXCEEDED` / `NEAR_DEPTH_LIMIT` | critical / warning | Beyond `ROV_MAX_DEPTH_M` / within 10% of it |
| `EXCESSIVE_TILT` | warning | Roll or pitch beyond `ROV_MAX_TILT_DEG` |
| `NO_DEPTH_DATA`, `NO_BATTERY_DATA` | info | The vehicle is not reporting that reading |

## Quick start

Requires Node.js 22 or newer.

```bash
git clone https://github.com/priyanshu3027/rov-telemetry-mcp.git
cd rov-telemetry-mcp
npm install
npm run build
```

Add the server to an MCP client. For Claude Code, put this in `.mcp.json` in your project; for Claude Desktop, add the same entry to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "rov-telemetry": {
      "command": "node",
      "args": ["/absolute/path/to/rov-telemetry-mcp/dist/index.js"]
    }
  }
}
```

With no configuration the server uses the simulator: the vehicle arms, descends at 0.4 m/s to 12 m, then holds depth while slowly turning and draining its battery. Try asking:

- "What is the vehicle doing right now?"
- "Run a pre-dive check."
- "Show me the raw SYS_STATUS message."

## Connecting to a vehicle

The server reads MAVLink through [mavlink2rest](https://github.com/mavlink/mavlink2rest), which exposes a vehicle's MAVLink stream as a REST API. Point the server at it with `MAVLINK2REST_URL`:

```json
{
  "mcpServers": {
    "rov-telemetry": {
      "command": "node",
      "args": ["/absolute/path/to/rov-telemetry-mcp/dist/index.js"],
      "env": {
        "MAVLINK2REST_URL": "http://127.0.0.1:8088",
        "ROV_MAX_DEPTH_M": "50"
      }
    }
  }
}
```

mavlink2rest can sit in front of a real autopilot or the ArduSub software-in-the-loop simulator.

### Configuration

| Variable | Default | Meaning |
|---|---|---|
| `MAVLINK2REST_URL` | unset | Base URL of mavlink2rest. Setting it switches the source from the simulator to the vehicle |
| `ROV_MCP_SOURCE` | auto | Force `simulator` or `mavlink2rest` |
| `ROV_SYSTEM_ID` | `1` | MAVLink system id of the vehicle |
| `ROV_COMPONENT_ID` | `1` | MAVLink component id of the autopilot |
| `ROV_HTTP_TIMEOUT_MS` | `3000` | Timeout for each request to mavlink2rest |
| `ROV_MAX_DEPTH_M` | `100` | Depth limit used by the health check |
| `ROV_MIN_BATTERY_V` | `13.0` | Minimum battery voltage (the default suits a 4S lithium pack) |
| `ROV_STALE_AFTER_S` | `5` | Heartbeat age after which the link counts as lost |
| `ROV_MAX_TILT_DEG` | `45` | Roll or pitch beyond this is flagged |

Invalid values stop the server at startup with a message naming the variable.

## How it works

```text
MCP client (Claude)
      │  stdio, JSON-RPC
      ▼
server.ts          tools, prompt, output schemas, error handling
      │
telemetry.ts       MAVLink messages → depth, attitude, battery in real units
health.ts          snapshot + limits → findings (pure function)
      │
MessageProvider    one interface, two implementations
   ├─ Mavlink2RestProvider   HTTP GET against mavlink2rest
   └─ SimulatedProvider      scripted dive, same message shapes
```

The simulator emits the same raw MAVLink message shapes as a vehicle, so both sources run through exactly the same conversion code.

MAVLink fields used: `HEARTBEAT` (armed bit, mode, state), `VFR_HUD` (depth as negative altitude, climb, heading), `GLOBAL_POSITION_INT` (depth fallback), `ATTITUDE` (roll, pitch, yaw), `SCALED_PRESSURE2` (water temperature, pressure) and `SYS_STATUS` (battery).

## Development

```bash
npm test            # build, then run the suite
npm run typecheck   # type-check sources and tests
npm run dev         # run from source with tsx
```

The suite has 111 tests:

- **Conversions and modes:** units, sentinel values, the armed bit in each form `base_mode` can take
- **mavlink2rest client:** URL building, 404 and empty bodies, timeouts, bad JSON, rejection of invalid message names before any request is made
- **Telemetry and health:** every reading and every rule, including missing data
- **Simulator:** the dive profile under a hand-driven clock
- **Server:** a real MCP client connected in memory, covering every tool, schema validation and failure of the telemetry source
- **End to end:** the built server started as a child process over stdio, against the simulator and against a local HTTP server that answers like mavlink2rest

## Limitations

- The mavlink2rest integration is tested against a local HTTP server that mimics the documented response format. It has not yet been run against a live mavlink2rest instance or a physical vehicle.
- `HEARTBEAT.base_mode` is serialised differently across mavlink2rest versions. The three known forms are handled; an unknown form reports the armed state as `null`.
- Flight mode names are for ArduSub. Other vehicle types report the mode by number.
- stdio transport only.

## License

MIT

TDQS

A3.8/5.0

Scored across 8 tools

Disambiguation4/5

Each tool targets a distinct telemetry concern (status, depth, attitude, battery, health, raw messages), and get_telemetry_snapshot's description explicitly tells the agent to prefer it over the individual getters. The only mild overlap is snapshot vs. the individual getters and raw vs. typed fields, but both are clearly explained.

Naming Consistency5/5

All tools follow a consistent snake_case verb_noun pattern (get_*, check_*, list_*), with verbs chosen appropriately for the action. No mixed conventions or vague names.

Tool Count5/5

Eight tools is well-scoped for a read-only telemetry server: four focused getters, one aggregate snapshot, one raw escape hatch, one health check and one discovery tool. Every tool earns its place without redundancy.

Completeness4/5

The surface covers the core ROV telemetry domains (status, depth, attitude, battery, health, raw MAVLink) plus discovery of available messages. Minor gaps exist, such as position/navigation data or a way to view/configure the operating limits used by check_vehicle_health, but agents can work around these via get_raw_message.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues