Skip to main content
Glama
turnout
by guimarais

Turnout connects your AI assistant to model railway planning. It is a local Model Context Protocol (MCP) server for Märklin C-track layouts in XTrackCAD: describe what you want, let Python handle the geometry, then review the result in your drawing editor.

What it does

  • Explore your track. Search the catalogue for track pieces, including their geometry, paths and connection points.

  • Understand a layout. Inspect an existing .xtc file, count its pieces, identify open ends and connection issues, and see a labelled SVG preview.

  • Extend existing track. Attach a catalogue piece to an open endpoint, including turnouts and buffer stops, and save a separate revision with a preview.

  • Build a closed oval. Generate a layout from real catalogue pieces, with checks for closure, board fit and centreline intersections.

XTrackCAD remains your editor for detailed changes, printing and train operation. Turnout works with local files and writes generated layouts separately. It does not call a model or require an API key; you bring your own MCP-compatible AI client.

Closed-loop generation supports ordinary straights and curves. Connected extension supports all 43 pieces in the bundled catalogue, one piece at a time, using one track system per layout. Roadbed and vehicle clearance are outside the current scope; XTrackCAD open/save verification for connected extension remains pending. See the guide for limits and the roadmap for plans.

Related MCP server: KiCAD MCP Server

Install

You need Python 3.13+, uv, an MCP-compatible AI client, and XTrackCAD to open and review layouts. The commands below use a macOS or Linux shell.

git clone https://github.com/guimarais/turnout.git
cd turnout
uv sync --locked

Keep this checkout in place: Turnout uses the catalogue and example files here. Installation currently runs from source.

For Codex, run these commands from the repository root with the Codex CLI installed:

codex mcp add turnout -- "$PWD/.venv/bin/python" -m turnout
codex mcp get turnout

Open a new chat or restart the client if the tools are not visible. Other clients can launch the same stdio server; see the connection guide for the launch command and configuration example.

Use

Start by asking your connected AI assistant to inspect the supplied layout:

Use turnout to inspect examples/mrkln_sample.xtc. Show the labelled preview, list its open endpoints, and explain any connection issues.

To extend it:

Use turnout to attach a Märklin 24188 straight to open endpoint 4:2 in examples/mrkln_sample.xtc. Save a separate revision and show its preview.

Or try generating a layout:

Use turnout to make a closed oval on a 2000 × 1200 mm board. Use six Märklin 24130 curves, one 24188 straight, six more 24130 curves, then another 24188 straight. Return the file path and parts list.

Open the returned .xtc file in XTrackCAD and review its geometry and connections. Save any manual changes as a separate file and use that file for the next inspection. Generated layouts go into layouts/; previews go into previews/.

For tool arguments, supported file records, geometry limits and compatibility checks, read the Turnout guide.


Contributing · Roadmap · GPL-3.0 license

Available Tools

2 tools
build_layoutA

Build a flat closed loop from an ordered list of catalogue part numbers.

Python attaches endpoint 0 to the previous endpoint 1. All curves turn left. Example oval: six 24130, one 24188, six 24130, one 24188. Centres the result on the board with a fixed 50 mm centreline edge margin. Rejects gaps >0.1 mm, angle errors >0.1 degrees, crossings and overlaps. On failure returns measured errors and writes nothing. On success creates a unique .xtc in this project's layouts/ and returns its path and parts list. Does not open XTrackCAD or check rolling-stock clearance.

Inputs: parts (required), width_mm, height_mm. Returns: object

list_partsA

Find supported ordinary Märklin C-track straights/curves by number or description.

Dimensions are mm. Build sequences enter endpoint 0 and leave endpoint 1; curves turn left. Turnouts, special tracks and catalogue editing are unsupported.

Inputs: query. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct roles: list_parts is a catalogue lookup, while build_layout performs construction and validation. There is no realistic ambiguity about which tool to use for a given request.

    Naming Consistency5/5

    Both names follow a consistent snake_case verb_noun pattern: list_parts and build_layout. The convention is predictable and easy to extend.

    Tool Count3/5

    Two tools is quite thin for a layout-building server, though each has a clear purpose. The surface feels minimal rather than well-scoped, with most capability concentrated in build_layout.

    Completeness3/5

    The server covers part lookup and layout creation, but lacks lifecycle operations such as listing, inspecting, updating, or deleting existing layouts. It also explicitly excludes turnouts despite the server name, which creates a notable domain gap.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants like Claude to interact with KiCAD for PCB design automation, providing comprehensive tool schemas and real-time project state access.
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with KiCAD for PCB design automation. Users can design PCBs using natural language, including component placement, routing, checks, and export.
      1
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI assistants to interact with KiCAD for PCB design automation, including schematic editing, component placement, routing, DRC/ERC, and export.
      100
      38 npm
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables an AI agent to do end-to-end PCB design work — component sourcing, schematic construction, placement, routing, SPICE simulation and manufacturing export — by driving KiCad through its project files and kicad-cli, with no running GUI required. Boards are only reported as routed or done when a machine-checked verification gate returns an unambiguous PASS, so unverified or partially checked results are never presented as finished.
      19
      MIT