Skip to main content
Glama

taskCreate

Create structured tasks with multiple steps, set priorities, due dates, and tags for efficient task management using a TypeScript-based protocol.

Instructions

創建新的任務,可以包含多個步驟

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYes
dueDateNo
priorityNo
stepsYes
tagsNo
titleYes

Implementation Reference

  • main.ts:580-599 (handler)
    MCP tool handler function for 'taskCreate' that validates input, calls TaskManagerTool.createTask, and formats the response.
    async ({ title, description, steps, tags = [], dueDate, priority = 3 }) => { try { const newTask = await TaskManagerTool.createTask( title, description, steps, tags, dueDate, String(priority) ); return { content: [{ type: "text", text: `任務創建成功:\n${JSON.stringify(newTask, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `創建任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } }
  • Zod input schema for taskCreate tool defining required title and description, optional steps array, tags, dueDate, and priority.
    title: z.string(), description: z.string(), steps: z.array(z.object({ description: z.string(), order: z.number().optional(), completed: z.boolean().optional(), estimatedTime: z.number().optional() })), tags: z.array(z.string()).optional(), dueDate: z.string().optional(), priority: z.number().optional() },
  • main.ts:565-600 (registration)
    Registers the 'taskCreate' tool on the MCP server with name, description, input schema, and handler function.
    server.tool("taskCreate", "創建新的任務,可以包含多個步驟", { title: z.string(), description: z.string(), steps: z.array(z.object({ description: z.string(), order: z.number().optional(), completed: z.boolean().optional(), estimatedTime: z.number().optional() })), tags: z.array(z.string()).optional(), dueDate: z.string().optional(), priority: z.number().optional() }, async ({ title, description, steps, tags = [], dueDate, priority = 3 }) => { try { const newTask = await TaskManagerTool.createTask( title, description, steps, tags, dueDate, String(priority) ); return { content: [{ type: "text", text: `任務創建成功:\n${JSON.stringify(newTask, null, 2)}` }] }; } catch (error) { return { content: [{ type: "text", text: `創建任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }] }; } } );
  • TaskManagerTool.createTask static method: core logic for creating and persisting a new task to ./task/tasks.json file.
    public static async createTask( title: string, description: string, steps: Omit<TaskStep, 'id'>[], tags: string[] = [], dueDate?: string, plannedStartDate?: string, priority: number = 3 ): Promise<Task> { if (!title || !description) { throw new Error('任務標題和描述不能為空'); } if (priority < 1 || priority > 5) { throw new Error('任務優先級必須在1到5之間'); } // 獲取現有任務 const tasks = await this.readTasks(); // 創建新任務 const now = new Date().toISOString(); const taskSteps = steps.map((step, index) => ({ ...step, id: uuidv4(), order: step.order !== undefined ? step.order : index + 1, completed: step.completed !== undefined ? step.completed : false })); const newTask: Task = { id: uuidv4(), title, description, steps: taskSteps, tags, createdAt: now, plannedStartDate, updatedAt: now, status: TaskStatus.PENDING, priority }; // 添加新任務 tasks.push(newTask); // 保存所有任務 await this.writeTasks(tasks); return newTask; }

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/GonTwVn/GonMCPtool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server