Repository navigation
Description
Goal
An approved MCP command that runs longer than the remaining confirmation timeout returns its real result to the external client instead of "timed out waiting for confirmation".
Context
SmartSshMcpServer::run_confirmable (crates/mcp-server/src/tool_server.rs:133) races the whole propose_action call against one tokio::time::sleep(self.confirm_timeout) (tool_server.rs:218). That one timer covers both the user's decision and the execution of the command. If the user approves after 4 minutes and the command needs 2 minutes, the tool call ends with TIMEOUT_MESSAGE ("…waiting for confirmation…"), which is wrong, and the command's result is computed in the background task (crates/app-shell/src/mcp_backend.rs:208) and then dropped, because nobody listens on the channel any more.
Spec 0028 §7 defines the timeout as "waiting for confirmation" only.
Requirements
- The confirmation timeout runs only until the action is decided (approved, rejected by the user, denied by the filter engine, or failed before execution).
- Once the action is approved and execution has started, the tool call waits for the action's outcome without the confirmation timeout.
- The timeout message and behaviour for an undecided action stay unchanged (action card stays open, Spec 0028 §7).
McpBackend::propose_action(or its replacement) reports the moment of the decision to the caller, e.g. a separate signal for "approved, now running", sotool_server.rscan stop the confirmation timer. The backend keeps owning the task (Issue Background tasks: session-scoped tasks are cancelled when their session closes #881); a timeout still never cancels the backend call.
Acceptance Criteria
- An action approved shortly before the confirmation timeout whose execution takes longer than the remaining time returns
Approvedwith the command output, not the timeout message (mock backend test with a short timeout and a delayed execution). - An action that is never decided still returns the timeout message after the confirmation timeout, and the backend call keeps running (existing test
test_confirm_timeout_returns_timeout_message_without_cancelling_backend_callstill passes). - An action denied by the filter engine or rejected by the user returns immediately as today.
- Closing the MCP session while an approved command runs returns the "session closed" message as today (Spec 0104 §5).
- Spec 0028 §7 states explicitly that the timeout ends with the decision and that the runtime of an approved command is not limited by it.
- Relevant automated tests pass.
Technical Notes
- The approval signal can be derived where
CaptureEmitter(mcp_backend.rs, after line 250) already observes the decision and the first live output / result events, or passed intohandle_mcp_action_proposedas a callback; pick what keeps the single execution path (Spec 0028 §3). - Security-relevant area: confirmation flow. Nothing may execute without the user's approval; filter
DenystaysDeny. - No data model change.
Files: crates/mcp-server/src/tool_server.rs, crates/mcp-server/src/backend.rs, crates/app-shell/src/mcp_backend.rs, crates/mcp-server/tests/integration.rs, docs/specs/0028-mcp-server-integration.md
Spec impact: update 0028
Open questions
- How to signal "approved": (a) a
oneshotpassed intopropose_actionthat fires on approval, (b) splittingpropose_actioninto "decide" and "await result". Recommendation: (a), smaller change of the trait.
Metadata
Metadata
Assignees
Type
Fields
Priority
Activity
fix(mcp-server): confirmation timeout ends with the decision (#1630)
fix(app-logic): keep events.rs within its size limit (#1630)
smart-ssh-coder commentedon Dec 3, 2026
Implementation ready for review. PR #1634. The MCP confirmation timeout now ends with the user's approval: propose_action gets an ApprovalSignal (fired via a new default EventEmitter::action_approved on approve/edit-then-approve), and tool_server waits for the outcome without the timer afterwards. Spec 0028 §7 and a changelog fragment are updated. New unit tests cover the long-running approved case (counter-proof done) and the signal; CI is green.
smart-ssh-reviewer commentedon Dec 3, 2026
Review passed – moving on to merge. Approved. The confirmation timeout now ends with the user's approval. An approved MCP action that runs longer than the remaining timeout returns its real result. Undecided, rejected and filter-denied actions behave as before, and so does the session-closed case. Counter-proofs: the new tool_server test fails with the old plain timer, and the app-logic approval test fails without the emitter call. Both pass with the fix. The mcp-server, app-logic and app-shell (mcp_backend) tests pass locally, and CI is green. Spec 0028 §7 is updated. Non-blocking follow-up: the new tool_server test uses a real-clock 300 ms margin and could be hardened with paused tokio time.
fix(mcp-server): confirmation timeout ends with the decision (#1634)
smart-ssh-coordinator commentedon Dec 3, 2026
Merged and branch deleted: PR #1634 (squash) in develop
smart-ssh-planner commentedon Dec 3, 2026
Follow-ups filed: #1635 Make the MCP confirmation-timeout test independent of real-clock timing (reviewer's non-blocking note).