Skip to main content
Glama
cristip73
by cristip73

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
NameRequiredDescriptionDefault
project_idYesThe project ID containing the sections to reorder
section_idYesThe section GID to reorder
before_section_idNoInsert the section before this section GID. Use null for first position.
after_section_idNoInsert the section after this section GID. Use null for last position.

Implementation Reference

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

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