Repository navigation
Description
Summary
The txAdmin client returns the parsed JSON body for any HTTP error that has one, and _render_toast falls back to the success text when type/msg are missing. An auth or permission rejection can therefore be reported as **[INFO]** Server stop request sent..
Where
mcp-server/tools/txadmin_client.py:109-116(TxAdminClient._send, HTTPError branch)mcp-server/tools/txadmin.py:29-36(_render_toast)mcp-server/tools/txadmin.py:60(txadmin_server_control),mcp-server/tools/txadmin.py:90(txadmin_resource_control)mcp-server/tools/txadmin.py:130,mcp-server/tools/txadmin.py:143-145(txadmin_player_search,limit)mcp-server/tools/txadmin.py:158-161(txadmin_kick_player,int(netid))
Details
except urllib.error.HTTPError as exc:
raw = exc.read().decode("utf-8", errors="replace")
parsed = _safe_json(raw)
if parsed is not None:
return parsed # 401/403/500 with a JSON body look like successtoast_type = (result.get("type") or "info").lower()
msg = result.get("msg") or result.get("error") or fallbackAny body without type and msg/error, such as {"logout": true} or {"success": false}, or a toast type outside success/warning/error, renders as [INFO] plus the "request sent" fallback. Confirmed offline: _render_toast({"logout": True}, "Server stop request sent.") returns **[INFO]** Server stop request sent. (Assumption: txAdmin returns at least one of these shapes on auth or permission failures.)
Smaller issues in the same module:
int(netid)acceptsTrue(becomes 1) and negative values.- With
limit <= 0, line 130 still prints one player, and line 145 reportslen(players) - limit"more".
Impact
These tools stop and restart a live game server, control resources, and kick players. An agent can be told a command was sent when txAdmin rejected it, and act on that (for example reporting a restart that never happened).
Steps to reproduce
- Point
TXADMIN_URLat a local stub that returns HTTP 403 with body{"logout":true}for/fxserver/controls(and a valid login response). - Call
txadmin_server_control_tool("restart"). - Output:
**[INFO]** Server restart request sent.
Suggested fix
- In
_send, keep the HTTP status and raiseTxAdminErrorfor status >= 400 even when the body is JSON, including the body's message. - In
_render_toast, treat a missingtype, an unknown type, or alogoutkey as an error or "unexpected response" and show the raw response, instead of the success fallback. - Reject boolean and negative
netid; clamplimitto at least 1 and compute the "more" count from the number actually shown.
Acceptance criteria
- An HTTP 401/403/500 response never produces output containing "request sent" or "command sent".
- A 200 response without a recognised toast shape is reported as unexpected, with the raw body.
-
netid=Trueandnetid=-1are rejected with no request sent. -
limit=0does not report a wrong "more" count. - Tests use a local
http.server.ThreadingHTTPServeron127.0.0.1:0as a fake panel (env set viamonkeypatch.setenv) and cover: missing credentials (error naming the vars, zero requests); login CSRF token propagation in thex-txadmin-csrftokenheader; login error andcsrfToken: "not_set"; invalid server action (zero requests) and" RESTART "normalisation; resourceensurebody{"action":"ensure_res","parameter":"my-res"}; HTTP 401{"logout":true}; HTTP 500 HTML body; connection refused; player searchfilters=Noneomitted from the query andlimit=25with 30 results showing "... and 5 more"; kick success,{}giving "Unexpected response", and non-numeric netid.
Getting started
- Relevant files:
mcp-server/tools/txadmin.py,mcp-server/tools/txadmin_client.py - How to run checks: there is no test suite yet; run the MCP server with
cd mcp-server && pip install -r requirements.txt && python server.py, and CI checks live in.github/workflows/validate.yml - Related docs:
skills/txadmin-integration/SKILL.md
Filed by repo-audit/full-audit at 701824d. Severity: medium. Effort: S. audit-key: bug|mcp-server/tools/txadmin.py|_render_toast
Activity
TMHSDigital commentedon Nov 21, 2026
Fixed in 40f5a20.
HTTP >= 400 responses now raise even with a JSON body; logout bodies and missing/unknown toast types render as an unexpected-response error; boolean and non-positive netids are rejected; the player search limit is clamped and the "more" count is computed from players shown.
Verified: Against a local fake panel: 401/403 logout, 500 HTML, 200 {"logout": true} and 200 {} all report errors and never "request sent"; bad netids send no request; limit 0 and 25 give correct counts. Covered by mcp-server/tests/test_txadmin.py.