# Modbus TCP/RTU Device

MCP server connecting AI assistants to industrial hardware over Modbus TCP or RTU. It translates raw registers into named physical metrics and enforces point safety limits.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 23
- Author: K-Dense-AI
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/K-Dense-AI/lab-instrument-mcps/tree/HEAD/servers/protocols/modbus
- Updated: 2026-09-26
- HTML: https://affpapa.org/en/nevibecode/mcp/modbus-tcprtu-device

## What it does

Instead of exposing raw memory addresses directly to an agent, the server relies on register maps in YAML or JSON. Each mapped point specifies data types like `int16` or `float32`, byte order, multiplier scales, and engineering units. The assistant reads temperatures or status codes directly in units such as degrees Celsius or text states.

Every writable numeric field must define bounds. Out-of-bounds commands get rejected immediately before transmission, and the server blocks unmapped writes to protected addresses. After every write, it reads back the register to confirm the update. A dedicated safe-state routine can reset critical outputs even under read-only mode.

Developers can test workflows using an included thermal controller simulator without physical gear. The codebase currently holds simulated status, having passed checks against pymodbus software instances rather than verified physical machines.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `LABMCP_ADDRESS`, `LABMCP_SIMULATE`, `LABMCP_READ_ONLY`, `LABMCP_LIMITS` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env LABMCP_ADDRESS=<LABMCP_ADDRESS> --env LABMCP_SIMULATE=<LABMCP_SIMULATE> --env LABMCP_READ_ONLY=<LABMCP_READ_ONLY> --env LABMCP_LIMITS=<LABMCP_LIMITS> --transport stdio modbus -- uvx labmcp-modbus
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>

### Codex

**Platform CLI**
```bash
codex mcp add modbus --env LABMCP_ADDRESS=<LABMCP_ADDRESS> --env LABMCP_SIMULATE=<LABMCP_SIMULATE> --env LABMCP_READ_ONLY=<LABMCP_READ_ONLY> --env LABMCP_LIMITS=<LABMCP_LIMITS> -- uvx labmcp-modbus
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "modbus": {
            "command": "uvx",
            "args": [
                "labmcp-modbus"
            ],
            "env": {
                "LABMCP_ADDRESS": "<LABMCP_ADDRESS>",
                "LABMCP_SIMULATE": "<LABMCP_SIMULATE>",
                "LABMCP_READ_ONLY": "<LABMCP_READ_ONLY>",
                "LABMCP_LIMITS": "<LABMCP_LIMITS>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "modbus": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "labmcp-modbus"
            ],
            "env": {
                "LABMCP_ADDRESS": "<LABMCP_ADDRESS>",
                "LABMCP_SIMULATE": "<LABMCP_SIMULATE>",
                "LABMCP_READ_ONLY": "<LABMCP_READ_ONLY>",
                "LABMCP_LIMITS": "<LABMCP_LIMITS>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e LABMCP_ADDRESS=<LABMCP_ADDRESS> -e LABMCP_SIMULATE=<LABMCP_SIMULATE> -e LABMCP_READ_ONLY=<LABMCP_READ_ONLY> -e LABMCP_LIMITS=<LABMCP_LIMITS> modbus uvx labmcp-modbus
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>

## When to use it
- control industrial instruments using human-readable tags
- prevent invalid register values via automatic range validation
- execute an emergency safe-state routine across multiple registers
- test Modbus control logic against a simulated PID loop

## Example prompts
- Read the current temperature from the controller using labmcp-modbus
- Set the setpoint to 45.0 degrees according to oven.yaml
- Execute apply_safe_state to shut down active outputs

## Similar
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89899
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119231
- [AIHawk](https://affpapa.org/en/nevibecode/mcp/aihawk.md) — MCP server · ★ 32260
- [Skyvern](https://affpapa.org/en/nevibecode/mcp/skyvern.md) — MCP server · ★ 23283
- [SeleniumBase MCP](https://affpapa.org/en/nevibecode/mcp/seleniumbase-mcp.md) — MCP server · ★ 13181
- [Inbox Zero](https://affpapa.org/en/nevibecode/mcp/inbox-zero.md) — MCP server · ★ 12826

From the same set: [k-dense-ai/lab-instrument-mcps](https://affpapa.org/en/nevibecode/by/k-dense-ai/lab-instrument-mcps.md) — 28 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
