Repository navigation
fix(mcp): report tool failures as typed MCP errors - #42
Merged
Merged
Conversation
This was referenced Oct 9, 2026
kyle-elliott
added this pull request to stack #45
October 9, 2026 23:21
MCP tools returned failure text inside a successful result, so hosts recorded isError: false for failed calls. The CLI recovered failures by parsing that text. Add one typed failure surface: - `ApiFailure` (client): every non-success HTTP answer carries its status, first typed API error code, bounded Retry-After delay, and the unchanged human text. - `ToolError` and `FailureKind` (query): operation, kind, and detail. `from_client` classifies by the typed cause, not by message text. rmcp marks an `Err(ToolError)` result with isError: true. - One rendering for every tool: `<op> failed: <detail>` and a `next: <step>` line. The `<op> unavailable — ...` form is removed. - `query::*` functions and every `#[tool]` return `Result<String, ToolError>`. `query::cli_result` is removed. CLI commands propagate the error, print only the first line, and exit non-zero. - An unknown codebase selector is an invalid argument that names the accepted values. - An applied edit whose summary cannot be rendered stays a success and names the edit id. No deadline, retry, or index_codebase behavior changes. Refs #37
kyle-elliott
force-pushed
the
fix/typed-tool-errors
branch
from
October 10, 2026 00:05
7cdff4b to
3a74cee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of 3 for #37, plus follow-up #46. Stack: this PR → #43 → #44 → #46.
Problem
MCP tools returned failure text inside a successful result. Hosts recorded
isError: falsefor failed calls. The CLI found failures by parsing that text (query::cli_result).Change
ApiFailure(src/client/failure.rs): each non-success HTTP answer carries its status, its first typed API error code, the boundedRetry-Afterdelay, and the unchanged human text.ToolErrorandFailureKind(src/query/error.rs):Retryable { after },Unavailable,InvalidArgument,IndexPending,IndexFailed,Refused.ToolError::from_clientclassifies by the typed cause, not by the message text.#[tool]and everyquery::*function returnsResult<String, ToolError>. rmcp marksErrresults withisError: true.<op> failed: <detail>, then anext: <step>line. The<op> unavailable — …form is gone.query::cli_resultis removed.InvalidArgument. The message names the accepted values (an immutable codebase ID or a local directory path) and points tolist_codebases.edit_id.There are no deadline, retry, or
index_codebasebehavior changes in this PR.Verification
cargo fmt --check,cargo test --workspace --locked,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo docwith-D warnings, andgit diff --checkpass.GraphLoadingwithRetry-After, 502, 400/404/422, connect errors), the rendering of each kind,isErrorthrough rmcp, and a CLI exit status that is not zero.