Modbus TCP/RTU Device — Claude Code MCP server: setup guide
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.
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-modbusWhat Modbus TCP/RTU Device 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.
What it helps with
- 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 for the agent
- 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
How to install Modbus TCP/RTU Device
Platform CLI
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-modbusReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>
Platform CLI
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-modbusReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>
Config file
{
"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>
Config file
{
"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>
Platform CLI
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-modbusReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from labmcp-modbus <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Modbus TCP/RTU Device
How to install Modbus TCP/RTU Device in Claude Code?
Run claude mcp add labmcp-modbus -- uvx labmcp-modbus for standard setup. If you pass environment variables for network addressing or simulation flags, use `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`.
What does Modbus TCP/RTU Device do?
It allows language models to monitor and configure Modbus TCP and RTU hardware. By applying register maps, it translates binary memory words into scaled units and checks bounds before writing.
Can I test it without connecting physical hardware?
Yes, launching with --simulate spins up a simulated PID temperature loop. You can test register configurations and verify tool calls entirely on your local machine.