From f7f69ec002e3d6db0fc413838306987ec3136198 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Tue, 1 Dec 2026 09:50:04 +0100 Subject: [PATCH] fix: name what a non-authoring role edits over mcp Co-Authored-By: Claude Opus 5.5 --- backend/windmill-api/openapi.yaml | 5 ++++ backend/windmill-api/src/mcp/role_access.rs | 23 +++++++++++++++++-- .../components/mcp/workspaceAccess.test.ts | 4 +++- .../src/lib/components/mcp/workspaceAccess.ts | 8 ++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 4a80c03878..019a0c2cce 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -42233,6 +42233,11 @@ components: runnables: type: integer description: With `runnables`, how many scripts and flows are offered. + edits: + type: array + description: With `run_and_edit`, the kinds the caller's role edits. + items: + type: string required: [id, name, access, limited] McpRoleSetting: diff --git a/backend/windmill-api/src/mcp/role_access.rs b/backend/windmill-api/src/mcp/role_access.rs index 490dfb08d8..f02c72beab 100644 --- a/backend/windmill-api/src/mcp/role_access.rs +++ b/backend/windmill-api/src/mcp/role_access.rs @@ -72,6 +72,8 @@ struct MemberAccess { limit: Option, username: Option, can_run: bool, + /// With `RunAndEdit`, what the role edits. + edits: Vec<&'static str>, } /// What a connection with `access` gets in each workspace, for `list_workspaces`. Community, where @@ -94,7 +96,7 @@ pub(super) async fn workspace_accesses( let text = match m.access { WorkspaceMcpAccess::BuildAndRun => "build and run".to_string(), WorkspaceMcpAccess::RunAndEdit => { - "read and run, and edit what your role allows".to_string() + format!("read and run, edit {}", m.edits.join(", ")) } WorkspaceMcpAccess::ReadAndRun => "read and run".to_string(), WorkspaceMcpAccess::ReadOnly => "read only".to_string(), @@ -152,6 +154,7 @@ async fn accesses( let mut session = access; let mut builds = true; let mut limit = None; + let mut edits = vec![]; let member = members.iter().find(|m| m.workspace_id == id); if let Some(m) = member { // Roles that cannot be read refuse every call there, as `caller_mcp_limit` does. @@ -175,6 +178,14 @@ async fn accesses( session = SessionAccess::ReadOnly; } builds = caps.is_author(); + // Folder rights, not the role, gate these two. + edits.extend(["resources", "variables"]); + if caps.manage_schedules { + edits.push("schedules"); + } + if caps.manage_triggers { + edits.push("triggers"); + } } } if locked.contains(&id) { @@ -195,7 +206,7 @@ async fn accesses( (_, SessionAccess::Full) => WorkspaceMcpAccess::BuildAndRun, }; let username = member.map(|m| m.username.clone()); - out.insert(id, MemberAccess { access, limit, username, can_run }); + out.insert(id, MemberAccess { access, limit, username, can_run, edits }); } Ok(out) } @@ -210,6 +221,9 @@ pub struct WorkspaceAccessEntry { /// With `runnables`, how many scripts and flows the caller would be offered. #[serde(skip_serializing_if = "Option::is_none")] runnables: Option, + /// With `run_and_edit`, the kinds the caller's role edits. + #[serde(skip_serializing_if = "Vec::is_empty")] + edits: Vec<&'static str>, } #[derive(Deserialize)] @@ -294,6 +308,11 @@ pub async fn list_workspace_access( access: member.access, limited: member.limit.is_some(), runnables, + edits: if member.access == WorkspaceMcpAccess::RunAndEdit { + member.edits.clone() + } else { + vec![] + }, id: w.id, name: w.name, }); diff --git a/frontend/src/lib/components/mcp/workspaceAccess.test.ts b/frontend/src/lib/components/mcp/workspaceAccess.test.ts index b1a638c7a0..fe662a57b2 100644 --- a/frontend/src/lib/components/mcp/workspaceAccess.test.ts +++ b/frontend/src/lib/components/mcp/workspaceAccess.test.ts @@ -30,7 +30,9 @@ it('names the lower of the picked access and the workspace one', () => { expect(accessLabel({ ...ws('a', 'runnables'), runnables: 12 }, 'full')).toBe( '12 scripts and flows as tools' ) - expect(accessLabel(ws('a', 'run_and_edit'), 'full')).toContain('edit what your role allows') + expect( + accessLabel({ ...ws('a', 'run_and_edit'), edits: ['variables', 'schedules', 'triggers'] }, 'full') + ).toBe('Read and run, edit variables, schedules and triggers') expect(accessLabel(ws('a', 'run_and_edit'), 'read_run')).toBe('Read and run') expect(accessLabel(ws('a', 'read_only'), 'read_run')).toBe('Read only') expect(accessLabel(ws('a', 'read_only'), 'selected')).toBe('Not available') diff --git a/frontend/src/lib/components/mcp/workspaceAccess.ts b/frontend/src/lib/components/mcp/workspaceAccess.ts index 44be81ba90..e1a4ce6a76 100644 --- a/frontend/src/lib/components/mcp/workspaceAccess.ts +++ b/frontend/src/lib/components/mcp/workspaceAccess.ts @@ -6,7 +6,7 @@ export type WorkspaceAccess = McpWorkspaceAccess['access'] const LABELS: Record = { build_and_run: 'Build and run', - run_and_edit: 'Read and run, edit what your role allows', + run_and_edit: 'Read and run', read_and_run: 'Read and run', read_only: 'Read only', runnables: 'Scripts and flows as tools', @@ -30,6 +30,12 @@ export function accessLabel(workspace: McpWorkspaceAccess, picked: McpAccess): s return `${runnables} ${runnables === 1 ? 'script or flow' : 'scripts and flows'} as tools` } if (picked === 'read_run' && access !== 'read_only') return LABELS.read_and_run + if (access === 'run_and_edit') { + const edits = workspace.edits ?? [] + const last = edits.at(-1) + const listed = edits.length > 1 ? `${edits.slice(0, -1).join(', ')} and ${last}` : last + return listed ? `${LABELS.run_and_edit}, edit ${listed}` : LABELS.run_and_edit + } return LABELS[access] }