Skip to main content
Glama
cristip73

MCP Server for Asana

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
    ];
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the basic action without behavioral details. It doesn't disclose permissions required, rate limits, whether the operation is idempotent, what happens on error, or the response format. For a mutation tool with zero annotation coverage, this is inadequate, scoring a 2 for limited transparency beyond the core action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the key action ('reorder a section within a project') and adds necessary detail ('by specifying its position relative to another section'). There's zero waste or redundancy, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation with 4 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like error handling, permissions, or return values, leaving gaps for an AI agent to invoke it correctly. For a tool with this context, it should do more, scoring a 2 for insufficient completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 4 parameters with clear descriptions (e.g., 'Use null for first position'). The description adds no additional parameter semantics beyond what's in the schema, such as explaining interactions between 'before_section_id' and 'after_section_id'. Baseline is 3 when schema does the heavy lifting, and the description doesn't compensate further.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('reorder') and resource ('a section within a project'), specifying it involves positioning relative to another section. It distinguishes from siblings like 'asana_create_section_for_project' or 'asana_get_project_sections' by focusing on reordering rather than creation or retrieval. However, it doesn't explicitly differentiate from all siblings (e.g., 'asana_set_parent_for_task' also involves ordering), so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing existing sections), exclusions (e.g., not for reordering tasks), or compare to siblings like 'asana_update_task' for task ordering. Usage is implied from the action but lacks explicit context, scoring a 2 for minimal guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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