asana_create_task_story
Add comments or stories to Asana tasks using plain text or formatted HTML with supported tags to document progress and communicate updates.
Instructions
Create a comment or story on a task. Either text or html_text is required.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | The task ID to add the story to | |
| text | No | The plain text content of the story/comment. Required if html_text is not provided. | |
| html_text | No | HTML-like formatted text for the comment. Required if text is not provided. 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>. | |
| opt_fields | No | Comma-separated list of optional fields to include |
Implementation Reference
- src/tool-handler.ts:284-324 (handler)Handler implementation for the 'asana_create_task_story' tool. Validates HTML text if provided, calls the Asana client wrapper to create the story, and provides detailed error handling including XML validation feedback.case "asana_create_task_story": { const { task_id, text, html_text, ...opts } = args; try { // Validate if html_text is provided if (html_text) { const xmlValidationErrors = validateAsanaXml(html_text); if (xmlValidationErrors.length > 0) { return { content: [{ type: "text", text: JSON.stringify({ error: "HTML validation failed", validation_errors: xmlValidationErrors, message: "The HTML text contains invalid XML formatting. Please check the validation errors above." }) }], }; } } const response = await asanaClient.createTaskStory(task_id, text, opts, html_text); return { content: [{ type: "text", text: JSON.stringify(response) }], }; } catch (error) { // When error occurs and html_text was provided, help troubleshoot if (html_text && error instanceof Error && error.message.includes('400')) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), html_text_validation: "The HTML format is valid. The error must be related to something else in the API request." }) }], }; } throw error; // re-throw to be caught by the outer try/catch } }
- src/tools/story-tools.ts:22-47 (schema)Schema definition for the 'asana_create_task_story' tool, including name, description, and detailed input schema.export const createTaskStoryTool: Tool = { name: "asana_create_task_story", description: "Create a comment or story on a task. Either text or html_text is required.", inputSchema: { type: "object", properties: { task_id: { type: "string", description: "The task ID to add the story to" }, text: { type: "string", description: "The plain text content of the story/comment. Required if html_text is not provided." }, html_text: { type: "string", description: "HTML-like formatted text for the comment. Required if text is not provided. 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>." }, opt_fields: { type: "string", description: "Comma-separated list of optional fields to include" } }, required: ["task_id"] } };
- src/asana-client-wrapper.ts:200-215 (helper)Helper method in AsanaClientWrapper that implements the core logic for creating a task story by calling the Asana Stories API.async createTaskStory(taskId: string, text: string | null = null, opts: any = {}, html_text: string | null = null) { const options = opts.opt_fields ? opts : {}; const data: any = {}; if (text) { data.text = text; } else if (html_text) { data.html_text = html_text; } else { throw new Error("Either text or html_text must be provided"); } const body = { data }; const response = await this.stories.createStoryForTask(body, taskId, options); return response.data; }
- src/tool-handler.ts:38-61 (registration)Registration of the 'asana_create_task_story' tool (included as createTaskStoryTool) in the all_tools array, which is filtered based on read-only mode and exported as list_of_tools for the MCP server.const all_tools: Tool[] = [ listWorkspacesTool, searchProjectsTool, searchTasksTool, getTaskTool, createTaskTool, getStoriesForTaskTool, updateTaskTool, getProjectTool, getProjectTaskCountsTool, getProjectSectionsTool, createTaskStoryTool, addTaskDependenciesTool, addTaskDependentsTool, createSubtaskTool, getMultipleTasksByGidTool, getProjectStatusTool, getProjectStatusesForProjectTool, createProjectStatusTool, deleteProjectStatusTool, setParentForTaskTool, getTasksForTagTool, getTagsForWorkspaceTool, ];