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:
Chris 2026-04-18 00:29:16 +03:00 committed by GitHub
parent d32b5943d1
commit 46329fc82b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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' },
],
}); });
} }
} }