add-task-to-story
Assign tasks to a Shortcut story with a description and designated owners using the MCP server. Simplify project management by integrating with AI tools for streamlined task creation.
Instructions
Add a task to a story
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| storyPublicId | Yes | The public ID of the story | |
| taskDescription | Yes | The description of the task | |
| taskOwnerIds | No | Array of user IDs to assign as owners of the task |
Implementation Reference
- src/tools/stories.ts:560-587 (handler)Handler function that implements the logic for adding a task to a story: validates inputs, fetches the story, checks owners, calls client.addTaskToStory, and returns formatted result.async addTaskToStory({ storyPublicId, taskDescription, taskOwnerIds, }: { storyPublicId: number; taskDescription: string; taskOwnerIds?: string[]; }) { if (!storyPublicId) throw new Error("Story public ID is required"); if (!taskDescription) throw new Error("Task description is required"); const story = await this.client.getStory(storyPublicId); if (!story) throw new Error(`Failed to retrieve Shortcut story with public ID: ${storyPublicId}`); if (taskOwnerIds?.length) { const owners = await this.client.getUserMap(taskOwnerIds as string[]); if (!owners) throw new Error(`Failed to retrieve users with IDs: ${taskOwnerIds.join(", ")}`); } const task = await this.client.addTaskToStory(storyPublicId, { description: taskDescription, ownerIds: taskOwnerIds, }); return this.toResult(`Created task for story sc-${storyPublicId}. Task ID: ${task.id}.`); }
- src/tools/stories.ts:256-268 (registration)MCP tool registration for 'stories-add-task', including input schema using Zod and handler that delegates to tools.addTaskToStoryserver.addToolWithWriteAccess( "stories-add-task", "Add a task to a story", { storyPublicId: z.number().positive().describe("The public ID of the story"), taskDescription: z.string().min(1).describe("The description of the task"), taskOwnerIds: z .array(z.string()) .optional() .describe("Array of user IDs to assign as owners of the task"), }, async (params) => await tools.addTaskToStory(params), );
- src/tools/stories.ts:259-266 (schema)Zod input schema for the 'stories-add-task' tool defining parameters: storyPublicId, taskDescription, and optional taskOwnerIds.{ storyPublicId: z.number().positive().describe("The public ID of the story"), taskDescription: z.string().min(1).describe("The description of the task"), taskOwnerIds: z .array(z.string()) .optional() .describe("Array of user IDs to assign as owners of the task"), },
- src/client/shortcut.ts:421-441 (helper)Helper method in ShortcutClientWrapper that wraps the base Shortcut API's createTask method to add a task to a story.async addTaskToStory( storyPublicId: number, taskParams: { description: string; ownerIds?: string[]; }, ): Promise<Task> { const { description, ownerIds } = taskParams; const params = { description, owner_ids: ownerIds, }; const response = await this.client.createTask(storyPublicId, params); const task = response?.data ?? null; if (!task) throw new Error(`Failed to create the task: ${response.status}`); return task; }