---
title: thv config set-build-env
hide_title: true
description: Reference for ToolHive CLI command `thv config set-build-env`
last_update:
  author: autogenerated
slug: thv_config_set-build-env
mdx:
  format: md
---

## thv config set-build-env

Set a build environment variable for protocol builds

### Synopsis

Set a build environment variable that will be injected into Dockerfiles
during protocol builds (npx://, uvx://, go://). This is useful for configuring
custom package mirrors in corporate environments.

Environment variable names must:
- Start with an uppercase letter
- Contain only uppercase letters, numbers, and underscores
- Not be a reserved system variable (PATH, HOME, etc.)

You can set the value in three ways:
1. Directly: thv config set-build-env KEY value
2. From a ToolHive secret: thv config set-build-env KEY --from-secret secret-name
3. From shell environment: thv config set-build-env KEY --from-env

Common use cases:
- NPM_CONFIG_REGISTRY: Custom npm registry URL
- PIP_INDEX_URL: Custom PyPI index URL
- UV_DEFAULT_INDEX: Custom uv package index URL
- GOPROXY: Custom Go module proxy URL
- GOPRIVATE: Private Go module paths

Examples:
  thv config set-build-env NPM_CONFIG_REGISTRY https://npm.corp.example.com
  thv config set-build-env GITHUB_TOKEN --from-secret github-pat
  thv config set-build-env ARTIFACTORY_API_KEY --from-env

```
thv config set-build-env <KEY> [value] [flags]
```

### Options

```
      --from-env      Read value from shell environment at build time
      --from-secret   Read value from a ToolHive secret at build time (value argument becomes secret name)
  -h, --help          help for set-build-env
```

### Options inherited from parent commands

```
      --debug   Enable debug mode
```

### SEE ALSO

* [thv config](thv_config.md)	 - Manage application configuration

