Skip to content

txAdmin tools report unexpected or error responses as success #34

Closed

Description

@TMHSDigital

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 success
toast_type = (result.get("type") or "info").lower()
msg = result.get("msg") or result.get("error") or fallback

Any 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) accepts True (becomes 1) and negative values.
  • With limit <= 0, line 130 still prints one player, and line 145 reports len(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

  1. Point TXADMIN_URL at a local stub that returns HTTP 403 with body {"logout":true} for /fxserver/controls (and a valid login response).
  2. Call txadmin_server_control_tool("restart").
  3. Output: **[INFO]** Server restart request sent.

Suggested fix

  • In _send, keep the HTTP status and raise TxAdminError for status >= 400 even when the body is JSON, including the body's message.
  • In _render_toast, treat a missing type, an unknown type, or a logout key as an error or "unexpected response" and show the raw response, instead of the success fallback.
  • Reject boolean and negative netid; clamp limit to 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=True and netid=-1 are rejected with no request sent.
  • limit=0 does not report a wrong "more" count.
  • Tests use a local http.server.ThreadingHTTPServer on 127.0.0.1:0 as a fake panel (env set via monkeypatch.setenv) and cover: missing credentials (error naming the vars, zero requests); login CSRF token propagation in the x-txadmin-csrftoken header; login error and csrfToken: "not_set"; invalid server action (zero requests) and " RESTART " normalisation; resource ensure body {"action":"ensure_res","parameter":"my-res"}; HTTP 401 {"logout":true}; HTTP 500 HTML body; connection refused; player search filters=None omitted from the query and limit=25 with 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

  1. added
    bug
    good first issue
    on Nov 21, 2026
  2. TMHSDigital commented on Nov 21, 2026

    @TMHSDigital
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueseverity: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions