fix: mcp refusal names the workspace and what the session can do there

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-12-03 16:41:43 +01:00
co-authored by Claude Opus 5.5
parent 3916c2785b
commit 2fcbf52ed3
3 changed files with 11 additions and 6 deletions
+4 -1
View File
@@ -140,6 +140,9 @@ async fn test_view_only_role_lists_no_runnable_tools(db: Pool<Postgres>) -> anyh
)
.await?;
let msg = run["error"]["message"].as_str().unwrap_or_default();
assert!(msg.contains("read-only"), "run must stay refused: {run}");
assert!(
msg.contains("in workspace test-workspace this session can only read"),
"run must stay refused: {run}"
);
Ok(())
}
+1 -1
View File
@@ -277,7 +277,7 @@ async fn role_setting_caps_every_token(db: Pool<Postgres>) -> anyhow::Result<()>
assert!(
out["error"]["message"]
.as_str()
.is_some_and(|m| m.contains("read-only")),
.is_some_and(|m| m.contains("in workspace test-workspace this session can only read")),
"{out}"
);
let out = call(DEFAULT, "ROLEUNBOUND_TOKEN", "list_workspaces", json!({})).await;
@@ -883,12 +883,14 @@ async fn call_generated_tool(
return Err(CallRefused::UnknownTool(format!("Unknown tool '{name}'")));
};
if !allowed(def, ctx.access) {
let token = match ctx.access {
SessionAccess::ReadAndRun => "can only read and run deployed scripts and flows",
_ => "is read-only",
// Named per workspace: a session covering several gives each its own access.
let can = match ctx.access {
SessionAccess::ReadAndRun => "only read and run deployed scripts and flows",
_ => "only read",
};
return Err(CallRefused::NotAllowed(format!(
"Tool '{name}' changes or runs something, and this session {token}"
"Tool '{name}' changes or runs something, and in workspace {} this session can {can}",
ctx.w_id
)));
}
dispatch(ctx, name, args).await.ok_or_else(|| {