Metadata-Version: 2.3
Name: logix-help-mcp
Version: 1.0.1
Summary: MCP server that indexes the Studio 5000 Logix Designer help into SQLite FTS5 and exposes search and read tools
Requires-Dist: mcp>=2.3
Requires-Dist: platformdirs>=4.14.5
Requires-Dist: selectolax>=1.0.2
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# Logix Help MCP

`logix-help-mcp` is a Python MCP server that indexes the help that ships with Studio 5000 Logix Designer **v31–v38+** into a local SQLite FTS5 database so that a coding agent (Claude Code, VS Code Chat, etc.) can easily read through the help contents. 

The index of help documents is built locally from your own licensed install of Studio 5000 Logix Designer. No Rockwell content is included. The tool automatically detects every version of the help it finds and builds an index for each one.

> [!NOTE]
> Versions older than v31 are currently unsupported as they use a different format for the help docs. Versions up to the current v38 have been tested.
>
> This project is not affiliated with Rockwell Automation in any way.

## Quick Start

### Install and Build the Index
[uv](https://docs.astral.sh/uv/getting-started/installation/) is the recommended way to install and run `logix-help-mcp`. `uvx` can cache the package and rerun it without the need to install it in a specific folder or environment.

```bash
uvx logix-help-mcp --root "/path/to/Studio 5000" --build --all
```

`--root` works in any shell. You can also set the `S5K_HELP_ROOT` environment variable instead.

On Linux
```bash
S5K_HELP_ROOT="/path/to/Studio 5000" uvx logix-help-mcp --build --all
``` 
Or in Powershell on Windows
```
$env:S5K_HELP_ROOT = "C:\path\to\Studio 5000"
```

Users on Windows with the default Studio 5000 install location (`C:\Program Files (x86)\Rockwell Software\Studio 5000`) can skip `--root` and simply run:

```bash
uvx logix-help-mcp --build --all
```

> [!NOTE]
> With the `--build --all` options the server will not run, it will just build the indexes. The server will typically be run by your MCP client (see [Register the MCP Server](#register-the-mcp-server))


### Install as a Tool with UV (optional)

`uv` can also register `logix-help-mcp` as a tool. This puts `logix-help-mcp` on your PATH to make calling it easier.

```bash
uv tool install logix-help-mcp
```

Then to run it:
```bash
logix-help-mcp --build --all
```

## Register the MCP Server

### Claude Code

`-s user` registers the server for all your projects. Leave it out to add it to the current project only.

```bash
claude mcp add -s user logix-help -e S5K_HELP_ROOT="/path/to/Studio 5000" -- uvx logix-help-mcp
```

If you installed it with `uv tool install`, replace `uvx logix-help-mcp` with `logix-help-mcp`.

### Other MCP clients

Other clients (e.g. VS Code `.vscode/mcp.json`) need the same command, arguments and environment. 

```json
{
    "servers": {
        "logix-help": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "logix-help-mcp"
            ],
            "env": { "S5K_HELP_ROOT": "/path/to/Studio 5000" }
        }
    }
}
```

With `uv tool install`, use `"command": "logix-help-mcp"` and no `args`.

## First start

The first start builds the default (newest) version's index in the background. That takes a few seconds to about a minute, depending on disk or network speed, and tools wait for it. Other versions build the first time a tool asks for them. Later starts reuse the cache unless the help files changed. The cache lives in your user cache directory, not in the install, so upgrading the package keeps it. A new schema version rebuilds it automatically.

## Configuration

| Env var         | CLI flag                             | Meaning                                                                                                                                                                                                         |
| --------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `S5K_HELP_ROOT` | `--root`                             | The `Studio 5000` install folder, the `Logix Designer/ENU` folder, or one `rs5000` help folder. Folders are scanned for `Logix Designer/ENU/v*/Bin/Help/ENU/rs5000` (v33+) and `Help/ENU/v*/rs5000` (v31, v32). |
| `S5K_VERSION`   | `--version`                          | Default version, e.g. `v37` (default: the newest version found; a requested version that is not found falls back to it with a warning).                                                                         |
| `S5K_DB_DIR`    |                                      | Where index databases are stored (default: user cache dir for `logix-help-mcp`).                                                                                                                           |
|                 | `--force-rebuild`                    | Rebuild even if the cache is fresh.                                                                                                                                                                             |
|                 | `--transport stdio\|streamable-http` | Default `stdio`.                                                                                                                                                                                                |
|                 | `--build-only`                       | Build the index, print statistics and timing, exit.                                                                                                                                                             |
|                 | `--all`                              | With `--build-only`: build every discovered version, one summary line each (exit 1 if any fails).                                                                                                               |

### Index Builds
The index is one SQLite file per version. It is rebuilt when the help folder's HTML files, TOC files, or metadata files (`context-help-map.xml`, `rs5000.csv`, `index.xml`) change, or when the schema version changes. The help folder is only ever read.

### Unreachable Help Folder
If the help folder is unreachable - such as when a network share is offline - versions that already have a cached index are still served from the cache. `get_image` does not work until the folder is back, because images are not cached.

If no help folder is found, the server looks again on later tool calls (at most every 30 s), so it picks the folder up once it is reachable, without a restart.

### Multiple Versions

- Discovery: v33+ help is expected in `Logix Designer/ENU/v*/Bin/Help/ENU/rs5000` and v31–v32 help in `Help/ENU/v*/rs5000` under the `Studio 5000` install folder.
- The newest version is the default version. Every tool takes an optional `version`: `'v33'` or a project revision such as `'33.01'` so that an agent can check against the correct version.


## Tools

| Tool                  | Description                                                                                                                       |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `search_help`         | Keyword search. Returns page IDs, titles, breadcrumbs and short snippets. Filter by `kind` (instruction, fault, module, dialog, command, concept) or `section`. |
| `get_page`            | Read a page as Markdown, with tables kept. Long pages are paginated with `offset` / `max_chars`.                                 |
| `get_instruction`     | Read an instruction page by mnemonic, e.g. `TON`, `GSV`, `MAOC`. Paginated like `get_page`.                                       |
| `get_image`           | Get a graphic referenced in a page's Markdown, e.g. a ladder or FBD diagram.                                                      |
| `get_page_by_help_id` | Find the page for an F1 / context help ID, numeric (`131173`) or named (`about_the_status_bar`).                                  |
| `browse_toc`          | List the table of contents, one level at a time.                                                                                  |
| `get_breadcrumb`      | Show where a page sits in the help hierarchy.                                                                                     |
| `list_versions`       | List the help versions found, their format and index state.                                                                       |
| `get_help_statistics` | Show index statistics and build progress.                                                                                         |

Every tool except `list_versions` takes an optional `version`. Search snippets are not page content; the server instructions tell the model to read the page with `get_page`.

- **Page IDs:** a page's `page_id` is its help topic ID (e.g. `ait_455128`) when that ID is unique. Some pages share a topic ID (duplicated pages such as the GSV/SSV pages); those use their help-relative path instead (e.g. `help/clinset/...html`). Every tool that takes a `page_id` accepts either form.
- **Renamed instructions:** v36 renamed several mnemonics (MOV→MOVE, EQU→EQ, NEQ→NE, LES→LT, GRT→GT, LEQ→LE, GEQ→GE, LIM→LIMIT, SQR→SQRT, XPY→EXPT, TOD→TO_BCD, FRD→BCD_TO, TRN→TRUNC, ACS→ACOS, ASN→ASIN, ATN→ATAN). `get_instruction` accepts either name in any version and says when it mapped one.
- **Errors:** failures (unknown page, TOC node or version, invalid `kind`, index still building) are returned as MCP tool errors (`is_error: true`). Valid empty outcomes, such as no search hits or an unmapped help ID, are normal results.

## Development

### Install from source

```bash
git clone https://github.com/zwood16/logix-help-mcp
cd logix-help-mcp
uv run logix-help-mcp
```

### Running Tests
This project uses `pytest` for tests and `ruff` for linting. Both are dev dependencies, so from the repository run:

```bash
uv run pytest
uv run ruff check
```

Integration tests need a real help install and are skipped unless `S5K_HELP_ROOT` is set. `uv run pytest -m "not integration"` runs only the offline tests.

