asana_create_section_for_project
Create a new section in an Asana project to organize tasks and improve workflow management. Specify the project ID and section name to add structured categories.
Instructions
Create a new section in a project
Input 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 |
Input Schema (JSON Schema)
{
"properties": {
"name": {
"description": "Name of the section to create",
"type": "string"
},
"opt_fields": {
"description": "Comma-separated list of optional fields to include",
"type": "string"
},
"project_id": {
"description": "The project ID to create the section in",
"type": "string"
}
},
"required": [
"project_id",
"name"
],
"type": "object"
}
Implementation Reference
- src/tool-handler.ts:328-334 (handler)MCP tool handler case that executes the tool logic by calling AsanaClientWrapper.createSectionForProject with project_id, name, and opts.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/asana-client-wrapper.ts:774-808 (handler)Core implementation that calls the Asana SectionsApi to create a section in the specified project.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/tools/project-tools.ts:102-123 (schema)Tool definition including input schema for validation (required: project_id, name).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:67-67 (registration)Tool registered in the main tools array used by MCP server.createSectionForProjectTool,
- src/utils/validation.ts:330-336 (helper)Validates project_id as Asana GID and name as required string before execution.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;