fix(mcp): Include subtasks in get_task API response (#1040)
Add Subtasks association to the findTaskByIdentifier function so that the get_task MCP API endpoint returns subtasks along with the main task. This enables clients to access the full task hierarchy in a single API call. The serializeTask function already supported subtasks serialization, so this change only required updating the query includes to load the Subtasks relation with proper ordering and Tag associations. Fixes #1029
This commit is contained in:
parent
d32b5943d1
commit
46329fc82b
1 changed files with 24 additions and 10 deletions
|
|
@ -15,23 +15,37 @@ const { Task, Project, Tag } = require('../../../models');
|
||||||
async function findTaskByIdentifier(identifier, userId) {
|
async function findTaskByIdentifier(identifier, userId) {
|
||||||
const isNumeric = !isNaN(identifier);
|
const isNumeric = !isNaN(identifier);
|
||||||
|
|
||||||
|
const includeOptions = [
|
||||||
|
{ model: Project, as: 'Project' },
|
||||||
|
{ model: Tag, as: 'Tags' },
|
||||||
|
{
|
||||||
|
model: Task,
|
||||||
|
as: 'Subtasks',
|
||||||
|
required: false,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
model: Tag,
|
||||||
|
as: 'Tags',
|
||||||
|
through: { attributes: [] },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
separate: true,
|
||||||
|
order: [
|
||||||
|
['order', 'ASC'],
|
||||||
|
['created_at', 'ASC'],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
if (isNumeric) {
|
if (isNumeric) {
|
||||||
return await taskRepository.findByIdAndUser(
|
return await taskRepository.findByIdAndUser(
|
||||||
parseInt(identifier),
|
parseInt(identifier),
|
||||||
userId,
|
userId,
|
||||||
{
|
{ include: includeOptions }
|
||||||
include: [
|
|
||||||
{ model: Project, as: 'Project' },
|
|
||||||
{ model: Tag, as: 'Tags' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return await taskRepository.findByUid(identifier, {
|
return await taskRepository.findByUid(identifier, {
|
||||||
include: [
|
include: includeOptions,
|
||||||
{ model: Project, as: 'Project' },
|
|
||||||
{ model: Tag, as: 'Tags' },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue