asana_create_section_for_project
Create a new section within an Asana project to organize tasks and improve project structure.
Instructions
Create a new section in a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | The project ID to create the section in | |
| name | Yes | Name of the section to create | |
| opt_fields | No | Comma-separated list of optional fields to include |
Implementation Reference
- src/tool-handler.ts:328-334 (handler)The main handler logic for the tool in the switch statement. It destructures the required parameters (project_id, name) and optional opts from the arguments, calls the Asana client wrapper method, and returns the JSON-stringified response.case "asana_create_section_for_project": { const { project_id, name, ...opts } = args; const response = await asanaClient.createSectionForProject(project_id, name, opts); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
- src/tools/project-tools.ts:102-123 (schema)Defines the tool's metadata including name, description, and input schema with required fields project_id and name, and optional opt_fields.export const createSectionForProjectTool: Tool = { name: "asana_create_section_for_project", description: "Create a new section in a project", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The project ID to create the section in" }, name: { type: "string", description: "Name of the section to create" }, opt_fields: { type: "string", description: "Comma-separated list of optional fields to include" } }, required: ["project_id", "name"] } };
- src/tool-handler.ts:61-103 (registration)Registers the tool by including createSectionForProjectTool in the exported tools array used for MCP tool handling.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:774-808 (helper)Core helper method in AsanaClientWrapper that performs the actual API call to create a section using Asana SectionsApi, with error handling and fallback to direct API call.async createSectionForProject(projectId: string, name: string, opts: any = {}) { try { const body = { data: { name } }; // Schimbăm ordinea parametrilor conform documentației Asana const response = await this.sections.createSectionForProject(projectId, body, opts); return response.data; } catch (error) { console.error(`Error creating section for project: ${error}`); // Dacă obținem eroare, încercăm metoda alternativă folosind callApi direct try { const client = Asana.ApiClient.instance; const response = await client.callApi( `/projects/${projectId}/sections`, 'POST', { project_gid: projectId }, {}, {}, {}, { data: { name } }, ['token'], ['application/json'], ['application/json'], 'Blob' ); return response.data; } catch (fallbackError) { console.error("Error in fallback method:", fallbackError); throw fallbackError; } } }
- src/utils/validation.ts:330-336 (schema)Validates the input parameters for the tool: project_id as GID and name as required string.case 'asana_create_section_for_project': result = validateGid(params.project_id, 'project_id'); if (!result.valid) errors.push(...result.errors); result = validateString(params.name, 'name', false); if (!result.valid) errors.push(...result.errors); break;