Skip to main content
Glama

startNextTask

Find and begin the next executable task with completed dependencies to advance project plans by updating task status to in-progress.

Instructions

自动查找下一个可执行的任务(所有依赖均已完成)并开始执行。 这会将任务状态更新为 'in_progress'。这是推进计划的核心方法。

Returns: ToolResponse[TaskOutput]: 包含已启动任务的响应对象。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler function for 'startNextTask'. Registered via @mcp.tool() decorator and delegates execution to PlanManager.startNextTask().
    @mcp.tool()
    def startNextTask() -> ToolResponse[TaskOutput]:
        """
        自动查找下一个可执行的任务(所有依赖均已完成)并开始执行。
        这会将任务状态更新为 'in_progress'。这是推进计划的核心方法。
        
        Returns:
            ToolResponse[TaskOutput]: 包含已启动任务的响应对象。
        """
        return plan_manager.startNextTask()
  • Core logic implementation in PlanManager class. Finds the next pending task with satisfied dependencies, marks it as in_progress, updates plan state, and returns the task details.
    def startNextTask(self) -> Dict:
        """自动开始下一个可执行的任务"""
        # 查找可执行的任务
        executable_tasks = []
        for task in self.plan_data["tasks"]:
            if (task["status"] == "pending" and 
                self._check_dependencies_satisfied(task)):
                executable_tasks.append(task)
        
        if not executable_tasks:
            return {"success": False, "message": "No executable tasks available", "data": None}
        
        # 选择第一个可执行的任务
        next_task = executable_tasks[0]
        next_task["status"] = "in_progress"
        self.plan_data["state"]["current_task_id"] = next_task["id"]
        self.plan_data["state"]["status"] = "running"
        
        self._update_timestamp()
        
        return {
            "success": True,
            "data": next_task,
            "message": f"Started task {next_task['id']}: {next_task['name']}"
        }
  • Pydantic model for TaskOutput, which defines the structure of the data returned by the startNextTask tool inside ToolResponse.
    class TaskOutput(BaseModel):
        """
        用于工具函数返回任务信息时,定义单个任务输出的Pydantic模型。
        """
        id: int
        name: str
        status: str
        dependencies: List[int]
        reasoning: str
        result: Optional[str] = None
  • Generic Pydantic model for ToolResponse[T], used as the return type for startNextTask (with T=TaskOutput). Defines the standardized response structure.
    class ToolResponse(BaseModel, Generic[T]):
        """
        一个通用的工具响应模型,用于标准化所有工具的返回结构。
        """
        success: bool = Field(True, description="操作是否成功。")
        message: Optional[str] = Field(None, description="关于操作结果的可读消息。")
        data: Optional[T] = Field(None, description="操作返回的主要数据负载。")

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/donway19/MCPlanManager'

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