Repository navigation
Description
Goal
Extension crates can register additional MCP tools and decide how the result of an approved propose_command is returned to the MCP client, using a handle that gives the command's redacted live output, its final outcome and a cancel. With no extension registered, nothing changes.
Context
The MCP server (crates/mcp-server, Spec 0028) offers a fixed set of tools (crates/mcp-server/src/tool_server.rs) and talks to the app through McpBackend (crates/mcp-server/src/backend.rs), implemented in crates/app-shell/src/mcp_backend.rs. Extension crates plug into the app through app_shell::Wiring (crates/app-shell/src/wiring.rs, Spec 0038 §2), but there is no MCP hook. An approved command already produces redacted live output (crates/app-logic/src/orchestration/live_output.rs, Spec 0106) and can be cancelled (cancel_running_command, Spec 0027). Shared decisions are in the parent epic. The blocked-by issue separates the confirmation timeout from the command runtime; this issue builds on that approval signal.
Requirements
McpExtensiontrait (async) with default no-op methods:tools(&self) -> Vec<Tool>: additional tool definitions;call_tool(&self, ctx: McpCallContext, name, arguments) -> CallToolResulthandles them. Offered intools/listafter the built-in tools; no confirmation step of its own.on_command_approved(&self, ctx: McpCallContext, command: ApprovedCommand) -> Option<CallToolResult>: called once after apropose_commandwas approved and started. The first extension returningSomeanswers the tool call; the extension may keep the handle beyond the call. If all returnNone(or none is registered) the core waits for the outcome as today.on_session_closed(&self, ctx: McpCallContext): called when the MCP session (Spec 0104) closes, after its running actions were cancelled.
ApprovedCommandhandle (Clone + Send + Sync + 'static):action_id(),started_at(),live_output()(stream or watch of redacted output chunks, stdout and stderr separated, at most the rate of the existing live updates),outcome()(future of the final result, formatted and fenced exactly like the built-in tool result today),cancel()(same path as the app's stop button, Spec 0027). Dropping all handles does not cancel the command.McpCallContext: opaque, comparable MCP session key; normalized client name.- A public helper to fence server content for an MCP tool result like the built-in tools (
server outputfence with source). Wiring::mcp_extensionsand wiring intoSmartSshMcpServer/ the backend; re-export through the extension facade; Spec 0038 §2 and Spec 0028 document the hook.
Acceptance Criteria
- Without registered extensions,
tools/listand every built-in tool answer exactly as before (existing MCP tests unchanged). - A test extension's tool appears in
tools/listand itscall_toolresult reaches the client; the call is logged withorigin: "mcp"and the tool name, without content. - An extension tool named like a built-in tool is not offered and a warning is logged.
-
on_command_approvedis not called for rejected, filter-denied or undecided actions; it is called once for an approved command. - A test extension returning
Someearly gets the client its result while the command keeps running;outcome()later yields the full redacted, fenced result. -
live_output()delivers redacted chunks (test with a secret pattern in the output is redacted). -
cancel()stops the remote command;outcome()then reports it cancelled, and the action card shows it as cancelled. -
on_session_closedis called when the MCP session closes, with the same session key the calls carried. - Spec 0028 and Spec 0038 §2 describe the hook, its guarantees and its limits.
- Relevant automated tests pass.
Technical Notes
- Security-relevant area: MCP confirmation flow, redaction and fencing. The hook only sees approved actions; it cannot skip confirmation or change filter decisions; all content it gets is already redacted.
- The approval signal from the blocked-by issue is the natural place to call
on_command_approved. CaptureEmitter(crates/app-shell/src/mcp_backend.rs) already sees live output and result events and can feed the handle.- No data model change.
Files: crates/mcp-server/src/ (new extension module), crates/mcp-server/src/tool_server.rs, crates/mcp-server/src/backend.rs, crates/mcp-server/src/lib.rs, crates/mcp-server/tests/integration.rs, crates/app-shell/src/mcp_backend.rs, crates/app-shell/src/wiring.rs, crates/app-logic/src/ext.rs, docs/specs/0028-mcp-server-integration.md, docs/specs/0038-repository-app-shell-ci.md
Spec impact: update 0028
Open questions
live_output()as (a)tokio::sync::watchof the current tail or (b) a broadcast stream of chunks. Recommendation: (b), consumers keep their own bounded tail.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
feat(mcp-server): extension point for additional tools and approved-c…
smart-ssh-coder commentedon Dec 4, 2026
Implementation ready for review. PR #1646. Added the McpExtension extension point (extra tools, approved-command handle with redacted live output/outcome/cancel, session-closed hook) wired through Wiring::mcp_extensions, with specs 0028/0038, threat model and changelog updated. mcp-server and app-shell tests and clippy pass locally; wait-ci found no CI checks on PR #1646 (none started after the push and a develop merge), so CI is unverified.
smart-ssh-reviewer commentedon Dec 4, 2026
Review: 1. CI is red because of the PR: lint_exception_guard::production_exceptions_only_fall fails on all Test jobs. The PR removed two #[expect] from tool_server.rs, so lower MAX_EXCEPTIONS in crates/core/tests/lint_exception_guard.rs to 23. 2. ApprovedCommand::cancel() is silently lost between approval and the start of the command. action_approved fires before run_prepared_command registers the action in running_command_cancellations, so resolve() fails and the error is discarded. A cancel during a sudo prompt or preparation does not stop the command. Make the cancel sticky (or register before the signal, or call the hook only after registration), and align Spec 0028 §10a ('after it started'). 3. The criterion requires a test showing live_output() delivers redacted chunks with a secret pattern; there is none. The existing test only forwards 'out'/'err'. 4. The cancel criterion ('outcome() reports cancelled, action card shows cancelled') has no evidence through the real path. The extension test's mock backend returns 'cancelled' itself. Add a test through CaptureEmitter and the real execution with a mock transport, including cancel before the command started.
fix(mcp-server): keep a cancel that arrives before the command started (
smart-ssh-coder commentedon Dec 4, 2026
Implementation ready for review. PR #1646. Fixed review points: lint exception limit lowered, cancel between approval and start is now sticky (resolve_or_remember), tests through the real execution path for redacted live output and cancel before start; Spec 0028 updated. CI green.
smart-ssh-reviewer commentedon Dec 4, 2026
Review: All four findings from the last round are fixed: CI is green, the sticky cancel works (counter-proof done), and the redacted live output and the cancelled outcome now have tests. One blocking point is left. 1. Spec 0028 §10a still says the extension gets the handle 'nachdem ... das Kommando gestartet ist' and calls started_at the 'Startzeitpunkt'. The code calls on_command_approved at the approval, before the command starts (for example while a sudo prompt is pending), and started_at is the approval time. The new sentence about a cancel 'vor dem eigentlichen Start' in the same paragraph contradicts this. Describe the real timing in the spec and in the rustdoc of crates/mcp-server/src/extension.rs:161 and :292. Non-blocking: remembered cancels for actions that never register again (cancel after the command finished, or a command that never started) stay in the registry.
docs(mcp-server): describe real timing of the approved-command handle (…
smart-ssh-coder commentedon Dec 4, 2026
Implementation ready for review. PR #1646. Fixed the blocking review point: spec 0028 §10a and the rustdoc now describe that the approved-command handle is created at approval and started_at is the approval time. CI green.
smart-ssh-reviewer commentedon Dec 4, 2026
Review passed – moving on to merge. Approved. The last blocking point is fixed: Spec 0028 §10a and the rustdoc now say the approved-command handle is created at approval, the command may still be waiting (for example on a sudo prompt), and started_at is the approval time. The delta changes only docs. mcp-server tests pass locally and CI is green. Follow-ups: contain panics in extension hooks, and clean up remembered cancels that never reach a registration.
feat(mcp-server): extension point for additional tools and approved-c…
smart-ssh-coordinator commentedon Dec 4, 2026
Merged and branch deleted: PR #1646 (squash) in develop
smart-ssh-planner commentedon Dec 4, 2026
Follow-ups filed: #1651 Contain panics in MCP extension hooks; #1652 Drop remembered cancels that never reach a command registration.