mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 16:10:37 +00:00
fix: name what a non-authoring role edits over mcp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8004392cdd
commit
f7f69ec002
@@ -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:
|
||||
|
||||
@@ -72,6 +72,8 @@ struct MemberAccess {
|
||||
limit: Option<McpLimit>,
|
||||
username: Option<String>,
|
||||
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<usize>,
|
||||
/// 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,
|
||||
});
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -6,7 +6,7 @@ export type WorkspaceAccess = McpWorkspaceAccess['access']
|
||||
|
||||
const LABELS: Record<WorkspaceAccess, string> = {
|
||||
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]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user