asana_reorder_sections
Reorder sections within an Asana project by specifying positions relative to other sections to organize project structure.
Instructions
Reorder a section within a project by specifying its position relative to another section
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The project ID containing the sections to reorder | |
| section_id | Yes | The section GID to reorder | |
| before_section_id | No | Insert the section before this section GID. Use null for first position. | |
| after_section_id | No | Insert the section after this section GID. Use null for last position. |
Implementation Reference
- src/asana-client-wrapper.ts:1404-1488 (handler)Core implementation of the reorderSections method that calls the Asana SectionsApi.insertSectionForProject or fallback direct API call to reorder the section.async reorderSections(projectId: string, sectionId: string, beforeSectionId?: string | null, afterSectionId?: string | null) { try { if (!sectionId) { throw new Error("Section ID cannot be empty"); } // Nu putem specifica atât before_section cât și after_section simultan if (beforeSectionId !== undefined && beforeSectionId !== null && afterSectionId !== undefined && afterSectionId !== null) { throw new Error("Cannot specify both before_section and after_section. Choose one."); } const body: any = { data: { section: sectionId } }; // Adăugăm before_section sau after_section la body, dacă sunt specificate if (beforeSectionId !== undefined) { body.data.before_section = beforeSectionId === null ? null : beforeSectionId; } else if (afterSectionId !== undefined) { body.data.after_section = afterSectionId === null ? null : afterSectionId; } else { throw new Error("Must specify either before_section_id or after_section_id"); } // Apelăm API-ul Asana pentru a muta secțiunea const response = await this.sections.insertSectionForProject(projectId, body); return { project_id: projectId, section_id: sectionId, status: "success", before_section: beforeSectionId, after_section: afterSectionId, result: response.data }; } catch (error) { console.error(`Error reordering section for project: ${error}`); // Dacă metoda standard eșuează, încercăm metoda alternativă cu callApi direct try { const client = Asana.ApiClient.instance; const body: any = { data: { section: sectionId } }; // Adăugăm before_section sau after_section la body, dacă sunt specificate if (beforeSectionId !== undefined) { body.data.before_section = beforeSectionId === null ? null : beforeSectionId; } else if (afterSectionId !== undefined) { body.data.after_section = afterSectionId === null ? null : afterSectionId; } const response = await client.callApi( `/projects/${projectId}/sections/insert`, 'POST', { project_gid: projectId }, {}, {}, {}, body, ['token'], ['application/json'], ['application/json'], 'Blob' ); return { project_id: projectId, section_id: sectionId, status: "success (fallback method)", before_section: beforeSectionId, after_section: afterSectionId, result: response.data }; } catch (fallbackError) { console.error("Error in fallback method:", fallbackError); throw error; // Aruncăm eroarea originală } } }
- src/tool-handler.ts:510-516 (handler)Tool handler dispatcher case that destructures input arguments and delegates to asanaClient.reorderSections method.case "asana_reorder_sections": { const { project_id, section_id, before_section_id, after_section_id } = args; const response = await asanaClient.reorderSections(project_id, section_id, before_section_id, after_section_id); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
- src/tools/project-tools.ts:338-363 (schema)Input schema definition for the asana_reorder_sections tool, specifying parameters and validation.export const reorderSectionsTool: Tool = { name: "asana_reorder_sections", description: "Reorder a section within a project by specifying its position relative to another section", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The project ID containing the sections to reorder" }, section_id: { type: "string", description: "The section GID to reorder" }, before_section_id: { type: "string", description: "Insert the section before this section GID. Use null for first position." }, after_section_id: { type: "string", description: "Insert the section after this section GID. Use null for last position." } }, required: ["project_id", "section_id"] } };
- src/tool-handler.ts:61-103 (registration)Registration of the tool in the central tools array exported for MCP server use, including import from project-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 ];