update_variable
Update a Codemagic environment variable by specifying its app ID, variable ID, key, new value, group, and secure flag.
Instructions
Update an existing environment variable for a Codemagic application.
Args: app_id: The Codemagic application ID. variable_id: The variable ID to update. key: The variable name. value: The new variable value. group: The variable group name. secure: Whether the variable should be encrypted.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ||
| variable_id | Yes | ||
| key | Yes | ||
| value | Yes | ||
| group | Yes | ||
| secure | No |
Implementation Reference
- codemagic_mcp/tools/variables.py:46-73 (handler)MCP tool handler for update_variable - receives app_id, variable_id, key, value, group, secure and delegates to the CodemagicClient.
@mcp.tool() async def update_variable( app_id: str, variable_id: str, key: str, value: str, group: str, secure: bool = False, ) -> Any: """Update an existing environment variable for a Codemagic application. Args: app_id: The Codemagic application ID. variable_id: The variable ID to update. key: The variable name. value: The new variable value. group: The variable group name. secure: Whether the variable should be encrypted. """ async with CodemagicClient() as client: return await client.update_variable( app_id=app_id, variable_id=variable_id, key=key, value=value, group=group, secure=secure, ) - codemagic_mcp/client.py:442-454 (schema)Client method implementing the actual API call - sends PUT to /apps/{app_id}/variables/{variable_id} with the variable data.
async def update_variable( self, app_id: str, variable_id: str, key: str, value: str, group: str, secure: bool = False, ) -> Any: return await self._put( f"/apps/{app_id}/variables/{variable_id}", json={"key": key, "value": value, "group": group, "secure": secure}, ) - codemagic_mcp/tools/__init__.py:6-13 (registration)Registration chain: register_all_tools -> variables.register(mcp) is called, which registers update_variable via @mcp.tool() decorator.
def register_all_tools(mcp: FastMCP) -> None: apps.register(mcp) builds.register(mcp) artifacts.register(mcp) caches.register(mcp) variables.register(mcp) webhooks.register(mcp) - codemagic_mcp/server.py:8-43 (registration)Entry point: server.py imports register_all_tools and calls it with the mcp instance, initiating tool registration.
from codemagic_mcp.tools import register_all_tools async def _step_log_cleanup_loop() -> None: while True: async with CodemagicClient() as client: client.cleanup_step_log_artifacts() await asyncio.sleep(settings.codemagic_log_cleanup_interval_seconds) @asynccontextmanager async def lifespan(_: FastMCP): async with CodemagicClient() as client: client.cleanup_step_log_artifacts() cleanup_task = asyncio.create_task(_step_log_cleanup_loop()) try: yield finally: cleanup_task.cancel() with suppress(asyncio.CancelledError): await cleanup_task mcp = FastMCP( name="Codemagic MCP", instructions=( "Codemagic CI/CD REST API: manage builds, apps, artifacts, caches, variables, and webhooks.\n\n" "Destructive ops (delete_app, cancel_build, delete_cache, delete_all_caches, delete_variable, delete_webhook): confirm before executing.\n\n" "App ID resolution: (1) use explicit app_id; (2) use CODEMAGIC_DEFAULT_APP_ID if set (exposed as `default_app_id`); " "(3) call list_apps — auto-select if one result, else ask user." ), lifespan=lifespan, ) register_all_tools(mcp)