logix-tag-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- logix_tag_mcp-0.1.0/LICENSE +21 -0
- logix_tag_mcp-0.1.0/PKG-INFO +203 -0
- logix_tag_mcp-0.1.0/README.md +186 -0
- logix_tag_mcp-0.1.0/pyproject.toml +70 -0
- logix_tag_mcp-0.1.0/pyproject.toml.orig +67 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/__init__.py +189 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/config.py +66 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/connection.py +186 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/logger.py +950 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/names.py +105 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/structs.py +267 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/tools.py +787 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/values.py +31 -0
- logix_tag_mcp-0.1.0/src/logix_tag_mcp/writes.py +421 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zac Wood
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: logix-tag-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server for reading (and optionally writing) live Logix controller tags
|
|
5
|
+
Keywords: mcp,logix,plc,rockwell,controllogix,compactlogix,ethernet/ip
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Topic :: Software Development
|
|
11
|
+
Requires-Dist: mcp[cli]>=2.3.0
|
|
12
|
+
Requires-Dist: pycomm3>=1.2.16
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Project-URL: Repository, https://github.com/zwood16/logix-tag-mcp
|
|
15
|
+
Project-URL: Issues, https://github.com/zwood16/logix-tag-mcp/issues
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# Logix Tag MCP
|
|
19
|
+
|
|
20
|
+
> [!IMPORTANT]
|
|
21
|
+
> This project is still very early. Consider it an Alpha for the time being
|
|
22
|
+
|
|
23
|
+
`logix-tag-mcp` is a Python MCP server that lets a coding agent such as Claude Code or VS Code Chat read live tag values from a running Rockwell Logix PLC's (CompactLogix, ControlLogix, etc.). It talks to the controller over EtherNet/IP with [pycomm3](https://github.com/ottowayi/pycomm3).
|
|
24
|
+
|
|
25
|
+
It pairs with [l5x-mcp](https://github.com/zwood16/l5x-mcp). The agent reads the logic offline with `l5x-mcp` and checks the live values here while you debug online. Tag names can be passed exactly as `l5x-mcp` shows them, as a bare program tag name plus its program.
|
|
26
|
+
|
|
27
|
+
The server is read-only by default. The `write_tag` tool is only registered when the server is started with writes enabled. See [Writing tags](#writing-tags).
|
|
28
|
+
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
> This project is not affiliated with Rockwell Automation in any way.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
`logix-tag-mcp` needs network access to the controller on EtherNet/IP port TCP 44818.
|
|
36
|
+
|
|
37
|
+
[uv](https://docs.astral.sh/uv/getting-started/installation/) is the recommended way to install and run `logix-tag-mcp`. `uvx` downloads and caches the package, so nothing needs to be installed in a specific folder or environment.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uvx logix-tag-mcp --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The server is normally started by your MCP client. See [Register the MCP server](#register-the-mcp-server).
|
|
44
|
+
|
|
45
|
+
There is no default controller. Every tool that talks to a controller takes a required `host` argument, for example `192.168.1.10`, or `192.168.1.10/1` for a processor in slot 1. The agent asks you for the address when it does not know it.
|
|
46
|
+
|
|
47
|
+
### Install as a tool with uv (optional)
|
|
48
|
+
|
|
49
|
+
`uv` can also install `logix-tag-mcp` as a tool. This puts `logix-tag-mcp` on your PATH.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv tool install logix-tag-mcp
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Updating
|
|
56
|
+
|
|
57
|
+
`uvx` caches the package, so refresh it to pick up a new release with `uvx --refresh logix-tag-mcp --help`. MCP clients configured with `uvx logix-tag-mcp` use the new version after you restart them. With `uv tool install`, run `uv tool upgrade logix-tag-mcp`.
|
|
58
|
+
|
|
59
|
+
## Register the MCP server
|
|
60
|
+
|
|
61
|
+
### Claude Code
|
|
62
|
+
|
|
63
|
+
`-s user` registers the server for all your projects. Leave it out to add it to the current project only.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
claude mcp add -s user logix-tags -- uvx logix-tag-mcp
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If you installed it with `uv tool install`, replace `uvx logix-tag-mcp` with `logix-tag-mcp`. Server options go after the command, and environment variables go in `-e` options before `--`. For example:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
claude mcp add -s user logix-tags -e LOGIX_TAG_MCP_ALLOWED_HOSTS=192.168.1.10 -- uvx logix-tag-mcp
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Other MCP clients
|
|
76
|
+
|
|
77
|
+
Other clients need the same command and arguments. This example is a VS Code `.vscode/mcp.json`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"servers": {
|
|
82
|
+
"logix-tags": {
|
|
83
|
+
"type": "stdio",
|
|
84
|
+
"command": "uvx",
|
|
85
|
+
"args": ["logix-tag-mcp"]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
With `uv tool install`, use `"command": "logix-tag-mcp"` and no `args`. Claude Code also reads a project `.mcp.json`. See [`.mcp.json.example`](.mcp.json.example).
|
|
92
|
+
|
|
93
|
+
## Configuration
|
|
94
|
+
|
|
95
|
+
| Env var | CLI flag | Meaning |
|
|
96
|
+
| ------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| `LOGIX_TAG_MCP_TIMEOUT` | `--timeout` | Socket timeout in seconds. Default: `5`. |
|
|
98
|
+
| `LOGIX_TAG_MCP_ALLOWED_HOSTS` | `--allowed-hosts` | Comma-separated hosts the server may connect to. Other hosts are refused. Default: any host. |
|
|
99
|
+
| `LOGIX_TAG_MCP_LOG_DIR` | `--log-dir` | Folder for logger files and the write audit log. Relative paths start at the folder the server runs in. Default: `logix-tag-mcp-logs`. |
|
|
100
|
+
| `LOGIX_TAG_MCP_ENABLE_WRITES` | `--enable-writes` | Register the `write_tag` tool. Default: off. |
|
|
101
|
+
| `LOGIX_TAG_MCP_WRITE_ALLOWLIST` | `--write-allowlist` | Comma-separated glob patterns. When set, only matching tags can be written. Default: none. |
|
|
102
|
+
|
|
103
|
+
Flags take precedence over environment variables. Boolean variables accept `1`, `true`, `yes` or `on`. Restart the server after changing its configuration.
|
|
104
|
+
|
|
105
|
+
## Tools
|
|
106
|
+
|
|
107
|
+
### Discovery tools
|
|
108
|
+
|
|
109
|
+
| Tool | Description |
|
|
110
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| `controller_info` | Controller name, product, firmware, serial number, key switch, programs, tasks, modules, tag count and clock. |
|
|
112
|
+
| `list_tags` | Paged tag list, filtered by name or glob, program and data type. Returns full names that `read_tags` accepts. |
|
|
113
|
+
| `get_data_type` | Members of a UDT, AOI, module or built-in type. |
|
|
114
|
+
| `refresh_tag_list` | Upload the tag list and data types again after a download or online edit. |
|
|
115
|
+
|
|
116
|
+
### Read tools
|
|
117
|
+
|
|
118
|
+
| Tool | Description |
|
|
119
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
120
|
+
| `read_tags` | Read any number of tags, members, bits, array elements or whole arrays in one batch. Each tag succeeds or fails on its own. |
|
|
121
|
+
| `read_struct` | Read a struct whole, or member by member up to 3 levels deep when the controller refuses the whole read. `members` filters large types such as axes. |
|
|
122
|
+
| `sample_tags` | Watch tags for up to 30 seconds and return only the changes, with timestamps. |
|
|
123
|
+
|
|
124
|
+
### Logger tools
|
|
125
|
+
|
|
126
|
+
| Tool | Description |
|
|
127
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
128
|
+
| `start_logger` | Log tags to a JSONL file on a background thread with its own connection. Logs on change or every sample, with an optional deadband. |
|
|
129
|
+
| `list_loggers` | Status of all loggers. |
|
|
130
|
+
| `get_logger_data` | Logged rows, filtered by time and tag, paged. |
|
|
131
|
+
| `get_logger_summary` | Per tag statistics and communication outages. Numbers get minimum, maximum and time-weighted mean. BOOLs get edges and time true and false. Other types get change counts. |
|
|
132
|
+
| `export_logger_csv` | Write a wide, forward-filled CSV next to the JSONL file for opening in Excel. |
|
|
133
|
+
| `stop_logger` | Stop a logger. |
|
|
134
|
+
|
|
135
|
+
Up to 5 loggers can run at once, with 100 tags each. The minimum interval is 50 ms. A logger runs for 1 hour by default and 24 hours at most. Loggers keep running through a lost connection and record `comm_error` and `comm_restored` events.
|
|
136
|
+
|
|
137
|
+
### Writing tags
|
|
138
|
+
|
|
139
|
+
`write_tag` is only registered when writes are enabled. It changes values in a running machine, which can start motion or change machine state. Enable it only when you mean to, and set an allowlist:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
claude mcp add logix-tags \
|
|
143
|
+
-e LOGIX_TAG_MCP_ENABLE_WRITES=1 \
|
|
144
|
+
-e "LOGIX_TAG_MCP_WRITE_ALLOWLIST=Program:MainProgram.Setpoint*" -- \
|
|
145
|
+
uvx logix-tag-mcp
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
How `write_tag` works:
|
|
149
|
+
|
|
150
|
+
- It refuses tags outside the allowlist, Read Only tags, and whole structs or arrays. Write members or elements instead.
|
|
151
|
+
- It checks the value against the tag type. BOOL takes only true, false, 0 or 1. Integers are range-checked. REALs must be finite. Strings are length-checked.
|
|
152
|
+
- It reads the current value first. With `expected_current`, it refuses the write if the value has changed. This check is not atomic, so logic can change the value between the check and the write.
|
|
153
|
+
- It sends the write once and never retries it. If the connection drops during the write, the result says the write may or may not have been applied.
|
|
154
|
+
- It reads the value back and warns if it differs. A difference usually means logic overwrites the tag every scan.
|
|
155
|
+
- It appends every attempt, including refusals, to `writes.jsonl` in the log folder.
|
|
156
|
+
|
|
157
|
+
## Tag names and l5x-mcp
|
|
158
|
+
|
|
159
|
+
Online, program tags are named `Program:<program>.<tag>`. `l5x-mcp` shows them by bare name with a program scope. Pass the bare name with `program` and the server resolves it the way Logix does. It looks for a program tag first, then a controller tag.
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
read_tags(host="192.168.1.10", tags=["Timer1.DN", "Motor1_Run"], program="MainProgram")
|
|
163
|
+
# Timer1.DN resolves to Program:MainProgram.Timer1.DN
|
|
164
|
+
# Motor1_Run resolves to the controller tag, because MainProgram has no tag with that name
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Fully qualified names such as `Program:MainProgram.Timer1` and `Local:1:I.Pt00.Data` are used unchanged.
|
|
168
|
+
|
|
169
|
+
## Controller behavior
|
|
170
|
+
|
|
171
|
+
- Tags with External Access set to None are not visible over the network. They read as if they do not exist. `l5x-mcp` shows each tag's `external_access`.
|
|
172
|
+
- The controller refuses whole reads of AOI instances, axes and module I/O structs such as `Local:1:I`. `read_tags` and `read_struct` fall back to reading their members. AOI local tags cannot be read, only parameters.
|
|
173
|
+
- BOOL arrays are stored as DWORDs. The server shows and reads them as BOOL arrays, so `Tag[5]` is bit 5.
|
|
174
|
+
- The controller clock is reported as the controller holds it, without timezone conversion.
|
|
175
|
+
- A dropped connection is reconnected on the next call. While the controller is unreachable, each call fails after about one timeout.
|
|
176
|
+
|
|
177
|
+
## Development
|
|
178
|
+
|
|
179
|
+
### Install from source
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
git clone https://github.com/zwood16/logix-tag-mcp.git
|
|
183
|
+
cd logix-tag-mcp
|
|
184
|
+
uv sync
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Running tests
|
|
188
|
+
|
|
189
|
+
This project uses `pytest` for tests and `ruff` for linting. Both are dev dependencies:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
uv run pytest
|
|
193
|
+
uv run ruff check
|
|
194
|
+
uv run ruff format
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The unit tests use a fake driver and need no hardware. Tests that need a real controller are marked `integration` and are skipped unless `LOGIX_TAG_MCP_TEST_HOST` is set to the controller address. Run only the offline tests, as the publish workflows do, with:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
uv run pytest -m "not integration"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
To use a source checkout with Claude Code, register `uv run --project /path/to/logix-tag-mcp --no-sync logix-tag-mcp`. Use `--project`, not `--directory`, so the server still starts in your project folder.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Logix Tag MCP
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> This project is still very early. Consider it an Alpha for the time being
|
|
5
|
+
|
|
6
|
+
`logix-tag-mcp` is a Python MCP server that lets a coding agent such as Claude Code or VS Code Chat read live tag values from a running Rockwell Logix PLC's (CompactLogix, ControlLogix, etc.). It talks to the controller over EtherNet/IP with [pycomm3](https://github.com/ottowayi/pycomm3).
|
|
7
|
+
|
|
8
|
+
It pairs with [l5x-mcp](https://github.com/zwood16/l5x-mcp). The agent reads the logic offline with `l5x-mcp` and checks the live values here while you debug online. Tag names can be passed exactly as `l5x-mcp` shows them, as a bare program tag name plus its program.
|
|
9
|
+
|
|
10
|
+
The server is read-only by default. The `write_tag` tool is only registered when the server is started with writes enabled. See [Writing tags](#writing-tags).
|
|
11
|
+
|
|
12
|
+
> [!NOTE]
|
|
13
|
+
> This project is not affiliated with Rockwell Automation in any way.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
`logix-tag-mcp` needs network access to the controller on EtherNet/IP port TCP 44818.
|
|
19
|
+
|
|
20
|
+
[uv](https://docs.astral.sh/uv/getting-started/installation/) is the recommended way to install and run `logix-tag-mcp`. `uvx` downloads and caches the package, so nothing needs to be installed in a specific folder or environment.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
uvx logix-tag-mcp --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The server is normally started by your MCP client. See [Register the MCP server](#register-the-mcp-server).
|
|
27
|
+
|
|
28
|
+
There is no default controller. Every tool that talks to a controller takes a required `host` argument, for example `192.168.1.10`, or `192.168.1.10/1` for a processor in slot 1. The agent asks you for the address when it does not know it.
|
|
29
|
+
|
|
30
|
+
### Install as a tool with uv (optional)
|
|
31
|
+
|
|
32
|
+
`uv` can also install `logix-tag-mcp` as a tool. This puts `logix-tag-mcp` on your PATH.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uv tool install logix-tag-mcp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Updating
|
|
39
|
+
|
|
40
|
+
`uvx` caches the package, so refresh it to pick up a new release with `uvx --refresh logix-tag-mcp --help`. MCP clients configured with `uvx logix-tag-mcp` use the new version after you restart them. With `uv tool install`, run `uv tool upgrade logix-tag-mcp`.
|
|
41
|
+
|
|
42
|
+
## Register the MCP server
|
|
43
|
+
|
|
44
|
+
### Claude Code
|
|
45
|
+
|
|
46
|
+
`-s user` registers the server for all your projects. Leave it out to add it to the current project only.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
claude mcp add -s user logix-tags -- uvx logix-tag-mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you installed it with `uv tool install`, replace `uvx logix-tag-mcp` with `logix-tag-mcp`. Server options go after the command, and environment variables go in `-e` options before `--`. For example:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
claude mcp add -s user logix-tags -e LOGIX_TAG_MCP_ALLOWED_HOSTS=192.168.1.10 -- uvx logix-tag-mcp
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Other MCP clients
|
|
59
|
+
|
|
60
|
+
Other clients need the same command and arguments. This example is a VS Code `.vscode/mcp.json`:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"servers": {
|
|
65
|
+
"logix-tags": {
|
|
66
|
+
"type": "stdio",
|
|
67
|
+
"command": "uvx",
|
|
68
|
+
"args": ["logix-tag-mcp"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
With `uv tool install`, use `"command": "logix-tag-mcp"` and no `args`. Claude Code also reads a project `.mcp.json`. See [`.mcp.json.example`](.mcp.json.example).
|
|
75
|
+
|
|
76
|
+
## Configuration
|
|
77
|
+
|
|
78
|
+
| Env var | CLI flag | Meaning |
|
|
79
|
+
| ------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `LOGIX_TAG_MCP_TIMEOUT` | `--timeout` | Socket timeout in seconds. Default: `5`. |
|
|
81
|
+
| `LOGIX_TAG_MCP_ALLOWED_HOSTS` | `--allowed-hosts` | Comma-separated hosts the server may connect to. Other hosts are refused. Default: any host. |
|
|
82
|
+
| `LOGIX_TAG_MCP_LOG_DIR` | `--log-dir` | Folder for logger files and the write audit log. Relative paths start at the folder the server runs in. Default: `logix-tag-mcp-logs`. |
|
|
83
|
+
| `LOGIX_TAG_MCP_ENABLE_WRITES` | `--enable-writes` | Register the `write_tag` tool. Default: off. |
|
|
84
|
+
| `LOGIX_TAG_MCP_WRITE_ALLOWLIST` | `--write-allowlist` | Comma-separated glob patterns. When set, only matching tags can be written. Default: none. |
|
|
85
|
+
|
|
86
|
+
Flags take precedence over environment variables. Boolean variables accept `1`, `true`, `yes` or `on`. Restart the server after changing its configuration.
|
|
87
|
+
|
|
88
|
+
## Tools
|
|
89
|
+
|
|
90
|
+
### Discovery tools
|
|
91
|
+
|
|
92
|
+
| Tool | Description |
|
|
93
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
94
|
+
| `controller_info` | Controller name, product, firmware, serial number, key switch, programs, tasks, modules, tag count and clock. |
|
|
95
|
+
| `list_tags` | Paged tag list, filtered by name or glob, program and data type. Returns full names that `read_tags` accepts. |
|
|
96
|
+
| `get_data_type` | Members of a UDT, AOI, module or built-in type. |
|
|
97
|
+
| `refresh_tag_list` | Upload the tag list and data types again after a download or online edit. |
|
|
98
|
+
|
|
99
|
+
### Read tools
|
|
100
|
+
|
|
101
|
+
| Tool | Description |
|
|
102
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
103
|
+
| `read_tags` | Read any number of tags, members, bits, array elements or whole arrays in one batch. Each tag succeeds or fails on its own. |
|
|
104
|
+
| `read_struct` | Read a struct whole, or member by member up to 3 levels deep when the controller refuses the whole read. `members` filters large types such as axes. |
|
|
105
|
+
| `sample_tags` | Watch tags for up to 30 seconds and return only the changes, with timestamps. |
|
|
106
|
+
|
|
107
|
+
### Logger tools
|
|
108
|
+
|
|
109
|
+
| Tool | Description |
|
|
110
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
+
| `start_logger` | Log tags to a JSONL file on a background thread with its own connection. Logs on change or every sample, with an optional deadband. |
|
|
112
|
+
| `list_loggers` | Status of all loggers. |
|
|
113
|
+
| `get_logger_data` | Logged rows, filtered by time and tag, paged. |
|
|
114
|
+
| `get_logger_summary` | Per tag statistics and communication outages. Numbers get minimum, maximum and time-weighted mean. BOOLs get edges and time true and false. Other types get change counts. |
|
|
115
|
+
| `export_logger_csv` | Write a wide, forward-filled CSV next to the JSONL file for opening in Excel. |
|
|
116
|
+
| `stop_logger` | Stop a logger. |
|
|
117
|
+
|
|
118
|
+
Up to 5 loggers can run at once, with 100 tags each. The minimum interval is 50 ms. A logger runs for 1 hour by default and 24 hours at most. Loggers keep running through a lost connection and record `comm_error` and `comm_restored` events.
|
|
119
|
+
|
|
120
|
+
### Writing tags
|
|
121
|
+
|
|
122
|
+
`write_tag` is only registered when writes are enabled. It changes values in a running machine, which can start motion or change machine state. Enable it only when you mean to, and set an allowlist:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
claude mcp add logix-tags \
|
|
126
|
+
-e LOGIX_TAG_MCP_ENABLE_WRITES=1 \
|
|
127
|
+
-e "LOGIX_TAG_MCP_WRITE_ALLOWLIST=Program:MainProgram.Setpoint*" -- \
|
|
128
|
+
uvx logix-tag-mcp
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
How `write_tag` works:
|
|
132
|
+
|
|
133
|
+
- It refuses tags outside the allowlist, Read Only tags, and whole structs or arrays. Write members or elements instead.
|
|
134
|
+
- It checks the value against the tag type. BOOL takes only true, false, 0 or 1. Integers are range-checked. REALs must be finite. Strings are length-checked.
|
|
135
|
+
- It reads the current value first. With `expected_current`, it refuses the write if the value has changed. This check is not atomic, so logic can change the value between the check and the write.
|
|
136
|
+
- It sends the write once and never retries it. If the connection drops during the write, the result says the write may or may not have been applied.
|
|
137
|
+
- It reads the value back and warns if it differs. A difference usually means logic overwrites the tag every scan.
|
|
138
|
+
- It appends every attempt, including refusals, to `writes.jsonl` in the log folder.
|
|
139
|
+
|
|
140
|
+
## Tag names and l5x-mcp
|
|
141
|
+
|
|
142
|
+
Online, program tags are named `Program:<program>.<tag>`. `l5x-mcp` shows them by bare name with a program scope. Pass the bare name with `program` and the server resolves it the way Logix does. It looks for a program tag first, then a controller tag.
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
read_tags(host="192.168.1.10", tags=["Timer1.DN", "Motor1_Run"], program="MainProgram")
|
|
146
|
+
# Timer1.DN resolves to Program:MainProgram.Timer1.DN
|
|
147
|
+
# Motor1_Run resolves to the controller tag, because MainProgram has no tag with that name
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Fully qualified names such as `Program:MainProgram.Timer1` and `Local:1:I.Pt00.Data` are used unchanged.
|
|
151
|
+
|
|
152
|
+
## Controller behavior
|
|
153
|
+
|
|
154
|
+
- Tags with External Access set to None are not visible over the network. They read as if they do not exist. `l5x-mcp` shows each tag's `external_access`.
|
|
155
|
+
- The controller refuses whole reads of AOI instances, axes and module I/O structs such as `Local:1:I`. `read_tags` and `read_struct` fall back to reading their members. AOI local tags cannot be read, only parameters.
|
|
156
|
+
- BOOL arrays are stored as DWORDs. The server shows and reads them as BOOL arrays, so `Tag[5]` is bit 5.
|
|
157
|
+
- The controller clock is reported as the controller holds it, without timezone conversion.
|
|
158
|
+
- A dropped connection is reconnected on the next call. While the controller is unreachable, each call fails after about one timeout.
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
### Install from source
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
git clone https://github.com/zwood16/logix-tag-mcp.git
|
|
166
|
+
cd logix-tag-mcp
|
|
167
|
+
uv sync
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Running tests
|
|
171
|
+
|
|
172
|
+
This project uses `pytest` for tests and `ruff` for linting. Both are dev dependencies:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
uv run pytest
|
|
176
|
+
uv run ruff check
|
|
177
|
+
uv run ruff format
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The unit tests use a fake driver and need no hardware. Tests that need a real controller are marked `integration` and are skipped unless `LOGIX_TAG_MCP_TEST_HOST` is set to the controller address. Run only the offline tests, as the publish workflows do, with:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
uv run pytest -m "not integration"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
To use a source checkout with Claude Code, register `uv run --project /path/to/logix-tag-mcp --no-sync logix-tag-mcp`. Use `--project`, not `--directory`, so the server still starts in your project folder.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "logix-tag-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP server for reading (and optionally writing) live Logix controller tags"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = [
|
|
9
|
+
"mcp",
|
|
10
|
+
"logix",
|
|
11
|
+
"plc",
|
|
12
|
+
"rockwell",
|
|
13
|
+
"controllogix",
|
|
14
|
+
"compactlogix",
|
|
15
|
+
"ethernet/ip",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Topic :: Software Development",
|
|
21
|
+
]
|
|
22
|
+
requires-python = ">=3.12"
|
|
23
|
+
dependencies = [
|
|
24
|
+
"mcp[cli]>=2.3.0",
|
|
25
|
+
"pycomm3>=1.2.16",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Repository = "https://github.com/zwood16/logix-tag-mcp"
|
|
30
|
+
Issues = "https://github.com/zwood16/logix-tag-mcp/issues"
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
logix-tag-mcp = "logix_tag_mcp:main"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["uv_build>=0.13.8,<0.14.0"]
|
|
37
|
+
build-backend = "uv_build"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=9.2.0",
|
|
42
|
+
"ruff>=0.17.6",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[tool.ruff]
|
|
46
|
+
line-length = 88
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
select = [
|
|
50
|
+
"E",
|
|
51
|
+
"F",
|
|
52
|
+
"I",
|
|
53
|
+
"UP",
|
|
54
|
+
"B",
|
|
55
|
+
"SIM",
|
|
56
|
+
"D",
|
|
57
|
+
"ANN",
|
|
58
|
+
]
|
|
59
|
+
ignore = ["ANN401"]
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint.pydocstyle]
|
|
62
|
+
convention = "google"
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint.per-file-ignores]
|
|
65
|
+
"tests/**" = ["D"]
|
|
66
|
+
|
|
67
|
+
[tool.pytest.ini_options]
|
|
68
|
+
testpaths = ["tests"]
|
|
69
|
+
addopts = "--strict-markers"
|
|
70
|
+
markers = ["integration: needs a reachable Logix controller (set LOGIX_TAG_MCP_TEST_HOST)"]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "logix-tag-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP server for reading (and optionally writing) live Logix controller tags"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = ["mcp", "logix", "plc", "rockwell", "controllogix", "compactlogix", "ethernet/ip"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"Operating System :: OS Independent",
|
|
12
|
+
"Topic :: Software Development",
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.12"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"mcp[cli]>=2.3.0",
|
|
17
|
+
"pycomm3>=1.2.16",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Repository = "https://github.com/zwood16/logix-tag-mcp"
|
|
22
|
+
Issues = "https://github.com/zwood16/logix-tag-mcp/issues"
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
logix-tag-mcp = "logix_tag_mcp:main"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["uv_build>=0.13.8,<0.14.0"]
|
|
29
|
+
build-backend = "uv_build"
|
|
30
|
+
|
|
31
|
+
[dependency-groups]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=9.2.0",
|
|
34
|
+
"ruff>=0.17.6",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[tool.ruff]
|
|
38
|
+
line-length = 88
|
|
39
|
+
|
|
40
|
+
[tool.ruff.lint]
|
|
41
|
+
# The rule categories to enable.
|
|
42
|
+
select = [
|
|
43
|
+
"E", # pycodestyle (catches formatting-adjacent errors)
|
|
44
|
+
"F", # Pyflakes (catches logical errors, like unused variables)
|
|
45
|
+
"I", # isort (automatically sorts your imports)
|
|
46
|
+
"UP", # pyupgrade (suggests modern syntax upgrades)
|
|
47
|
+
"B", # flake8-bugbear (catches common bugs and gotchas)
|
|
48
|
+
"SIM", # flake8-simplify (suggests cleaner, more elegant code)
|
|
49
|
+
"D", # pydocstyle (docstrings, for generated API docs)
|
|
50
|
+
"ANN", # flake8-annotations (type hints)
|
|
51
|
+
]
|
|
52
|
+
# Live PLC tag values are dynamically typed (BOOL/DINT/REAL/STRING/structs/
|
|
53
|
+
# arrays), so `Any` is the honest annotation for them.
|
|
54
|
+
ignore = ["ANN401"]
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint.pydocstyle]
|
|
57
|
+
convention = "google"
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint.per-file-ignores]
|
|
60
|
+
"tests/**" = ["D"]
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
addopts = "--strict-markers"
|
|
65
|
+
markers = [
|
|
66
|
+
"integration: needs a reachable Logix controller (set LOGIX_TAG_MCP_TEST_HOST)",
|
|
67
|
+
]
|