Skip to main content
Glama
by cristip73

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

NameRequiredDescriptionDefault
section_idYesThe section ID to add the task to
task_idYesThe task ID to add to the section
opt_fieldsNoComma-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

  • 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) }], }; }
  • 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"] } };
  • 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 ];
  • 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; } } }
  • 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;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cristip73/mcp-server-asana'

If you have feedback or need assistance with the MCP directory API, please join our Discord server