update_application
Modify an ArgoCD application by updating its project, repository, path, destination, revision, or sync settings. Automate syncing, pruning, or self-healing, and validate changes for accuracy.
Instructions
Update an existing application in ArgoCD
Args:
name: The application name to update (required)
project: New project name (optional)
repo_url: New Git repository URL (optional)
path: New path within the repository (optional)
dest_server: New destination K8s API server URL (optional)
dest_namespace: New destination namespace (optional)
revision: New Git revision (optional)
automated_sync: Enable/disable automated sync (optional)
prune: Enable/disable auto-pruning resources (optional)
self_heal: Enable/disable self-healing (optional)
validate: Whether to validate the application
Returns:
The updated application details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| automated_sync | No | ||
| dest_namespace | No | ||
| dest_server | No | ||
| name | Yes | ||
| path | No | ||
| project | No | ||
| prune | No | ||
| repo_url | No | ||
| revision | No | ||
| self_heal | No | ||
| validate | No |
Implementation Reference
- tools/applications.py:180-287 (handler)The primary handler function for the 'update_application' tool. It fetches the current application details from ArgoCD, applies the provided optional updates to project, source (repo, path, revision), destination (server, namespace), and sync policy fields, then performs a PUT request to update the application via the API client.async def update_application( name: str, project: Optional[str] = None, repo_url: Optional[str] = None, path: Optional[str] = None, dest_server: Optional[str] = None, dest_namespace: Optional[str] = None, revision: Optional[str] = None, automated_sync: Optional[bool] = None, prune: Optional[bool] = None, self_heal: Optional[bool] = None, validate: bool = True, ) -> Dict[str, Any]: """ Update an existing application in ArgoCD Args: name: The application name to update (required) project: New project name (optional) repo_url: New Git repository URL (optional) path: New path within the repository (optional) dest_server: New destination K8s API server URL (optional) dest_namespace: New destination namespace (optional) revision: New Git revision (optional) automated_sync: Enable/disable automated sync (optional) prune: Enable/disable auto-pruning resources (optional) self_heal: Enable/disable self-healing (optional) validate: Whether to validate the application Returns: The updated application details """ # First get the current application details success, app_data = await make_api_request(f"applications/{name}") if not success: return { "error": app_data.get( "error", f"Failed to get current application details for '{name}'" ) } # Update fields only if provided if project: app_data["spec"]["project"] = project if repo_url or path or revision: # Update source fields source = app_data["spec"].get("source", {}) if repo_url: source["repoURL"] = repo_url if path: source["path"] = path if revision: source["targetRevision"] = revision app_data["spec"]["source"] = source if dest_server or dest_namespace: # Update destination fields destination = app_data["spec"].get("destination", {}) if dest_server: destination["server"] = dest_server if dest_namespace: destination["namespace"] = dest_namespace app_data["spec"]["destination"] = destination # Update sync policy if any of those parameters are provided if automated_sync is not None or prune is not None or self_heal is not None: sync_policy = app_data["spec"].get("syncPolicy", {}) automated = ( sync_policy.get("automated", {}) if "automated" in sync_policy else None ) # Create automated section if it doesn't exist but should if automated_sync is True and automated is None: automated = {} sync_policy["automated"] = automated # Remove automated section if it exists but should not elif automated_sync is False and automated is not None: del sync_policy["automated"] # Update automated settings if automated is not None: if prune is not None: automated["prune"] = prune if self_heal is not None: automated["selfHeal"] = self_heal app_data["spec"]["syncPolicy"] = sync_policy # Add query parameters params = {} if validate: params["validate"] = "true" # Update the application success, response = await make_api_request( f"applications/{name}", method="PUT", data=app_data, params=params ) if success: logger.info(f"Application '{name}' updated successfully") return response else: logger.error(f"Failed to update application '{name}': {response.get('error')}") return { "error": response.get("error", f"Failed to update application '{name}'") }
- server.py:44-44 (registration)Registers the update_application function from tools.applications as an MCP tool using the FastMCP tool decorator.mcp.tool()(applications.update_application)
- server.py:18-18 (registration)Imports the applications module containing the update_application handler for registration.import tools.settings as settings