From c63b2e3e14adabd468f12c355d939660b5882d91 Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Tue, 3 Nov 2026 00:32:55 +0800 Subject: [PATCH] =?UTF-8?q?docs(mcp):=20node=5Fconsole=5Fexec=20=E2=80=94?= =?UTF-8?q?=20QEMU=20serial=20getty=20login=20needs=20one=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Field finding from the smoke test: login flushes typed-ahead input before printing "Password: ", so a password sent in a separate call is lost (Login incorrect loop). Sending username and password in the same command string logs in reliably; the shell then persists across calls. --- docs/features/mcp-service.md | 2 +- gns3server/agent/mcp/__init__.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/features/mcp-service.md b/docs/features/mcp-service.md index f0ab52d1c..cb8a1e180 100644 --- a/docs/features/mcp-service.md +++ b/docs/features/mcp-service.md @@ -533,7 +533,7 @@ Output handling (the funnel): - `full=true` returns the last 400 lines / 64 KiB. - When output exceeds 50 lines, the full capture is also written to the node's files (`console-capture.txt`, overwritten per session) and the hint includes a `curl` URL with a short-lived **access ticket** (10 min) bound to that exact download path — the same mechanism `link_capture_download` uses. Tickets are short random strings (`gns3t_…`); they replaced long Bearer JWTs in returned URLs because LLM clients reliably corrupted those when retyping them (logging out invalidates outstanding tickets). -Node-side state persists between calls (config mode, running pings, pager position) — a new session lands where the previous one ended. Control keys are sent as real characters: an interrupt is `"\u0003"` as its own line in the `command` string; the 4-character spelling `"\x03"` is not translated. `command=""` sends a single Enter (wake an idle console / read the prompt). The session stays open the full `timeout` window (default 15 s, max 300 s) — set it just above the expected output time. +Node-side state persists between calls (config mode, running pings, pager position) — a new session lands where the previous one ended. On QEMU serial consoles, log in in ONE call: send the username and the password in the same `command` string. `login` flushes typed-ahead input before printing `Password: `, so a password sent in a separate call is lost and the console loops on `Login incorrect`. Once logged in, the shell persists across calls. Control keys are sent as real characters: an interrupt is `"\u0003"` as its own line in the `command` string; the 4-character spelling `"\x03"` is not translated. `command=""` sends a single Enter (wake an idle console / read the prompt). The session stays open the full `timeout` window (default 15 s, max 300 s) — set it just above the expected output time. The console WebSocket URL is built from the server's `_server_url()`, which resolves the host as follows: diff --git a/gns3server/agent/mcp/__init__.py b/gns3server/agent/mcp/__init__.py index b4bca26e5..bafd66071 100644 --- a/gns3server/agent/mcp/__init__.py +++ b/gns3server/agent/mcp/__init__.py @@ -809,6 +809,10 @@ async def node_console_exec( spelling "\\x03" is NOT translated and would arrive as text. - command="" sends a single Enter — wakes an idle console and shows the prompt. + - QEMU serial getty login: send the username and the password in the SAME + call. login flushes typed-ahead input before printing "Password: ", so + a password sent in a separate call is lost (Login incorrect loop). The + logged-in shell then persists across calls. Timeout: the session stays open for the FULL window (like `timeout N websocat`). Output keeps arriving the whole time; there is no