get_next_task
Retrieve the next pending task in a project from taskqueue-mcp, along with recommendations to guide its completion, ensuring structured progress.
Instructions
Get the next task to be done in a project. Returns the first non-approved task in sequence, regardless of status. The task may include toolRecommendations and ruleRecommendations fields that should be used to guide task completion.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | The ID of the project to get the next task from (e.g., proj-1). |
Implementation Reference
- src/server/toolExecutors.ts:230-242 (handler)The main handler/executor for the 'get_next_task' tool. Validates the projectId input parameter and delegates to TaskManager.getNextTask() for the core logic.const getNextTaskToolExecutor: ToolExecutor = { name: "get_next_task", async execute(taskManager, args) { // 1. Argument Validation const projectId = validateProjectId(args.projectId); // 2. Core Logic Execution const resultData = await taskManager.getNextTask(projectId); // 3. Return raw success data return resultData; }, };
- src/server/toolExecutors.ts:243-243 (registration)Registers the get_next_task executor in the toolExecutorMap used by the MCP server to dispatch tool calls.toolExecutorMap.set(getNextTaskToolExecutor.name, getNextTaskToolExecutor);
- src/server/tools.ts:416-429 (schema)Defines the Tool schema for 'get_next_task', including name, description, and inputSchema for MCP protocol compliance.const getNextTaskTool: Tool = { name: "get_next_task", description: "Get the next task to be done in a project. Returns the first non-approved task in sequence, regardless of status. The task may include toolRecommendations and ruleRecommendations fields that should be used to guide task completion.", inputSchema: { type: "object", properties: { projectId: { type: "string", description: "The ID of the project to get the next task from (e.g., proj-1).", }, }, required: ["projectId"], }, };
- src/server/TaskManager.ts:265-297 (helper)Core helper method in TaskManager that implements the logic to find and return the next unapproved task in a project, handling edge cases like completed projects or no tasks.public async getNextTask(projectId: string): Promise<OpenTaskSuccessData | { message: string }> { await this.ensureInitialized(); await this.reloadFromDisk(); const proj = this.data.projects.find((p) => p.projectId === projectId); if (!proj) { throw new AppError(`Project ${projectId} not found`, AppErrorCode.ProjectNotFound); } if (proj.completed) { throw new AppError('Project is already completed', AppErrorCode.ProjectAlreadyCompleted); } if (!proj.tasks.length) { throw new AppError('Project has no tasks', AppErrorCode.TaskNotFound); } const nextTask = proj.tasks.find((t) => !(t.status === "done" && t.approved)); if (!nextTask) { // all tasks done and approved? const allDoneAndApproved = proj.tasks.every((t) => t.status === "done" && t.approved); if (allDoneAndApproved && !proj.completed) { return { message: `All tasks have been completed and approved. Awaiting project completion approval.` }; } throw new AppError('No incomplete or unapproved tasks found', AppErrorCode.TaskNotFound); } return { projectId: proj.projectId, task: { ...nextTask }, }; }