Skip to main content
Glama
by cristip73

asana_create_task

Create new tasks in Asana projects with names, descriptions, due dates, assignees, and custom fields to organize work and track progress.

Instructions

Create a new task in a project

Input Schema

NameRequiredDescriptionDefault
project_idYesThe project to create the task in
nameYesName of the task
notesNoDescription of the task
html_notesNoHTML-like formatted description of the task. Does not support ALL HTML tags. Only a subset. The only allowed TAG in the HTML are: <body> <h1> <h2> <ol> <ul> <li> <strong> <em> <u> <s> <code> <pre> <blockquote> <a data-asana-type="" data-asana-gid=""> <hr> <img> <table> <tr> <td>. No other tags are allowed. Use the \n to create a newline. Do not use \n after <body>. Example: <body><h1>Motivation</h1> A customer called in to complain <h1>Goal</h1> Fix the problem</body>
due_onNoDue date in YYYY-MM-DD format
assigneeNoAssignee (can be 'me' or a user ID)
followersNoArray of user IDs to add as followers
parentNoThe parent task ID to set this task under
projectsNoArray of project IDs to add this task to
resource_subtypeNoThe type of the task. Can be one of 'default_task' or 'milestone'
custom_fieldsNoObject mapping custom field GID strings to their values. For enum fields use the enum option GID as the value.

Input Schema (JSON Schema)

{ "properties": { "assignee": { "description": "Assignee (can be 'me' or a user ID)", "type": "string" }, "custom_fields": { "description": "Object mapping custom field GID strings to their values. For enum fields use the enum option GID as the value.", "type": "object" }, "due_on": { "description": "Due date in YYYY-MM-DD format", "type": "string" }, "followers": { "description": "Array of user IDs to add as followers", "items": { "type": "string" }, "type": "array" }, "html_notes": { "description": "HTML-like formatted description of the task. Does not support ALL HTML tags. Only a subset. The only allowed TAG in the HTML are: <body> <h1> <h2> <ol> <ul> <li> <strong> <em> <u> <s> <code> <pre> <blockquote> <a data-asana-type=\"\" data-asana-gid=\"\"> <hr> <img> <table> <tr> <td>. No other tags are allowed. Use the \\n to create a newline. Do not use \\n after <body>. Example: <body><h1>Motivation</h1>\nA customer called in to complain\n<h1>Goal</h1>\nFix the problem</body>", "type": "string" }, "name": { "description": "Name of the task", "type": "string" }, "notes": { "description": "Description of the task", "type": "string" }, "parent": { "description": "The parent task ID to set this task under", "type": "string" }, "project_id": { "description": "The project to create the task in", "type": "string" }, "projects": { "description": "Array of project IDs to add this task to", "items": { "type": "string" }, "type": "array" }, "resource_subtype": { "description": "The type of the task. Can be one of 'default_task' or 'milestone'", "type": "string" } }, "required": [ "project_id", "name" ], "type": "object" }

Implementation Reference

  • Main tool handler switch case that processes the request arguments and invokes the Asana client to create a task.
    case "asana_create_task": { const { project_id, ...taskData } = args; const response = await asanaClient.createTask(project_id, taskData); return { content: [{ type: "text", text: JSON.stringify(response) }], }; }
  • Core implementation that prepares the task data (ensuring project inclusion, defaults) and calls the Asana TasksApi.createTask method.
    async createTask(projectId: string, data: any) { try { // Ensure projects array includes the projectId const projects = data.projects || []; if (!projects.includes(projectId)) { projects.push(projectId); } const taskData = { data: { ...data, projects, // Handle resource_subtype if provided resource_subtype: data.resource_subtype || 'default_task', // Handle custom_fields if provided custom_fields: data.custom_fields || {}, // Asigură-te că task-ul este adăugat la sfârșitul listei insert_before: null } }; const response = await this.tasks.createTask(taskData); return response.data; } catch (error: any) { console.error(`Error creating task: ${error.message}`); // Add useful diagnostics information if (error.response && error.response.body) { console.error(`Response error details: ${JSON.stringify(error.response.body, null, 2)}`); } // Provide more context about the error if (error.message.includes("Missing input")) { throw new Error(`Failed to create task: Missing required parameters. ${error.message}`); } if (error.message.includes("Not a valid project")) { throw new Error(`Project ID ${projectId} is not valid or you don't have access to it.`); } throw error; } }
  • Defines the tool metadata, description, and input schema specifying required parameters and types for validation.
    export const createTaskTool: Tool = { name: "asana_create_task", description: "Create a new task in a project", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The project to create the task in" }, name: { type: "string", description: "Name of the task" }, notes: { type: "string", description: "Description of the task" }, html_notes: { type: "string", description: "HTML-like formatted description of the task. Does not support ALL HTML tags. Only a subset. The only allowed TAG in the HTML are: <body> <h1> <h2> <ol> <ul> <li> <strong> <em> <u> <s> <code> <pre> <blockquote> <a data-asana-type=\"\" data-asana-gid=\"\"> <hr> <img> <table> <tr> <td>. No other tags are allowed. Use the \\n to create a newline. Do not use \\n after <body>. Example: <body><h1>Motivation</h1>\nA customer called in to complain\n<h1>Goal</h1>\nFix the problem</body>" }, due_on: { type: "string", description: "Due date in YYYY-MM-DD format" }, assignee: { type: "string", description: "Assignee (can be 'me' or a user ID)" }, followers: { type: "array", items: { type: "string" }, description: "Array of user IDs to add as followers" }, parent: { type: "string", description: "The parent task ID to set this task under" }, projects: { type: "array", items: { type: "string" }, description: "Array of project IDs to add this task to" }, resource_subtype: { type: "string", description: "The type of the task. Can be one of 'default_task' or 'milestone'" }, custom_fields: { type: "object", description: "Object mapping custom field GID strings to their values. For enum fields use the enum option GID as the value." } }, required: ["project_id", "name"] } };
  • Registers the createTaskTool (imported from task-tools) in the global tools array used by the MCP server.
    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 ];
  • Validates key parameters (project_id as GID, name as required string, due_on as date) before execution.
    case 'asana_create_task': 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); if (params.due_on) { result = validateDate(params.due_on, 'due_on'); if (!result.valid) errors.push(...result.errors); } break;

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