Skip to main content
Glama
twincat-project-mcp

twincat-project-mcp

twincat-project-mcp

Inspect a saved Beckhoff TwinCAT 3 project from Codex, Claude Code or another local stdio MCP client. Open a system or PLC project to see which files it includes, which references could be resolved and the SHA-256 of each file and of the project manifest. The Python 3.12+ reader runs without XAE, an ADS route or a PLC.

First read

From this checkout, use uv to install the locked development environment and exercise the actual stdio server with the bundled synthetic program.

uv sync --locked
uv run twincat-project-mcp-doctor

Expect a PASS with the hash of MAIN.TcPOU. To check your own input, pass --project /absolute/path/to/MAIN.TcPOU. Compare its reported digest with Get-FileHash -Algorithm SHA256 on Windows or sha256sum on Linux.

Configure your client's stdio launcher with the absolute path to .venv/Scripts/twincat-project-mcp.exe on Windows or .venv/bin/twincat-project-mcp on Linux. The server captures its inputs at startup. Restart it to inspect a new saved revision.

{
  "mcpServers": {
    "twincat-project": {
      "command": "C:/path/to/twincat-project-mcp/.venv/Scripts/twincat-project-mcp.exe",
      "args": ["--project", "C:/path/to/MAIN.TcPOU"]
    }
  }
}

This is the JSON form for clients using mcpServers. For Codex, register the same executable and arguments with codex mcp add twincat-project -- <executable> --project <absolute-file>. Ask “Where is ready declared and which line sets it?” when using the bundled example.

Related MCP server: ACE-MCP

Inspect a project

Pass a saved system or PLC project to the same launcher. To verify a project before opening your MCP client, run the doctor against it.

uv run twincat-project-mcp-doctor --project /checkout/plc/Cell.tsproj

By default, capture stays inside the entry file’s directory. If the project includes a sibling folder, pass --root /checkout to authorize the common parent. The doctor reports the entry hash, manifest hash, captured file count and unresolved reference count.

Tool

Result

get_capabilities

Supported formats, scope and whether a comparison input was selected.

get_project

Entry identity, object kind, visible sections and direct references. For project entries, includes the manifest hash and counts of captured files and unresolved references.

list_inventory

Page through files, references, diagnostics, projects, instances, tasks, libraries, objects or coverage notes. Each page identifies its manifest.

read_object

For project entries, pass the object ID from a search or inventory result. Returns the requested section lines, owning PLC, file hash and locator. For a single source file, select its top-level section directly.

search_project

Paged literal search in captured declarations and ST bodies. Filter by PLC path, object kind or section. Each project hit identifies its owner, object, file hash and one-based section line.

compare_projects

Enabled by --compare-project <second-file>. Returns both file hashes and the fields that changed in the supported projection.

From a .tsproj, capture follows explicit PLC project paths and recognized split PLC descriptors. For example, a PLC project with File="Cell.xti" resolves under _Config/PLC. Its PrjFilePath resolves relative to that XTI. From each .plcproj, capture follows literal, unconditional compile items for POUs, GVLs, DUTs, PLC tasks and interfaces. Task inventory distinguishes system tasks, PLC tasks and their saved program calls. Library rows show saved references and placeholder resolutions.

For example, from the demo system project, call search_project with the following arguments to find uses of the status buffer in method bodies.

{"request":{"query":"StatusBuffer[","plc":"CartonPLC/CartonPLC.plcproj","kind":"Method","section":"implementation","limit":5}}

To continue, repeat the request with the returned next_cursor in request.cursor. The query and filters must match. You can change the page size (1–100). A null cursor marks the last page. On an empty project search, searched_objects counts objects eligible under the filters. The unresolved-reference and coverage counts describe the entire capture. Use list_inventory with diagnostics or coverage to inspect those gaps.

Check isError before interpreting a tool response. An inspection failure carries error.code, hint, retryable and the selected source identity in both structured content and JSON text. After invalid_cursor, reuse the original query or start a new search. After snapshot_mismatch, repeat the lookup on the current snapshot. For a project read_object, pass the hit’s object_id and optional snapshot_sha256 to verify the revision.

Try the public CartonPLC demo

Open plc/CartonCell.tsproj and ask “Where is the status array declared, where does the heartbeat advance, and where is the array published?” In revision 172b616, the declaration is on line 5 of the GVL_HMI declaration. In the PublishStatus method, implementation line 13 advances word 9 and line 17 publishes the array. These are section-relative lines. The links open the corresponding XML lines. Starting at plc/CartonPLC/CartonPLC.plcproj yields the same three source locations. Public demo repository · Status declaration · Heartbeat and publication

Capture accepts local regular files up to 2 MiB each, 32 MiB and 2,048 files in total. It rejects DTDs and links, and compares two captures before serving a session. Restart the server after a save to inspect the new revision. Requested source excerpts are visible to the MCP client you choose.

Optional physical CX check

On a Windows engineering PC with the TwinCAT ADS library and an existing route to a CX running the CartonPLC demo, install the extra and explicitly select the target. In XAE, SYSTEM → Routes lists remote AMS Net IDs. Use the PLC instance’s AMS port. The demo uses 851.

uv sync --locked --extra ads
uv run --no-sync twincat-carton-probe --net-id <six-octet-net-id> --port 851

This separate CLI reads only GVL_HMI.Status. It checks the declared 106-DINT array, transfer length and signature 51003 before reporting two host-timestamped state and heartbeat samples. An unchanged heartbeat is reported as observed. PLC writes, subscriptions and route creation are outside the probe. Physical bench result

Development

uv run ruff format --check .
uv run ruff check .
uv run pyright
uv run pytest
uv build --wheel

CI tests the built wheel on Windows and Linux with Python 3.12 and 3.13. The automated tests use synthetic data and local stdio. Architecture and design · Peer feature analysis · Contributor rules

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables AI agents to read and understand local Mendix project structure and logic by connecting directly to the .mpr file via MCP. Allows querying microflows, entities, attributes, and modules in read-only mode without requiring cloud access.
      4
      1
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI clients to perform local code search, indexing, and analysis across Java, JavaScript/TypeScript, .NET/C#, and Python projects through the MCP protocol.
      1
      Apache 2.0
    • F
      license
      A
      quality
      B
      maintenance
      Provides read-only analysis of Mitsubishi GX Works3 PLC projects via MCP, enabling device tracing, cross-referencing, ladder inspection, linting, and report generation without modifying source projects.
      15
      62 PyPI
      10
      -