From 6e63145a477fb77720fc84397c7a42afdf70ef06 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Wed, 4 Nov 2026 22:56:37 +0100 Subject: [PATCH] fix: address review nits on MCP get_run and delete-after-use waits Co-Authored-By: Claude Opus 5.5 --- backend/windmill-api/src/jobs.rs | 4 ++-- backend/windmill-api/src/mcp/core.rs | 4 ++-- backend/windmill-mcp/src/server/runner.rs | 22 +++++++++++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 187faa4e6c..3f8e5d33ca 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -8409,8 +8409,8 @@ impl QueuedRun { result } - /// Whether its script deletes the run's data once its result is read, which only a - /// caller waiting on that result does. + /// Whether its script deletes the run's data after use, at once or after a delay: only a + /// caller that waits for the result applies that setting. pub fn deletes_after_use(&self) -> bool { resolve_delete_after_secs(self.delete_after_use, self.delete_after_secs).is_some() } diff --git a/backend/windmill-api/src/mcp/core.rs b/backend/windmill-api/src/mcp/core.rs index 29a48d442f..27cff9e9b7 100644 --- a/backend/windmill-api/src/mcp/core.rs +++ b/backend/windmill-api/src/mcp/core.rs @@ -112,8 +112,8 @@ impl WindmillBackend { queued: QueuedRun, request: &McpRequest<'_>, ) -> BackendResult { - // No later read can follow these: a hub script's run is outside what `get_run` - // reads, and a run deleted once its result is read is gone by then. + // A hub script's run is outside what `get_run` reads, and a script's delete-after-use + // setting is applied only by a caller that waits for its result. if path.starts_with("hub/") || queued.deletes_after_use() { let response = queued .wait(&self.db, workspace_id, &auth.username) diff --git a/backend/windmill-mcp/src/server/runner.rs b/backend/windmill-mcp/src/server/runner.rs index 705d951c40..7f7fd40d74 100644 --- a/backend/windmill-mcp/src/server/runner.rs +++ b/backend/windmill-mcp/src/server/runner.rs @@ -884,12 +884,17 @@ impl Runner { )); } - tools.extend( - self.backend - .session_tools(SessionAccess::ReadOnly) - .into_iter() - .find(|tool| tool.name == GET_RUN), - ); + if scope_config.favorites + || scope_config.has_any("script") + || scope_config.has_any("flow") + { + tools.extend( + self.backend + .session_tools(SessionAccess::ReadOnly) + .into_iter() + .find(|tool| tool.name == GET_RUN), + ); + } } // Add endpoint tools from the generated MCP tools, filtered by scope. @@ -1142,7 +1147,10 @@ impl Runner { let id = args.get("id").and_then(Value::as_str).unwrap_or_default(); let refused = || { ErrorData::invalid_params( - format!("No run {id} of a script or flow this token runs"), + format!( + "No run {id} of a script or flow this token runs. For a step of a flow, \ + pass the flow's run id and the step's id as `step`." + ), None, ) };