UNPKG

mcp-product-manager

Version:

MCP Orchestrator for task and project management with web interface

47 lines 1.52 kB
/** * Claim task tool for MCP */ import { run, get } from '../utils/database.js'; export default { description: "Claim a task for an agent to work on", parameters: { type: "object", properties: { task_id: { type: "string", description: "Task ID to claim" }, agent: { type: "string", description: "Agent name claiming the task" } }, required: ["task_id", "agent"] }, async execute(params) { const { task_id, agent } = params; // Check if task exists and is claimable const task = await get('SELECT * FROM tasks WHERE id = ? AND status IN (?, ?)', [task_id, 'ready', 'pending']); if (!task) { throw new Error(`Task ${task_id} not found or not claimable`); } // Claim the task await run(`UPDATE tasks SET status = 'claimed', claimed_by = ?, claimed_at = datetime('now'), updated_at = datetime('now') WHERE id = ?`, [agent, task_id]); // Get updated task const claimedTask = await get('SELECT * FROM tasks WHERE id = ?', [task_id]); if (!claimedTask) { throw new Error(`Failed to retrieve claimed task ${task_id}`); } return { success: true, task: claimedTask, message: `Task ${task_id} claimed by ${agent}` }; } }; //# sourceMappingURL=claim_task.js.map