Skip to content

Commit 40c25ad

Browse files
RusDynclaude
andcommitted
Apply agent default department when no department filter provided
get_tasks and get_top_tasks now fall back to ctx.defaultDepartmentId when the caller omits the department param, so agents see their own department by default instead of all departments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b68af2b commit 40c25ad

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

supabase/functions/mcp-server/tools/get-tasks.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ export async function handleGetTasks(
5555
return mcpError(scopeNotAllowedError(params.project, 'read'))
5656
}
5757

58-
// 3. Resolve department if provided
58+
// 3. Resolve department: explicit param → agent default → null (all)
59+
const effectiveDept = params.department
60+
?? (ctx.defaultDepartmentId && projectPerms.some((p) => p.departmentId === ctx.defaultDepartmentId)
61+
? ctx.defaultDepartmentId
62+
: undefined)
5963
let departmentId: string | null = null
60-
if (params.department) {
61-
const result = await resolveDepartment(params.department, projectPerms, supabase, 'read', params.project, ctx.workspaceId)
64+
if (effectiveDept) {
65+
const result = await resolveDepartment(effectiveDept, projectPerms, supabase, 'read', params.project, ctx.workspaceId)
6266
if ('error' in result) {
6367
return mcpError(result.error)
6468
}

supabase/functions/mcp-server/tools/get-top-tasks.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ export async function handleGetTopTasks(
4343
return mcpError(scopeNotAllowedError(params.project, 'read'))
4444
}
4545

46-
// 2. Resolve department if provided
46+
// 2. Resolve department: explicit param → agent default → null (all)
47+
const effectiveDept = params.department
48+
?? (ctx.defaultDepartmentId && projectPerms.some((p) => p.departmentId === ctx.defaultDepartmentId)
49+
? ctx.defaultDepartmentId
50+
: undefined)
4751
let departmentId: string | null = null
48-
if (params.department) {
49-
const result = await resolveDepartment(params.department, projectPerms, supabase, 'read', params.project, ctx.workspaceId)
52+
if (effectiveDept) {
53+
const result = await resolveDepartment(effectiveDept, projectPerms, supabase, 'read', params.project, ctx.workspaceId)
5054
if ('error' in result) {
5155
return mcpError(result.error)
5256
}

0 commit comments

Comments
 (0)