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="操作返回的主要数据负载。")
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses the mutation behavior (marking as completed) and the downstream effect (unlocking dependencies), which are valuable. However, it doesn't mention permission requirements, whether the action is reversible, error conditions, or what happens if the task is already completed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with two sentences: first states the core action and its importance, second provides parameter semantics. Every sentence adds value with zero wasted words, and key information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 2 parameters, 0% schema coverage, no annotations, and no output schema, the description does a decent job explaining the action and parameters. However, it lacks details about return values, error handling, and behavioral nuances like idempotency or side effects, leaving some gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must fully compensate. It provides clear semantic meaning for both parameters: 'task_id' is explained as '需要标记为完成的任务的ID (从0开始)' (ID of task to mark as completed, starting from 0), and 'result' as '描述任务完成结果或产出的字符串' (string describing task completion result or output). This adds essential context beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('标记为 completed' - mark as completed) and resource ('指定ID的任务' - task with specified ID). It distinguishes from siblings like 'failTask' (marks as failed) and 'skipTask' (bypasses task), establishing a specific completion action.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by stating this is '关键步骤' (key step) for unlocking dependent tasks, which implies it should be used when a task is successfully finished. However, it doesn't explicitly mention when NOT to use it or name alternatives like 'failTask' for unsuccessful outcomes.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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