Repository navigation
Closed
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/mcpModel Context Protocol tools, system resources, and promptstype/bugType bug: the code does not do what it must
Milestone
Description
Context & Rationale
_run_mcp_cmd (ai/mcp/server.py:50-63) sends every uv run devops argv to the in-process dispatcher, which runs it with Typer's CliRunner (ai/mcp/dispatcher.py:228-249).
Child output corrupts the protocol stream.
- A command whose child process inherits stdout writes to the server's real fd 1. Under
--transport stdio(.mcp.json), fd 1 is the JSON-RPC channel. - Examples:
devops ci test|lint|format|typecheck(_runusescapture_output=False,commands/ci.py:172-185), and the kustomize, uv, release, telemetry, config and k8s commands. - A probe with a failing child returned
Command exited with status 1:\nℹ Quality gate root: <root>. The diagnostic went to fd 1 instead of the reply.
Failures can read as success. The dispatcher returns Success for empty output whatever the exit code (dispatcher.py:248, :268).
ci_run misleads agents (server.py:593-598):
- it offers only 5 of the gate's checks;
- its docstring says the gate is 'pytest, ruff check, ruff format, mypy';
- it times out at 180 s (
config/defaults.py:246), while the test step alone takes 102-435 s; - its lint and format paths apply fixes, so asking whether the gate passes silently edits the working tree.
Planning record.
docs/ROADMAP.md:950(P0) and:968(P1, ToolError and isError) plan this. Neither has an issue.- refactor(cli): one process runner owns execution, process groups and dry-run #775 (one process runner, P2) also changes
_run.
Scope & Deliverables
- Deliverable:
- In-process dispatch never lets a child process write to fd 1.
- The dispatcher returns
Successonly on exit 0, andno output capturedotherwise. - A non-zero exit raises fastmcp
ToolError, carrying the masked, bounded output, so clients seeisError. ci_run:- runs with
--check; - accepts any check name the gate defines;
- takes its timeout from
CONST_CI_TEST_BUDGET_SECONDSplus a margin constant; - says in its docstring what the gate runs.
- runs with
- Mark the defect part of
ROADMAP.md:950and the ToolError part of:968delivered.
- Acceptance criteria:
- A capfd test asserts that nothing reaches the real stdout while a tool dispatches a command whose child prints.
- A check that exits 1 after printing a diagnostic yields an
isErrorresult containing the exit status and the diagnostic. - Exit 0 with empty output returns
Success. - The argv
ci_runbuilds contains--check, and its timeout is at leastCONST_CI_TEST_BUDGET_SECONDS. - The new tests take at most 1 s in total.
- Key questions:
- Redirect fd 1 inside the dispatcher, or route child-spawning commands to the captured subprocess path? (proposed) Redirect in the dispatcher: one place then covers every command.
- If refactor(cli): one process runner owns execution, process groups and dry-run #775 has started, fold this into it? (proposed) Yes. Otherwise land this first, with the smallest possible change to
_run.
- Constraint:
- Tests stay offline.
- No new dependency.
- The structured mypy/ruff diagnostics from
ROADMAP.md:950stay out of scope. - One PR.
Strategic Alignment
- Milestone: Backlog
- Depends on: none (coordinate with refactor(cli): one process runner owns execution, process groups and dry-run #775)
Metadata
Metadata
Assignees
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/mcpModel Context Protocol tools, system resources, and promptstype/bugType bug: the code does not do what it must
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(ai): mcp command tools return the failing output and never write …
fix(ai): mcp command tools return the failing output and never write …
feat(release): v0.2.28 (#1283)