---
title: "corestack_deployments_variable_set"
url: https://docs.corefinity.com/mcp/tools/corestack_deployments_variable_set
type: tool
last_updated: 2026-11-13
feature: deployment-variables
related:
  - https://docs.corefinity.com/api/reference/deployments/update-site-deployment-variable.md
  - https://docs.corefinity.com/guides/sites/code-and-deployments/variables-and-secrets.md
---
# corestack_deployments_variable_set

**Set a deployment variable.** Create or change one of the environment's deployment variables, which every stage receives 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 or change one of the environment's deployment variables, which every stage receives as CF_<name>. Send `value`, `log_visibility` or both. The value is write-only: it is never shown again here.

The same action in the public REST API, with the same checks, refusals and scope: `PUT /api/corestack/sites/{site}/deployments/variables/{name}`.

## Inputs

- `site_id` (integer, ≥ 1, required)
- `name` (string, matching `^[A-Za-z_][A-Za-z0-9_]{0,63}$`, required): Without the CF_ prefix.
- `value` (string, at most 2048 characters)
- `log_visibility` (string, one of `hidden`, `shown`): hidden (default) masks it in deployment output.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "log_visibility": {
      "description": "hidden (default) masks it in deployment output.",
      "enum": [
        "hidden",
        "shown"
      ],
      "type": "string"
    },
    "name": {
      "description": "Without the CF_ prefix.",
      "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
      "type": "string"
    },
    "site_id": {
      "minimum": 1,
      "type": "integer"
    },
    "value": {
      "maxLength": 2048,
      "type": "string"
    }
  },
  "required": [
    "site_id",
    "name"
  ],
  "type": "object"
}
```

## Refusals

- `variable_reserved`: that name is reserved for a value the platform sets.
- `variable_tool_credential`: a new variable named as 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; `details.field` is `name`). Builds receive every variable as CF_<name>, so the tool would never read it: "Builds see this variable as CF_COMPOSER_AUTH, so Composer never reads it. Add the credentials under Deployments > Private registries instead." Save the credentials with `corestack_deployments_secret_set` instead. An existing variable of such a name is kept and can still be changed or deleted; the list marks it with the same sentence as its `tool_credential`.
- `variable_invalid`: the value has a line break, a control character or is too long.
- `invalid_arguments`: `log_visibility: shown` without a `value`, for a variable whose stored value is hidden (showing it would reveal it): "Send the value with log_visibility shown. A stored value is read only through its reveal."
- `managed_elsewhere` (message: "This site is managed by another control panel"): another control panel manages this site, so use that control panel for it. This is refused before anything else about the site, as in the Control Panel and the API. Nothing was done.
- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_deployments_variable_set",
  "arguments": {
    "site_id": 4211,
    "name": "API_URL",
    "value": "https://api.example.com",
    "log_visibility": "shown"
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_deployments_variable_set with site_id 4211, name API_URL, value https://api.example.com, log_visibility shown. (Set a deployment variable.) Tell me what it returned.
```

## The same task elsewhere

- Endpoint: [PUT /api/corestack/sites/{site}/deployments/variables/{name}](https://docs.corefinity.com/api/reference/deployments/update-site-deployment-variable.md)
- Guide: [Variables](https://docs.corefinity.com/guides/sites/code-and-deployments/variables-and-secrets.md)
