sync_application
Synchronize ArgoCD applications with specified revisions, resources, and strategies. Supports pruning, dry runs, and custom namespaces to manage application deployments effectively.
Instructions
Sync an application in ArgoCD
Args:
name: The name of the application to sync (required)
revision: Git revision to sync to (optional)
prune: Whether to prune resources (default: False)
dry_run: Whether to perform a dry run (default: False)
strategy: Sync strategy ("apply" or "hook")
resources: List of resources to sync (optional)
namespace: The application namespace (optional)
Returns:
Sync result details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | ||
| name | Yes | ||
| namespace | No | ||
| prune | No | ||
| resources | No | ||
| revision | No | ||
| strategy | No |
Implementation Reference
- tools/applications.py:336-384 (handler)The main handler function for the "sync_application" MCP tool. It constructs the sync request payload based on input parameters and performs a POST request to the ArgoCD API endpoint `/applications/{name}/sync` to initiate synchronization.async def sync_application( name: str, revision: str = "", prune: bool = False, dry_run: bool = False, strategy: str = "", resources: Optional[List[Dict[str, str]]] = None, namespace: str = "", ) -> Dict[str, Any]: """ Sync an application in ArgoCD Args: name: The name of the application to sync (required) revision: Git revision to sync to (optional) prune: Whether to prune resources (default: False) dry_run: Whether to perform a dry run (default: False) strategy: Sync strategy ("apply" or "hook") resources: List of resources to sync (optional) namespace: The application namespace (optional) Returns: Sync result details """ data = {"name": name, "prune": prune, "dryRun": dry_run} if revision: data["revision"] = revision if strategy and strategy in ["apply", "hook"]: data["strategy"] = {"hook": {}} if strategy == "hook" else {"apply": {}} if resources: data["resources"] = resources params = {} if namespace: params["appNamespace"] = namespace success, response = await make_api_request( f"applications/{name}/sync", method="POST", data=data, params=params ) if success: logger.info(f"Application '{name}' sync initiated") return response else: logger.error(f"Failed to sync application '{name}': {response.get('error')}") return {"error": response.get("error", f"Failed to sync application '{name}'")}
- server.py:46-46 (registration)Registers the `sync_application` function as an MCP tool using the `mcp.tool()` decorator in the FastMCP server.mcp.tool()(applications.sync_application)
- server.py:18-18 (registration)Import statement that brings the `sync_application` handler into scope for registration in the MCP server.import tools.settings as settings