jules_approve_plan
Approve execution plans for Google Jules AI coding tasks to proceed with automated development workflows and code generation.
Instructions
Approve Jules execution plan for a task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| taskId | Yes | Task ID or URL |
Implementation Reference
- src/index.ts:1418-1454 (handler)Executes the jules_approve_plan tool by navigating to the Jules task page with Playwright, locating the approval button via CSS selector, clicking it if present, and returning appropriate success or status messages.private async approvePlan(args: any) { const { taskId } = args; const actualTaskId = this.extractTaskId(taskId); const page = await this.getPage(); try { const url = taskId.includes('jules.google.com') ? taskId : `${this.config.baseUrl}/task/${actualTaskId}`; await page.goto(url); await page.waitForLoadState('networkidle'); // Look for approval button const approveButton = page.locator("div.approve-plan-container > button"); if (await approveButton.isVisible()) { await approveButton.click(); return { content: [ { type: 'text', text: `Plan approved for task ${actualTaskId}. Jules will now execute the planned changes.` } ] }; } else { return { content: [ { type: 'text', text: `No plan approval needed for task ${actualTaskId}. The task may already be approved or not ready for approval yet.` } ] }; } } catch (error) { throw new Error(`Failed to approve plan: ${error}`); } }
- src/index.ts:195-207 (schema)Input schema for the jules_approve_plan tool, requiring a 'taskId' parameter as a string (can be task ID or full URL).name: 'jules_approve_plan', description: 'Approve Jules execution plan for a task', inputSchema: { type: 'object', properties: { taskId: { type: 'string', description: 'Task ID or URL', }, }, required: ['taskId'], }, },
- src/index.ts:372-373 (registration)Tool registration/dispatch in the MCP CallToolRequestSchema handler switch statement, mapping 'jules_approve_plan' calls to the approvePlan method.return await this.approvePlan(args); case 'jules_resume_task':
- src/index.ts:1236-1242 (helper)Helper function used by approvePlan (and other tools) to normalize taskId input, extracting ID from full Jules URLs if provided.private extractTaskId(taskIdOrUrl: string): string { if (taskIdOrUrl.includes('jules.google.com/task/')) { const match = taskIdOrUrl.match(/\/task\/([^/]+)/); return match ? match[1] : taskIdOrUrl; } return taskIdOrUrl; }
- Python client-side wrapper function that invokes the MCP 'jules_approve_plan' tool, validates task status, updates local storage, and handles responses.def approve_plan(manager: Dict[str, Any], task_id: str) -> bool: """Approve a plan via MCP and update task status. Args: manager: Job manager dictionary produced by ``create_job_manager``. task_id: Identifier for the task awaiting approval. Returns: Boolean representing whether approval succeeded. Raises: ValueError: When dependencies are missing or task is not in approval state. KeyError: If the task does not exist in storage. RuntimeError: When MCP invocation fails or returns an error payload. """ validated_id = _validate_task_identifier(task_id) mcp_client = manager.get("mcp_client") if mcp_client is None: raise ValueError("MCP client is missing") storage_manager = manager.get("storage") if storage_manager is None: raise ValueError("Storage manager is missing") existing_task = storage.get_task(storage_manager, validated_id) normalized_task = models.jules_task_from_dict(existing_task) current_status = normalized_task.get("status") if current_status != "waiting_approval": raise ValueError("Task must be waiting for approval") payload = {"taskId": validated_id} LOGGER.info("Approving plan via MCP", extra=payload) try: response = _invoke_mcp_tool(mcp_client, "jules_approve_plan", payload) except Exception as error: # noqa: BLE001 LOGGER.error("MCP invocation failed", extra={"task_id": validated_id}) raise RuntimeError("Failed to approve plan via MCP") from error text_payload = _extract_response_text(response) try: raw_data = json.loads(text_payload) except json.JSONDecodeError as error: raise ValueError("Unable to parse approval payload") from error if not isinstance(raw_data, dict): raise ValueError("Approval payload must be a dictionary") success_value = raw_data.get("success") if success_value is False: return False if raw_data.get("error"): message_text = str(raw_data.get("error")) raise RuntimeError(f"MCP plan approval failed: {message_text}") if success_value is None: raise ValueError("Approval payload missing success indicator") if success_value is not True: raise ValueError("Unexpected success value in approval payload") normalized_task["status"] = "in_progress" normalized_task["updated_at"] = datetime.now().astimezone() serialized_task = models.jules_task_to_dict(normalized_task) storage.save_task(storage_manager, serialized_task) return True