turnout
A local MCP server for planning Märklin C-track layouts in XTrackCAD, currently exposing two tools.
Search catalogue parts: find supported ordinary Märklin C-track straights and curves by part number or description.
Build closed layouts: create a flat closed loop from an ordered list of catalogue part numbers on a specified board size.
Validate geometry: reject gaps, angle errors, crossings and overlaps, returning measured errors on failure.
Save results: on success write a unique
.xtcfile underlayouts/and return its path and parts list.
Limitations: no turnouts, special tracks or catalogue editing; curves always turn left; it does not check rolling-stock clearance or open XTrackCAD.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@turnout build a closed oval on a 2000x1200 mm board with twelve 24130 curves and two 24188 straights"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
.xtcfile, 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 --lockedKeep 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 turnoutOpen 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:2inexamples/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.
Available Tools
2 toolsbuild_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
Scored across 2 tools
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.
Both names follow a consistent snake_case verb_noun pattern: list_parts and build_layout. The convention is predictable and easy to extend.
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.
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
Related MCP Connectors
Parametric 3D CAD for AI agents: build print-ready parts, check them, export STL, 3MF or STEP.
Design, route, check, review and export manufacturable PCBs from plain language; KiCad import.
Build KiCad PCBs from requirements: schematic, placed and routed board, ERC/DRC. Read and edit them.
Design redstone machines with your AI and test them tick by tick with Java Edition 26.3 rules.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants like Claude to interact with KiCAD for PCB design automation, providing comprehensive tool schemas and real-time project state access.3MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with KiCAD for PCB design automation. Users can design PCBs using natural language, including component placement, routing, checks, and export.1MIT
- AlicenseBqualityCmaintenanceEnables AI assistants to interact with KiCAD for PCB design automation, including schematic editing, component placement, routing, DRC/ERC, and export.10038 npm2MIT
- AlicenseAqualityBmaintenanceEnables 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.19MIT