Skip to main content
Glama

completeTask

Mark tasks as completed in MCPlanManager to unlock dependent tasks and track progress in AI agent task management systems.

Instructions

将指定ID的任务标记为 'completed' (已完成)。 这是解锁后续依赖任务的关键步骤。

Args: task_id (int): 需要标记为完成的任务的ID (从0开始)。 result (str): 描述任务完成结果或产出的字符串。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYes
resultYes

Implementation Reference

  • The primary MCP tool handler for 'completeTask'. Decorated with @mcp.tool() for automatic registration and schema generation from type hints. Delegates to PlanManager.completeTask for execution.
    @mcp.tool() def completeTask(task_id: int, result: str) -> ToolResponse[TaskOutput]: """ 将指定ID的任务标记为 'completed' (已完成)。 这是解锁后续依赖任务的关键步骤。 Args: task_id (int): 需要标记为完成的任务的ID (从0开始)。 result (str): 描述任务完成结果或产出的字符串。 """ return plan_manager.completeTask(task_id, result)
  • Core helper method in PlanManager that implements the task completion logic: validates task exists and is in_progress, updates status and result, manages current_task_id and plan status.
    def completeTask(self, task_id: int, result: str) -> Dict: """标记任务为完成状态""" task = self._find_task_by_id(task_id) if not task: return {"success": False, "message": f"Task {task_id} not found", "data": None} if task["status"] != "in_progress": return {"success": False, "message": f"Task {task_id} is not in progress", "data": None} task["status"] = "completed" task["result"] = result # 如果这是当前任务,清除当前任务ID if self.plan_data["state"]["current_task_id"] == task_id: self.plan_data["state"]["current_task_id"] = None # 检查是否所有任务都完成了 all_completed = all( task["status"] in ["completed", "skipped"] for task in self.plan_data["tasks"] ) if all_completed: self.plan_data["state"]["status"] = "completed" self._update_timestamp() return { "success": True, "data": task, "message": "Task completed successfully" }
  • Pydantic schema for TaskOutput, used in the ToolResponse data field for completeTask output.
    class TaskOutput(BaseModel): """ 用于工具函数返回任务信息时,定义单个任务输出的Pydantic模型。 """ id: int name: str status: str dependencies: List[int] reasoning: str result: Optional[str] = None
  • Generic Pydantic schema for ToolResponse[T], where T=TaskOutput for completeTask, defining the standardized output 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