update_task_status now delegates to updateTaskStatusWithStoryPromotion
and surfaces story_status_change ('promoted' | 'demoted' | null) in the
response so Claude Code can act on story completion without a separate
read call.
get_claude_context adds an OR-filter on tasks so stories where every
task is DONE are skipped — only surfaces stories that still have work to
do (no tasks, or at least one non-DONE task).
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { z } from 'zod'
|
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
import { requireWriteAccess } from '../auth.js'
|
|
import { userCanAccessTask } from '../access.js'
|
|
import { toolError, toolJson, withToolErrors } from '../errors.js'
|
|
import { TASK_STATUS_API_VALUES, taskStatusFromApi, taskStatusToApi } from '../status.js'
|
|
import { updateTaskStatusWithStoryPromotion } from '../lib/tasks-status-update.js'
|
|
|
|
const inputSchema = z.object({
|
|
task_id: z.string().min(1),
|
|
status: z.enum(TASK_STATUS_API_VALUES as [string, ...string[]]),
|
|
})
|
|
|
|
export function registerUpdateTaskStatusTool(server: McpServer) {
|
|
server.registerTool(
|
|
'update_task_status',
|
|
{
|
|
title: 'Update task status',
|
|
description:
|
|
'Set the status of a task. Allowed values: todo, in_progress, review, done. ' +
|
|
'Forbidden for demo accounts.',
|
|
inputSchema,
|
|
},
|
|
async ({ task_id, status }) =>
|
|
withToolErrors(async () => {
|
|
const auth = await requireWriteAccess()
|
|
const dbStatus = taskStatusFromApi(status)
|
|
if (!dbStatus) {
|
|
return toolError(`Unknown status: ${status}`)
|
|
}
|
|
if (!(await userCanAccessTask(task_id, auth.userId))) {
|
|
return toolError(`Task ${task_id} not found or not accessible`)
|
|
}
|
|
const { task, storyStatusChange } = await updateTaskStatusWithStoryPromotion(
|
|
task_id,
|
|
dbStatus,
|
|
)
|
|
return toolJson({
|
|
id: task.id,
|
|
status: taskStatusToApi(task.status),
|
|
implementation_plan: task.implementation_plan,
|
|
story_status_change: storyStatusChange,
|
|
})
|
|
}),
|
|
)
|
|
}
|