UNPKG

mcp-product-manager

Version:

MCP Orchestrator for task and project management with web interface

76 lines 2.29 kB
/** * List tasks tool for MCP */ import { query } from '../utils/database.js'; export default { description: "List tasks for a specific project with optional filters", parameters: { type: "object", properties: { project: { type: "string", description: "Project name to list tasks for" }, status: { type: "string", enum: ["ready", "claimed", "in_progress", "blocked", "completed", "archived"], description: "Filter by task status" }, limit: { type: "number", description: "Maximum number of tasks to return (default 50)", default: 50 } }, required: ["project"] }, async execute(params) { const { project, status, limit = 50 } = params; // Require project parameter if (!project) { throw new Error('Project parameter is required'); } // Build query const conditions = ['project = ?']; const queryParams = [project]; if (status) { conditions.push('status = ?'); queryParams.push(status); } queryParams.push(limit); const sql = ` SELECT id, project, description, status, priority, category, model, claimed_by, created_at, updated_at, estimated_hours, completed_at FROM tasks WHERE ${conditions.join(' AND ')} ORDER BY CASE priority WHEN 'critical' THEN 4 WHEN 'high' THEN 3 WHEN 'medium' THEN 2 WHEN 'low' THEN 1 END DESC, created_at DESC LIMIT ? `; const tasks = await query(sql, queryParams); // Get total count const countSql = ` SELECT COUNT(*) as total FROM tasks WHERE ${conditions.join(' AND ')} `; const countParams = [...queryParams.slice(0, -1)]; // Remove limit const countResult = await query(countSql, countParams); const total = countResult[0]?.total || 0; return { project, total, tasks, limit }; } }; //# sourceMappingURL=list_tasks.js.map