JMRI MCP

io.github.HO44-PROJECT由 GitHub 帳號 HO44-PROJECT 發布v1.0.0rc4更新於 Oct 24, 2026

JMRI voice/chat control for DCC model railroads

已驗證STDIO僅桌面

概覽

AI 產生的概覽

此 MCP 伺服器讓 AI 助理透過聊天或語音控制 JMRI 驅動的 DCC 模型鐵路:機車、道岔、號誌、燈光與電源。

可以做什麼
管理配置電源,包括未知狀態復原,以及全配置狀態總覽與晝夜模式。駕駛機車:取得手柄、設定速度與方向、開關功能。讀取與管理機車名冊,包括每台機車所屬的命令站。列出並操作道岔、感測器、號誌、閉塞區與配置燈光,每次寫入後都重新讀取實際狀態確認。
適用情境
當你執行 JMRI 與 DCC 配置,希望透過支援 MCP 的助理以自然語言駕駛列車、扳動道岔或管理號誌與燈光,而不是使用 JMRI 面板或命令列時使用。
執行需求
以僅限桌面的本機程序執行。需要 Python 3.10 或更新版本,以及正在執行的 JMRI Web 伺服器(已在 JMRI 5.4 上測試)。JMRI_URL 變數設定伺服器位址,預設指向本機位址。未宣告身分驗證。
安裝前請注意
指令作用於真實硬體:手柄、道岔、號誌與電源會改變實體配置,且每次寫入都會重新讀取並回報。展覽模式將機車限制在允許的 DCC 位址內,退出需 EXHIBITION_PASSWORD 設定的密碼,其預設值是眾所皆知的弱密碼,公開展示前應修改。專案採用 AGPL-3.0-or-later 授權,再散布時須保留署名。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 JMRI MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

MrJ JMRI AI Assistant

Version française

[PyPI - jmri-mcp] [PyPI - jmri-cli] [PyPI - jmri-core] [Downloads] [GitHub Release]

License & attribution — please read before reusing this work. This project is © HO44 PROJECT (MrJ) and licensed under AGPL-3.0-or-later (see LICENSE). If you redistribute, modify, or republish any part of this project — jmri-core, jmri-cli, jmri-mcp, the .mcpb/.codex.zip bundles, or the documentation — on this repository or anywhere else (a fork, another platform, a package registry, a video, a write-up), you must:

  • keep the original author credit (MrJ / HO44 PROJECT) and a link back to this repository, and
  • keep the same AGPL-3.0-or-later license on any redistributed or modified version.

Removing or hiding this attribution is not just bad etiquette — under AGPL-3.0 it is a license violation, and it will be treated as one. See NOTICE.md for details.

Questions or general discussion: use GitHub Discussions. Bug reports and feature requests: use Issues.

Talk to your model railroad.

Bring AI to your JMRI powered layout. Connect your favorite AI assistant and control your DCC model railroad using natural language through voice or chat.

Drive locomotives, control turnouts, operate signals, manage layout accessories, and more — just by asking.

Compatible with MCP clients such as Claude Desktop, Claude Code, xiaozhi, and other MCP-compatible AI assistants.

Features

MrJ JMRI AI Assistant provides:

  • Ready-to-use package for easy installation
  • Full documentation with setup guides and usage examples
  • A complete MCP (Model Context Protocol) server for JMRI integration
  • A command-line interface (jmri-cli) for direct control, scripting, and automation
  • 52 MCP tools exposing the main JMRI capabilities:
    • Power management
    • Locomotive throttles and functions
    • Roster management
    • Turnouts
    • Sensors
    • Layout lights
    • Signals
    • Blocks
    • Operating modes
    • Layout-wide meta tools (status overview, secure/night/day mode)

See the complete MCP tools reference in mcp-tools.md.

The goal is simple: make advanced JMRI control accessible to every model railroader, from casual operators to automation enthusiasts.

Built on real hardware, not just the JMRI docs

This project was developed against a real DCC++ layout with multiple command stations, and several of its behaviors exist specifically because live hardware doesn't always behave the way the JMRI API documentation implies:

  • Self-healing UNKNOWN power states. Re-sending a command station's current power state (a naive "set power ON" when it's already ON) is a known JMRI/DCC++ trap: it knocks the system into an UNKNOWN state instead of being a safe no-op. Every power command re-reads current state first and skips redundant POSTs — and if a genuine ON request still lands in UNKNOWN, it automatically recovers with an OFF → wait → ON retry sequence, rather than leaving the layout stuck.
  • Per-locomotive command station affinity. On a layout with more than one DCC connection, sending a locomotive's throttle commands to the wrong command station doesn't raise an error — it's just silently inaudible to the decoder. Roster entries can declare which connection they normally run on via a DccSystem custom attribute (set in JMRI's own Roster Entry → Edit → Attributes tab, e.g. DccSystem = T), and throttle acquisition reads it automatically to target the right station.
  • DCC connection and hardware address surfaced on every turnout, light, and signal. Listing a turnout, light, or signal reports which DCC connection actually drives it (resolved from its JMRI system name, e.g. OT23 → ohara (turnouts)) alongside its raw hardware address where JMRI exposes one (turnouts and lights; signal masts don't expose theirs via any JMRI API today, so that field is honestly reported as unknown rather than guessed).
  • Every write is confirmed by re-reading real state, never by trusting the response. Power, turnout, light, and signal commands all re-read JMRI's actual state after acting, and report exactly what was observed — including when that doesn't match what was asked for — instead of assuming a 200 response means the layout did what was requested.
  • Throttle state stays live even when driven from elsewhere. JMRI broadcasts every throttle change (speed, direction, functions) to all clients holding that locomotive — including other JMRI panels or a second MCP session — and this project's throttle cache is kept continuously in sync with that stream, not just with its own commands, so it never reports stale state after someone else drives the train.

What can I say?

Pick the page that matches what you want to do — each links to the next. Available in English and French:

  • 🚂 Conductor — just want to drive trains? Start here. English · Français
  • 🔧 Tinkerer — managing power, turnouts, signals, and the whole layout. English · Français
  • 🛠️ Engineer — full tool reference, CLI, scripting, and JMRI internals. English · Français

The conductor/tinkerer/engineer split is borrowed from DCC-EX, who came up with this framing first.

Installation

Getting started is designed to be simple.

See the installation guide for every install combination (CLI, Claude Desktop .mcpb, Kira bridge), configuration, and first commands.

Prefer a step-by-step walkthrough with screenshots? See the community Instructable: Control Your JMRI Railroad by Chatting With Claude.

AI Assistant Setup

Command Line Interface

jmri-cli is a full-featured command-line client for your layout, talking to JMRI directly with no AI assistant or MCP client required — everything the MCP tools can do, a human can do too, from a terminal.

Run it bare with no arguments to open an interactive shell: a single persistent connection that keeps locomotives moving, lit, and acquired between commands (unlike a one-shot invocation, which releases every throttle the instant it exits). The shell adds real command-line ergonomics on top: up/down arrow command history persisted across sessions (~/.jmri-cli/shell_history), TAB completion across the entire command tree, ;-separated multi-command lines, a wait command to sequence a --hold and a following command, and a friendlier natural-language-ish sentence syntax for speed/direction (speed Autorail at 30 for 30 up 5 down 6 forward, or move Autorail forward at 30 for 30) alongside the regular flag-based form. select <loco> picks a locomotive for the rest of the session — the prompt switches to its name, and every command with an otherwise-optional or -mandatory loco argument (stop, speed 40, function-on F0, ...) targets it automatically until clear; a loco named explicitly on a line still overrides the selection for that one command. Exiting always leaves the layout safe: any locomotive still in motion gets a ramp-down-and-release prompt, and active functions (lights) are turned off before the connection closes, rather than being abandoned.

Every command also works one-shot from a plain terminal for scripting, automation, and quick manual checks or troubleshooting against a real layout.

See the CLI reference.

MCP Tools

The MCP server currently exposes 52 tools covering the main JMRI capabilities.

See the complete reference:

Status

v1.0

The project is fully functional and actively maintained.

Future improvements, feature requests, and roadmap items are tracked in the project board and the issues.

Requirements

  • Python ≥ 3.10 (developed on 3.12)
  • A running JMRI Web Server (tested with JMRI 5.4)

See docs/install.md for installation details.

Documentation

Getting started

  • Installation guide — every install combination (CLI, Claude Desktop .mcpb, Kira bridge), configuration, and first commands
  • Developing on this repo — editable installs from a cloned copy, for working on the code itself

AI assistants

Advanced users

  • CLI reference — jmri-cli command reference
  • Exhibition mode — restricted-safety mode for public demos
  • Architecture — module design, JMRI clients, WebSocket implementation
  • Testing — mocked and live test suites, hardware safety configuration
  • Resources — references for JMRI, MCP, and xiaozhi/Kira

Project

Configuration

VariableDefaultDescription
JMRI_URLhttp://localhost:12080Base URL of the JMRI Web Server
EXHIBITION_PASSWORDthis is spartaPassword required to exit exhibition mode. See Exhibition mode.
EXHIBITION_ALLOWED_ADDRESSES(none)Comma-separated DCC addresses locomotives are restricted to while exhibition mode is on.
EXHIBITION_START_ON(off)If set to 1/true/yes/on, the server starts already in exhibition mode.

Credits

[MrJ]

Built and maintained by MrJ.

Questions, bugs, and feature requests are welcome via issues.

License

AGPL-3.0-or-later

Chosen deliberately over a permissive license (MIT/Apache) so that anyone who modifies this project and offers it as a network service (not just redistributes the code) must also publish their modified source.

See the license text for the exact terms, and NOTICE.md for what attribution is required when reusing this project.

Third-party code

xiaozhi_wrapper (part of the jmri-mcp package) is adapted from the MCP pipe example in xiaozhi-esp32 (MIT License, Copyright (c) 2025 Shenzhen Xinzhi Future Technology Co., Ltd. and Project Contributors).

See the package documentation:

packages/jmri-mcp/src/xiaozhi_wrapper/__init__.py

來源:README.md,提交 b029e1d

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.0rc4最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分