An MCP server that standardizes and contextualizes Modbus data, enabling seamless integration of AI agents with industrial IoT systems. - Modbus Tools: - Read/write holding registers (readregister, writeregister). - Read/write coils (readcoils, writecoil). - Read input registers (readinputregisters). - Read multiple holding registers (readmultipleholdingregisters). - Prompt: Analyze Modbus registe
Add this skill
npx mdskills install kukapay/modbus-mcpWell-documented Modbus integration with comprehensive tool coverage and clear setup
1# Modbus MCP Server23An MCP server that standardizes and contextualizes Modbus data, enabling seamless integration of AI agents with industrial IoT systems.456789## Features1011- **Modbus Tools**:12 - Read/write holding registers (`read_register`, `write_register`).13 - Read/write coils (`read_coils`, `write_coil`).14 - Read input registers (`read_input_registers`).15 - Read multiple holding registers (`read_multiple_holding_registers`).16- **Prompt**: Analyze Modbus register values with a customizable prompt (`analyze_register`).17- **Flexible Connections**: Supports Modbus over TCP, UDP, or serial, configured via environment variables.1819## Requirements2021- **Python**: 3.1022- **uv** for dependency and virtual environment management.2324## Installation25261. **Install `uv`**:27 ```bash28 curl -LsSf https://astral.sh/uv/install.sh | sh29 ```30312. **Clone the Repository**:32 ```bash33 git clone https://github.com/kukapay/modbus-mcp.git34 cd modbus-mcp35 ```36373. **Install Dependencies**:38 ```bash39 uv sync40 ```4142## Configuration4344The server connects to a Modbus device using parameters specified via environment variables. Set these variables in a `.env` file or your shell environment.4546### Environment Variables4748| Variable | Description | Default | Required |49|------------------------- |--------------------------------------------------|----------------------|----------|50| `MODBUS_TYPE` | Connection type: `tcp`, `udp`, or `serial` | `tcp` | Yes |51| `MODBUS_HOST` | Host address for TCP/UDP | `127.0.0.1` | For TCP/UDP |52| `MODBUS_PORT` | Port for TCP/UDP | `502` | For TCP/UDP |53| `MODBUS_DEFAULT_SLAVE_ID` | Slave ID | `1` | For TCP/UDP |54| `MODBUS_SERIAL_PORT` | Serial port (e.g., `/dev/ttyUSB0`, `COM1`) | `/dev/ttyUSB0` | For serial |55| `MODBUS_BAUDRATE` | Serial baud rate | `9600` | For serial |56| `MODBUS_PARITY` | Serial parity: `N` (none), `E` (even), `O` (odd) | `N` | For serial |57| `MODBUS_STOPBITS` | Serial stop bits | `1` | For serial |58| `MODBUS_BYTESIZE` | Serial byte size | `8` | For serial |59| `MODBUS_TIMEOUT` | Serial timeout (seconds) | `1` | For serial |6061### Example `.env` File6263For TCP:64```65MODBUS_TYPE=tcp66MODBUS_HOST=192.168.1.10067MODBUS_PORT=50268MODBUS_SLAVE_ID=169```7071For Serial:72```73MODBUS_TYPE=serial74MODBUS_SERIAL_PORT=/dev/ttyUSB075MODBUS_BAUDRATE=960076MODBUS_PARITY=N77MODBUS_STOPBITS=178MODBUS_BYTESIZE=879MODBUS_TIMEOUT=180```8182## Usage8384### Installing for Claude Desktop8586The configuration file:8788```json89{90 "mcpServers": {91 "Modbus MCP Server": {92 "command": "uv",93 "args": [ "--directory", "/path/to/modbus-mcp", "run", "modbus-mcp" ],94 "env": { "MODBUS_TYPE": "tcp", "MODBUS_HOST": "127.0.0.1", "MODBUS_PORT": 502 },95 }96 }97}98```99100### Using Tools101102**Note**: Natural language support depends on the client’s ability to parse and map prompts to tools. The MCP Inspector requires structured JSON, but the examples below show how conversational inputs translate.1031041. **Read a Holding Register**:105 - **Prompt**:106 ```107 Please read the value of Modbus holding register 0.108 ```109 - **MCP Inspector JSON**:110 ```json111 {112 "tool": "read_register",113 "parameters": {"address": 0, "slave_id": 1}114 }115 ```116 - **Expected Output**: `Value: <register_value>`1171182. **Write to a Holding Register**:119 - **Prompt**:120 ```121 Set Modbus holding register 10 to the value 100.122 ```123 - **MCP Inspector JSON**:124 ```json125 {126 "tool": "write_register",127 "parameters": {"address": 10, "value": 100, "slave_id": 1}128 }129 ```130 - **Expected Output**: `Successfully wrote 100 to register 10`1311323. **Read Coils**:133 - **Prompt**:134 ```135 Check the status of the first 5 Modbus coils starting at address 0.136 ```137 - **MCP Inspector JSON**:138 ```json139 {140 "tool": "read_coils",141 "parameters": {"address": 0, "count": 5, "slave_id": 1}142 }143 ```144 - **Expected Output**: `Coils 0 to 4: [False, False, False, False, False]`1451464. **Write to a Coil**:147 - **Prompt**:148 ```149 Turn on Modbus coil 5.150 ```151 - **MCP Inspector JSON**:152 ```json153 {154 "tool": "write_coil",155 "parameters": {"address": 5, "value": true, "slave_id": 1}156 }157 ```158 - **Expected Output**: `Successfully wrote True to coil 5`1591605. **Read Input Registers**:161 - **Prompt**:162 ```163 Read the values of 3 Modbus input registers starting from address 2.164 ```165 - **MCP Inspector JSON**:166 ```json167 {168 "tool": "read_input_registers",169 "parameters": {"address": 2, "count": 3, "slave_id": 1}170 }171 ```172 - **Expected Output**: `Input Registers 2 to 4: [<value1>, <value2>, <value3>]`1731746. **Read Multiple Holding Registers**:175 - **Prompt**:176 ```177 Get the values of Modbus holding registers 0 through 2.178 ```179 - **MCP Inspector JSON**:180 ```json181 {182 "tool": "read_multiple_holding_registers",183 "parameters": {"address": 0, "count": 3, "slave_id": 1}184 }185 ```186 - **Expected Output**: `Holding Registers 0 to 2: [<value1>, <value2>, <value3>]`187188189## License190191This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.192
Full transparency — inspect the skill content before installing.