add_variable
Add an environment variable to a Codemagic app. Provide name, value, group, and optionally mark as secure for secrets.
Instructions
Add an environment variable to a Codemagic application.
Args: app_id: The Codemagic application ID. key: The variable name. value: The variable value. group: The variable group name. secure: Whether the variable should be encrypted (e.g. for secrets/tokens).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ||
| key | Yes | ||
| value | Yes | ||
| group | Yes | ||
| secure | No |
Implementation Reference
- codemagic_mcp/tools/variables.py:20-44 (handler)MCP tool handler that adds an environment variable to a Codemagic app. Decorated with @mcp.tool() and registered via the variables.register() function.
@mcp.tool() async def add_variable( app_id: str, key: str, value: str, group: str, secure: bool = False, ) -> Any: """Add an environment variable to a Codemagic application. Args: app_id: The Codemagic application ID. key: The variable name. value: The variable value. group: The variable group name. secure: Whether the variable should be encrypted (e.g. for secrets/tokens). """ async with CodemagicClient() as client: return await client.add_variable( app_id=app_id, key=key, value=value, group=group, secure=secure, ) - Input schema defined by function signature: app_id (str), key (str), value (str), group (str), secure (bool, default False). Return type is Any.
@mcp.tool() async def add_variable( app_id: str, key: str, value: str, group: str, secure: bool = False, ) -> Any: - codemagic_mcp/tools/__init__.py:6-12 (registration)Registration orchestration: register_all_tools() in __init__.py imports and calls variables.register(mcp), which decorates add_variable with @mcp.tool().
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/client.py:429-440 (helper)API client helper in CodemagicClient class. Sends POST /apps/{app_id}/variables with the variable data payload.
async def add_variable( self, app_id: str, key: str, value: str, group: str, secure: bool = False, ) -> Any: return await self._post( f"/apps/{app_id}/variables", json={"key": key, "value": value, "group": group, "secure": secure}, )