---
title: "corestack_enterprise_variable_set"
url: https://docs.corefinity.com/mcp/tools/corestack_enterprise_variable_set
type: tool
last_updated: 2026-11-13
feature: enterprise-variables
related:
  - https://docs.corefinity.com/guides/corestack-enterprise/environment-variables.md
---
# corestack_enterprise_variable_set

**Set a CoreStack Enterprise build variable.** Create, change, clear or rename one of a CoreStack Enterprise environment's build variables, which its deployments receive as CF_<name>. The value is write-only: it is never shown again here. Scope: write.

- Scope: `write`
- Runs as a task: no

## When to use it

Create, change, clear or rename one of a CoreStack Enterprise environment's build variables: the Environment Variables
editor's Save. Every deployment of the environment receives it as `CF_<name>`.

- `value` left out keeps the stored value (a rename alone).
- `value` as `""` or null clears it: the variable stays, with no value.
- Any other string sets it. A new variable needs one.
- `rename_to` renames the variable and keeps its value, unless `value` changes it too, so a rename never needs the value
  shown first. The new name follows the rules for a new variable's name and must be free. A rename that only changes the
  case (`api_token` to `API_TOKEN`) is allowed.

The name rules below apply to a name being created and to `rename_to`. A variable the environment already has is found by
the name it was saved with, so one saved before today's rules (with a hyphen, say) can still be changed, cleared, or
renamed to a name that follows them.

The value is write-only: the answer, `{variable: {name, masked, updated_at}, created}`, carries only the mask, and the
value is never shown again here. `corestack_enterprise_variable_reveal` shows it. For a CoreStack or CoreCluster site, use
`corestack_deployments_variable_set` by `site_id` instead.

The public API's `PUT /api/environments/{environment}/variables/{name}` does the same, with the same checks and
refusals in the same words.

## Inputs

- `enterprise_env_id` (integer, ≥ 1, required)
- `name` (string, required): without the `CF_` prefix. A new name: letters, digits and underscores, starting with a
  letter or an underscore, at most 64 characters. An existing variable: its name as `corestack_enterprise_variables_list`
  gives it.
- `value` (string or null): at most 2,048 characters, with no line breaks, control or invisible formatting characters.
- `rename_to` (string or null): the variable's new name.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "enterprise_env_id": {
      "description": "A CoreStack Enterprise environment's id; for CoreStack or CoreCluster use the corestack_deployment_* tools.",
      "minimum": 1,
      "type": "integer"
    },
    "name": {
      "description": "Without the CF_ prefix.",
      "type": "string"
    },
    "rename_to": {
      "description": "A new name; the value is kept unless value changes it.",
      "type": [
        "string",
        "null"
      ]
    },
    "value": {
      "description": "Left out: kept. \"\" or null: cleared. A new variable needs one.",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "enterprise_env_id",
    "name"
  ],
  "type": "object"
}
```

## Refusals

- `variable_invalid` (`details.field` is `name`, `rename_to` or `value`): a new name or `rename_to` that breaks the rule
  above or starts with `CF_` ("Use letters, digits and underscores, starting with a letter or underscore, without the CF_
  prefix (CoreStack adds it)."); a value that is too long, holds a line break, a control or an invisible formatting
  character, or a new variable with no value ("Use at most 2,048 characters, with no line breaks, control or invisible
  formatting characters.").
- `variable_reserved`: a new name (or `rename_to`) CoreStack sets itself, such as `DOMAIN` ("CF_DOMAIN is set by
  CoreStack. Choose another name."). An existing variable of such a name can still be changed or deleted.
- `variable_tool_credential`: a new name (or `rename_to`) of a build tool's credential (`COMPOSER_AUTH`, `NPM_TOKEN`,
  `NODE_AUTH_TOKEN`, `YARN_NPM_AUTH_TOKEN`, `GITHUB_TOKEN`, `GITLAB_TOKEN`, `BITBUCKET_TOKEN`, in any case): builds see it
  as `CF_<name>`, so the tool would never read it.
- `too_many_variables`: the environment already holds the most variables it can (`limit` in the list).
- `exists` (409): `rename_to` names another variable the environment already has ("This environment already has a
  variable with that name."). Choose another name, or delete that variable first.
- `invalid_arguments` (field `enterprise_env_id`): a CoreStack or CoreCluster environment; use the
  `corestack_deployments_*` tools by `site_id`.
- `tenant_mismatch` ("Not found."): the environment does not exist, is not the person's, or is hidden from them; and a
  rename of a variable the environment does not have. Both answers are the same, so read
  `corestack_enterprise_variables_list` to tell them apart.
- `pin_refused`, and the refusals every tool can answer: `scope_required`, `rate_limited`, `temporarily_unavailable`,
  `internal_error` (corestack://guides/how-this-server-works).

Nothing is changed by a refused call.

## Example

```json
{
  "name": "corestack_enterprise_variable_set",
  "arguments": {
    "enterprise_env_id": 1530,
    "name": "API_URL",
    "value": "https://api.example.com"
  }
}
```

```json
{
  "name": "corestack_enterprise_variable_set",
  "arguments": {
    "enterprise_env_id": 1530,
    "name": "API_URL",
    "rename_to": "SERVICE_URL"
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_enterprise_variable_set with enterprise_env_id 1530, name API_URL, value https://api.example.com. (Set a CoreStack Enterprise build variable.) Tell me what it returned.
```

## The same task elsewhere

- Guide: [Environment variables](https://docs.corefinity.com/guides/corestack-enterprise/environment-variables.md)
