asana_add_task_to_section
Add tasks to specific sections within Asana projects to organize work and maintain project structure.
Instructions
Add a task to a specific section in a project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| section_id | Yes | The section ID to add the task to | |
| task_id | Yes | The task ID to add to the section | |
| opt_fields | No | Comma-separated list of optional fields to include |
Input Schema (JSON Schema)
{
"properties": {
"opt_fields": {
"description": "Comma-separated list of optional fields to include",
"type": "string"
},
"section_id": {
"description": "The section ID to add the task to",
"type": "string"
},
"task_id": {
"description": "The task ID to add to the section",
"type": "string"
}
},
"required": [
"section_id",
"task_id"
],
"type": "object"
}
Implementation Reference
- src/tool-handler.ts:336-342 (handler)Tool handler case that destructures input parameters (section_id, task_id, opts) and delegates execution to AsanaClientWrapper.addTaskToSection method.case "asana_add_task_to_section": { const { section_id, task_id, ...opts } = args; const response = await asanaClient.addTaskToSection(section_id, task_id, opts); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
- src/tools/task-tools.ts:433-454 (schema)Defines the Tool object with name, description, and inputSchema for validating parameters: section_id and task_id are required strings.export const addTaskToSectionTool: Tool = { name: "asana_add_task_to_section", description: "Add a task to a specific section in a project", inputSchema: { type: "object", properties: { section_id: { type: "string", description: "The section ID to add the task to" }, task_id: { type: "string", description: "The task ID to add to the section" }, opt_fields: { type: "string", description: "Comma-separated list of optional fields to include" } }, required: ["section_id", "task_id"] } };
- src/tool-handler.ts:61-103 (registration)Registers the tool in the exported tools array used by the MCP server to list available tools.export const tools: Tool[] = [ listWorkspacesTool, searchProjectsTool, getProjectTool, getProjectTaskCountsTool, getProjectSectionsTool, createSectionForProjectTool, createProjectForWorkspaceTool, updateProjectTool, reorderSectionsTool, getProjectStatusTool, getProjectStatusesForProjectTool, createProjectStatusTool, deleteProjectStatusTool, searchTasksTool, getTaskTool, createTaskTool, updateTaskTool, createSubtaskTool, getMultipleTasksByGidTool, addTaskToSectionTool, getTasksForSectionTool, getProjectHierarchyTool, getSubtasksForTaskTool, getTasksForProjectTool, getTasksForTagTool, getTagsForWorkspaceTool, addTagsToTaskTool, addTaskDependenciesTool, addTaskDependentsTool, setParentForTaskTool, addFollowersToTaskTool, getStoriesForTaskTool, createTaskStoryTool, getTeamsForUserTool, getTeamsForWorkspaceTool, addMembersForProjectTool, addFollowersForProjectTool, getUsersForWorkspaceTool, getAttachmentsForObjectTool, uploadAttachmentForObjectTool, downloadAttachmentTool ];
- src/asana-client-wrapper.ts:811-845 (helper)Core implementation in AsanaClientWrapper that calls Asana SectionsApi.addTaskForSection to add the task to the section, with fallback direct API call.async addTaskToSection(sectionId: string, taskId: string, opts: any = {}) { const data = { data: { task: taskId, insert_before: null } }; try { const response = await this.sections.addTaskForSection(sectionId, data, opts); return response.data; } catch (error) { console.error("Error in addTaskToSection:", error); // Dacă obținem eroare, încercăm metoda alternativă folosind callApi direct try { const client = Asana.ApiClient.instance; const response = await client.callApi( `/sections/${sectionId}/addTask`, 'POST', { section_gid: sectionId }, {}, {}, {}, { data: { task: taskId, insert_before: null } }, ['token'], ['application/json'], ['application/json'], 'Blob' ); return response.data; } catch (fallbackError) { console.error("Error in fallback method:", fallbackError); throw fallbackError; } } }
- src/utils/validation.ts:338-344 (helper)Validates that task_id and section_id are valid Asana GIDs (numeric strings) before execution.case 'asana_add_task_to_section': result = validateGid(params.task_id, 'task_id'); if (!result.valid) errors.push(...result.errors); result = validateGid(params.section_id, 'section_id'); if (!result.valid) errors.push(...result.errors); break;