mcp-product-manager
Version:
MCP Orchestrator for task and project management with web interface
74 lines • 2.53 kB
JavaScript
// detail.js - GET /api/bundles/:id
import { Router } from 'express';
import { query, get } from '../../utils/database.js';
import { success, error, asyncHandler } from '../../utils/response.js';
import { getTaskDetails } from '../tasks/detail.js';
const router = Router();
// Get bundle details
router.get('/api/bundles/:id', asyncHandler(async (req, res) => {
const { id } = req.params;
try {
// Get bundle information
const bundle = await get(`
SELECT * FROM task_bundles WHERE id = ?
`, [id]);
if (!bundle) {
const errorResponse = error('Bundle not found', 404);
return res.status(errorResponse.status).json(errorResponse.body);
}
// Get all task IDs in the bundle
const bundleTaskIds = await query(`
SELECT task_id FROM bundle_tasks WHERE bundle_id = ?
`, [id]);
// Get detailed task information for each task
const tasks = [];
for (const { task_id } of bundleTaskIds) {
const taskDetail = await getTaskDetails(task_id);
if (taskDetail) {
tasks.push(taskDetail);
}
}
const bundleDetail = {
id: bundle.id,
project: bundle.project,
type: bundle.bundle_type,
status: bundle.status,
task_count: bundle.task_count,
total_hours: bundle.total_estimated_hours,
reason: bundle.bundle_reason,
claimed_by: bundle.claimed_by,
created_at: bundle.created_at,
started_at: bundle.started_at,
created_by: bundle.created_by,
tasks: tasks
};
res.json(success({
bundle: bundleDetail
}));
}
catch (err) {
console.error('Failed to get bundle details:', err);
const errorResponse = error('Failed to get bundle details', 500, {
error: err.message
});
res.status(errorResponse.status).json(errorResponse.body);
}
}));
// MCP tool definition
export const tool = {
name: 'bundle_get_details',
description: 'Get detailed information about a bundle including all tasks',
inputSchema: {
type: 'object',
properties: {
bundle_id: {
type: 'string',
description: 'The ID of the bundle to get details for'
}
},
required: ['bundle_id']
}
};
export { router };
export default router;
//# sourceMappingURL=detail.js.map