Skip to main content
Glama

failTask

Mark a task as failed in MCPlanManager by providing a task ID and error message, with options to specify retry behavior for task management.

Instructions

将指定ID的任务标记为 'failed' (失败)。

Args: task_id (int): 需要标记为失败的任务的ID (从0开始)。 error_message (str): 描述任务失败原因的字符串。 should_retry (bool, optional): 是否应该重试该任务的标志。默认为 True。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYes
error_messageYes
should_retryNo

Implementation Reference

  • MCP tool handler for 'failTask', registered via @mcp.tool() decorator. Defines input schema via type hints and docstring, delegates to PlanManager.failTask.
    @mcp.tool()
    def failTask(task_id: int, error_message: str, should_retry: bool = True) -> ToolResponse[TaskOutput]:
        """
        将指定ID的任务标记为 'failed' (失败)。
    
        Args:
            task_id (int): 需要标记为失败的任务的ID (从0开始)。
            error_message (str): 描述任务失败原因的字符串。
            should_retry (bool, optional): 是否应该重试该任务的标志。默认为 True。
        """
        return plan_manager.failTask(task_id, error_message, should_retry)
  • Core implementation of failTask in PlanManager class. Updates task status to 'failed', sets result to error_message, clears current task ID if matching, updates timestamp, and returns success response with updated task data.
    def failTask(self, task_id: int, error_message: str, should_retry: bool = True) -> Dict:
        """标记任务失败"""
        task = self._find_task_by_id(task_id)
        if not task:
            return {"success": False, "message": f"Task {task_id} not found", "data": None}
        
        task["status"] = "failed"
        task["result"] = error_message
        
        # 如果这是当前任务,清除当前任务ID
        if self.plan_data["state"]["current_task_id"] == task_id:
            self.plan_data["state"]["current_task_id"] = None
        
        self._update_timestamp()
        
        return {
            "success": True,
            "data": task,
            "message": f"Task failed: {error_message}"
        }

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