Skip to main content
Glama

buildx_build

Build container images with BuildKit, supporting multi-platform builds, cache import/export, attestations, build secrets, and multi-stage targets.

Instructions

Build an image with BuildKit via docker buildx build.

Replaces the legacy image_build tool when you need any of: multi-platform output (platforms), modern cache export (cache_from/cache_to), SBOM or provenance attestations, build secrets, or multi-stage builds with target. Always runs with --progress=plain so output is captured rather than redrawn on a TTY. With no local buildx plugin and an ssh:// target, the build runs on that host: a local context directory is copied there honouring .dockerignore, as are file, build_contexts and secret paths. Raises ToolInputError in that case for output/cache_to with a filesystem dest=, cache_from with a local src=, or any ssh= - each would resolve on the remote machine, losing the output or silently changing the build. Does not raise on a non-zero CLI exit (a missing buildx plugin or a timeout still raises) - inspect returncode/stderr in the result.

Args: context: Build context: a filesystem path or Git/HTTP URL (verbatim; no ~/glob expansion). The - stdin-tarball form is NOT supported (stdin isn't forwarded - it'd block on the server's own stdin); serve a pre-packed tarball over HTTP instead. Copied to the target host when it names a local directory and there is no local plugin. tags: Image references to apply (-t, repeatable) platforms: Target platforms, e.g. ["linux/amd64", "linux/arm64"] file: Dockerfile path. A relative path resolves against this server's working directory (buildx's own rule), NOT against context - pass e.g. "ctx/Dockerfile" for a Dockerfile inside the context directory "ctx". build_args: Build-time variables (each becomes --build-arg KEY=VALUE) build_contexts: Additional named build contexts (e.g. {"deps": "./vendor"}) labels: Labels to set on the resulting image (each becomes --label KEY=VALUE) annotations: OCI manifest annotations (passed verbatim, repeatable) target: Target build stage to stop at push: Push the result to the registry (mutually exclusive with load) load: Load the result into the local image store (single-platform builds only) output: Custom --output specs (e.g. ["type=tar,dest=out.tar"]). A filesystem dest= is refused when the build has to run on a remote host; dest=- (stdout) is fine. no_cache: Do not use cache when building no_cache_filter: Stage names to exclude from caching pull: Always attempt to pull a newer version of each base image cache_from: Cache import specs, e.g. ["type=registry,ref=user/img:cache"] cache_to: Cache export specs builder: Override the active builder sbom: Shorthand for --attest=type=sbom; pass "true" or a config string provenance: Shorthand for --attest=type=provenance; pass "true", "false", or a config string attest: Custom attestation specs (repeatable) secret: Secret specs (e.g. ["id=npmrc,src=/home/user/.npmrc"] or ["id=npmrc,env=NPM_TOKEN"]). ~ in src= is NOT expanded (by this tool or the CLI) - use an absolute path. ssh: SSH agent socket/key specs (e.g. ["default"], using $SSH_AUTH_SOCK). Refused when the build has to run on a remote host: the socket read would be that host's. timeout_seconds: Subprocess timeout (default 1800s)

Returns: dict: {"returncode": int, "stdout": str, "stderr": str, "truncated": bool}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sshNo
fileNo
loadNo
pullNo
pushNo
sbomNo
tagsNo
attestNo
labelsNo
outputNo
secretNo
targetNo
builderNo
contextYes
cache_toNo
no_cacheNo
platformsNo
build_argsNo
cache_fromNo
provenanceNo
annotationsNo
build_contextsNo
no_cache_filterNo
timeout_secondsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.1.4
  2. Removedv2.1.4
  3. First observedv1.9.0

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations (readOnlyHint=false, destructiveHint=false), the description reveals that it always runs with --progress=plain, copies local context to remote hosts when no local plugin exists, and raises ToolInputError in specific remote scenarios. It also states that non-zero CLI exits do not raise but returncode/stderr should be inspected. This gives the agent a thorough understanding of side effects, error conditions, and edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but highly structured: a one-line summary, differentiation from the legacy tool, key behavioral notes, and then parameter explanations. Every sentence carries actionable information; there is no fluff or repetition. The use of headings and clear formatting makes the length appropriate for a tool with 24 parameters and complex remote execution semantics.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the tool's purpose, usage, constraints, error behavior, remote execution details, and returns an explicit return format (dict with returncode/stdout/stderr/truncated). It addresses pitfalls (e.g., stdin blocking, path expansion, remote-side resolution) and provides enough detail for an agent to invoke the tool successfully in any scenario. No gaps are apparent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description carries the full burden of documenting all 24 parameters. It provides a detailed Args section with explanations for each parameter, including examples and critical caveats (e.g., context not supporting stdin tarballs, relative Dockerfile path resolution, timeouts). This fully compensates for the empty schema and adds value beyond anything the schema could provide.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise action: 'Build an image with BuildKit via docker buildx build.' It then explicitly differentiates itself from the sibling `image_build` tool by listing the specific features it supports (multi-platform, cache export, attestations, secrets, multi-stage). This makes the tool's purpose unmistakable and distinguishes it from alternatives without needing to inspect schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool instead of `image_build` (for multi-platform, cache_from/cache_to, SBOM/provenance, secrets, target). It also explains the behavioral difference when a remote host is involved and lists conditions that raise ToolInputError. Clear guidance on when to use and what to expect, with no ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools