Skip to main content
Glama
vincenthopf

Gemini Web Automation MCP

by vincenthopf

stop_web_task

Stop a running web automation task to cancel unnecessary operations and free browser resources. Use this tool to halt long-running tasks immediately.

Instructions

Stop a running web browsing task.

Immediately halts task execution and cleans up browser resources. Use this
when you need to cancel a long-running task that's no longer needed.

Args:
    task_id: Task ID from start_web_task()

Returns:
    Dictionary containing:
    - ok: Boolean indicating success
    - message: Confirmation message
    - task_id: The stopped task ID
    - error: Error message (if task not found or already completed)

Examples:
    - stop_web_task("abc-123-def")

Note: Cannot stop tasks that are already completed or failed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYes

Implementation Reference

  • The primary handler for the 'stop_web_task' tool. Decorated with @mcp.tool() for automatic registration in the MCP server. Handles input validation via type hints, logs the action, calls the task_manager helper, and returns a standardized success/error response dictionary.
    async def stop_web_task(task_id: str) -> dict[str, Any]:
        """
        Stop a running web browsing task.
    
        Immediately halts task execution and cleans up browser resources. Use this
        when you need to cancel a long-running task that's no longer needed.
    
        Args:
            task_id: Task ID from start_web_task()
    
        Returns:
            Dictionary containing:
            - ok: Boolean indicating success
            - message: Confirmation message
            - task_id: The stopped task ID
            - error: Error message (if task not found or already completed)
    
        Examples:
            - stop_web_task("abc-123-def")
    
        Note: Cannot stop tasks that are already completed or failed.
        """
        logger.info(f"Stopping web task: {task_id}")
    
        success = task_manager.cancel_task(task_id)
    
        if success:
            return {
                "ok": True,
                "message": f"Task {task_id} cancelled successfully",
                "task_id": task_id
            }
        else:
            return {
                "ok": False,
                "error": f"Could not cancel task {task_id} (not found or already completed)",
                "task_id": task_id
            }
  • Core helper method in BrowserTaskManager that implements task cancellation logic: checks if cancellable, updates status to CANCELLED, sets completion time, and cleans up associated browser agent.
    def cancel_task(self, task_id: str) -> bool:
        """Cancel a running task.
    
        Args:
            task_id: Task identifier
    
        Returns:
            True if task was cancelled, False otherwise
        """
        with self._lock:
            task = self.tasks.get(task_id)
            if not task or task.status not in [TaskStatus.PENDING, TaskStatus.RUNNING]:
                return False
    
            task.status = TaskStatus.CANCELLED
            task.completed_at = datetime.now(timezone.utc).isoformat()
    
            # Clean up browser if running
            if task.agent:
                task.agent.cleanup_browser()
    
            return True

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/vincenthopf/computer-use-mcp'

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