UNPKG

mcp-product-manager

Version:

MCP Orchestrator for task and project management with web interface

70 lines 2.37 kB
// list.ts - GET /api/projects import { Router } from 'express'; import { query } from '../../utils/database.js'; import { success, error, asyncHandler } from '../../utils/response.js'; const router = Router(); // List all projects router.get('/api/projects', asyncHandler(async (req, res) => { try { // Get unique projects with task counts const projects = await query(` SELECT project, COUNT(*) as total_tasks, SUM(CASE WHEN status = 'ready' THEN 1 ELSE 0 END) as ready_tasks, SUM(CASE WHEN status IN ('claimed', 'in_progress') THEN 1 ELSE 0 END) as active_tasks, SUM(CASE WHEN status = 'blocked' THEN 1 ELSE 0 END) as blocked_tasks, SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed_tasks, MIN(created_at) as first_task_created, MAX(created_at) as last_task_created, MAX(completed_at) as last_task_completed FROM tasks GROUP BY project ORDER BY project `); // Get agent counts per project const agentCounts = await query(` SELECT project, COUNT(*) as total_agents, SUM(CASE WHEN status = 'active' THEN 1 ELSE 0 END) as active_agents FROM agents GROUP BY project `); // Merge agent data with project data const agentMap = {}; agentCounts.forEach((a) => { agentMap[a.project] = { total_agents: a.total_agents, active_agents: a.active_agents }; }); const projectsWithAgents = projects.map((p) => ({ ...p, agents: agentMap[p.project] || { total_agents: 0, active_agents: 0 } })); success(res, { projects: projectsWithAgents, total: projectsWithAgents.length }); } catch (err) { console.error('Failed to list projects:', err); error(res, 'Failed to list projects', 500, { error: err.message }); } })); // MCP tool definition export const tool = { name: 'list_projects', description: 'List all projects with task and agent statistics', inputSchema: { type: 'object', properties: {}, required: [] } }; export { router }; export default router; //# sourceMappingURL=list.js.map