Repository navigation
Description
Problem Description
When an in-process MCP tool call fails, the devops-cli MCP server returns only the class name of the exception. The agent cannot act on that answer.
Evidence:
src/devops_cli/ai/mcp/dispatcher.py, line 323:return 1, f"In-process execution error: {type(exc).__name__}". The message of the exception is not in the answer, and the debug log line holds only the class name too.- Claude Code transcripts, 2026-10-27 to 2026-11-13: 34 devops-cli MCP calls, 3 failures. The MCP server writes only uvicorn access lines, so no other record holds the cause.
- The project rule says that output keeps the facts that the reader needs, such as error lines.
Reproduction Steps
- Call an in-process MCP tool with an argument that makes the command raise (for example, a path that does not exist).
- See the answer
In-process execution error: <ExceptionClass>with no message.
Expected vs Actual Behavior
Expected: the answer holds the class and the first line of the message, passed through mask_secrets and cut to a fixed length. One log record at warning level holds the tool name, the class and the masked first line. Actual: the answer and the debug log hold only the class.
Proposed Solution
- Return
In-process execution error: <Class>: <first line>, with the first line passed throughmask_secrets(src/devops_cli/security/sanitizer.py) and cut to 200 characters. - Log the same text at warning level with the tool name, so that Loki can count MCP tool errors.
Acceptance Criteria
- A test (written first, fails on the base) makes the in-process dispatcher raise
ValueError("bad path x")and proves that the answer holdsValueError: bad path x. - A test proves that a secret-like value in the message is masked, and that a long message is cut.
- A test proves that one warning record names the tool and the class.
-
uv run devops ci fail-to-pass --base origin/mainshows that the new tests fail on the base. - Measure in telemetry: the warning records of failed MCP tool calls appear in Loki, by tool and class.
Existing Tool Considered
mask_secrets, which the project already uses for error text. No new tool. Cost to build (estimate): 0.05 M model input and output, and 1 hour. Cost to keep: near 0.
Related
#4784 (bound the GitHub MCP tools).
Alternatives check of 2026-11-23: none.
Tool: none found.
Reason: Searches found only the MCP SDK and generic redaction or log tooling; none turns an in-process exception into a masked, length-bounded answer with a tool-labelled warning. The fix belongs in the dispatcher and reuses the project's own mask_secrets helper, as the issue says.
Proposed design
Problem statement
An in-process MCP tool call that raises returns only the exception class. The agent cannot see the cause. The change returns the class and the masked first line of the message. It writes a warning with the tool label and the class.
Acceptance criteria
Requirement: Return masked first line
The in-process dispatcher SHALL return the exception class and the masked first line of its message.
Scenario: ValueError message
- WHEN A test makes the in-process dispatcher raise
ValueErrorwith messagebad path x. - THEN The returned text is
In-process execution error: ValueError: bad path x.
Requirement: Mask before cut
The in-process dispatcher MUST pass the first line through mask_secrets before it cuts the text to 200 characters.
Scenario: Secret at the cut
- WHEN A test makes the dispatcher raise
ValueErrorwith 190acharacters followed bytoken=supersecretvalue123. - THEN The returned text contains
token=<masand does not containtoken=supeorsupersecretvalue123.
Requirement: Bound returned message
The in-process dispatcher SHALL cut the masked first line to 200 characters.
Scenario: Long message
- WHEN A test makes the dispatcher raise
ValueErrorwith a message of 300xcharacters. - THEN The returned text holds exactly 200
xcharacters afterIn-process execution error: ValueError:.
Requirement: Warning names tool and class
The in-process dispatcher SHALL write one warning record that names the tool label and the exception class, and SHALL NOT write the exception message.
Scenario: Warning for a failed tool
- WHEN A test dispatches
devops gh pr viewand makes the in-process invocation raiseValueErrorwith messagebad path x. - THEN One record at warning level contains
ghandValueError, and it does not containbad path x.
Requirement: Fail-to-pass check
The change SHALL include tests that fail on the base revision and pass on the head revision.
Scenario: Fail-to-pass command
- WHEN A developer runs
uv run devops ci fail-to-pass --base origin/main. - THEN The command reports that the new tests fail on the base revision and pass on the head revision.
Existing Tool Considered
The alternatives check of 2026-11-17 in the issue body records none; no external tool applies. The fix reuses the existing mask_secrets helper (src/devops_cli/security/sanitizer.py) for masking. Written cost: about 0.05 M model input and output tokens and 1 hour; cost to keep is near zero.
Key questions
- Where does the in-process dispatcher turn an exception into the tool answer?: In
InProcessDispatcher._dispatch_typer, theexcept Exception as excblock returns1andIn-process execution error: {type(exc).__name__}. The same block logs only the class at debug level. [sources: src/devops_cli/ai/mcp/dispatcher.py] - How does the dispatcher form and bound the returned message?: Take the first line of
str(exc), pass it throughmask_secrets, cut it to 200 characters, and returnIn-process execution error: <Class>: <text>. When the first line is empty, returnIn-process execution error: <Class>. (best practice) [sources: src/devops_cli/ai/mcp/dispatcher.py, src/devops_cli/security/sanitizer.py:468]- Chosen: Mask then cut. A secret that crosses the cut stays masked.
- Rejected: Cut then mask. A secret can cross the cut and leave an unmasked prefix.
- Rejected: Return the full message. A long or multi-line message does not fit the MCP answer.
- What does the warning record hold, given the CodeQL note in the dispatcher?: Log the tool label and the exception class at warning level. Do not log the exception message. The returned text carries the masked message to the agent. This keeps the Loki count and avoids the clear-text logging alerts that the dispatcher comment records. (best practice) [sources: src/devops_cli/ai/mcp/dispatcher.py]
- Rejected: Log tool, class and masked message. The dispatcher comment records that masked values still raised CodeQL clear-text logging alerts and blocked v0.2.22.
- Chosen: Log tool and class only. The warning still names the failed tool and class for Loki, and no caller data reaches the log.
- Rejected: Log class only. Loki cannot count failures by tool.
- How does the dispatcher name the tool in the warning?: Use the first
devopssubcommand fromsub_argsas the tool label, and useunknownwhen it is empty. The dispatcher has no separate MCP tool name. (best practice) [sources: src/devops_cli/ai/mcp/dispatcher.py]- Rejected: Add a
tool_nameparameter todispatch. It changes theMcpDispatcherprotocol and every MCP tool caller for one log field. - Rejected: Use
cmd[0].cmd[0]isdevopsoruv, so it names no tool. - Chosen: Use the first
devopssubcommand. It is the stable label that the dispatcher already computes, and it needs no protocol change.
- Rejected: Add a
- Which existing helper masks secrets in text?:
mask_secretsinsrc/devops_cli/security/sanitizer.pymasks known secret patterns and returns the text. [sources: src/devops_cli/security/sanitizer.py:468]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 13, 2026
Both items fix an error response that hides the exception message, but in different code paths: the MCP dispatcher versus the roadmap implement step.devops-cli-service commentedon Nov 17, 2026
Alternatives check: none
Reason: The issue asks for no new tool: the fix is a few lines in the project's own in-process MCP dispatcher (
src/devops_cli/ai/mcp/dispatcher.py) that reuse the existingmask_secretshelper, add a warning log record, and cover it with tests. Searches for an MCP error-handling or secret-redaction tool/library that would supply this behaviour found nothing that fits the project's dispatcher, answer format and Loki logging, so no external tool or library applies.Tool: none found
Lacks:
In-process execution error: <Class>: <first line>from the project's in-process dispatchermask_secrets(src/devops_cli/security/sanitizer.py)Searches run:
Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at b466159 (see proposed design in issue body).
Moved to new items: #6237.
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC