trigger_build
Trigger a build for your Codemagic app by specifying application ID, workflow, branch or tag, with optional environment variables and instance type.
Instructions
Trigger a new build for a Codemagic application.
Args: app_id: The Codemagic application ID. workflow_id: The workflow ID to run. branch: Git branch to build (mutually exclusive with tag). tag: Git tag to build (mutually exclusive with branch). environment: Optional environment variables to override, e.g. {"variables": {"KEY": "value"}}. instance_type: Optional machine instance type to use for the build.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ||
| workflow_id | Yes | ||
| branch | No | ||
| tag | No | ||
| environment | No | ||
| instance_type | No |
Implementation Reference
- codemagic_mcp/tools/builds.py:47-74 (handler)The MCP tool handler function for 'trigger_build'. This is the actual tool function registered with the MCP server. It accepts app_id, workflow_id, branch, tag, environment, and instance_type, and delegates to CodemagicClient.trigger_build().
@mcp.tool() async def trigger_build( app_id: str, workflow_id: str, branch: str | None = None, tag: str | None = None, environment: dict[str, Any] | None = None, instance_type: str | None = None, ) -> Any: """Trigger a new build for a Codemagic application. Args: app_id: The Codemagic application ID. workflow_id: The workflow ID to run. branch: Git branch to build (mutually exclusive with tag). tag: Git tag to build (mutually exclusive with branch). environment: Optional environment variables to override, e.g. {"variables": {"KEY": "value"}}. instance_type: Optional machine instance type to use for the build. """ async with CodemagicClient() as client: return await client.trigger_build( app_id=app_id, workflow_id=workflow_id, branch=branch, tag=tag, environment=environment, instance_type=instance_type, ) - codemagic_mcp/client.py:207-228 (helper)The CodemagicClient.trigger_build() method that builds the API payload and sends a POST request to /builds. This is the core helper that executes the HTTP call.
async def trigger_build( self, app_id: str, workflow_id: str, branch: str | None = None, tag: str | None = None, environment: dict[str, Any] | None = None, instance_type: str | None = None, ) -> Any: payload: dict[str, Any] = { "appId": app_id, "workflowId": workflow_id, } if branch is not None: payload["branch"] = branch if tag is not None: payload["tag"] = tag if environment is not None: payload["environment"] = environment if instance_type is not None: payload["instanceType"] = instance_type return await self._post("/builds", json=payload) - codemagic_mcp/tools/builds.py:9-9 (registration)The register() function in builds.py that, when called, registers all build-related MCP tools (including trigger_build) via the @mcp.tool() decorator.
def register(mcp: FastMCP) -> None: - codemagic_mcp/tools/__init__.py:6-12 (registration)The register_all_tools() function that calls builds.register(mcp) to trigger registration of all build tools including trigger_build.
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)