# set_environment

Source: https://libtmux.org/en/py/stable/mcp/tools/set_environment/

> Set a tmux environment variable.

tool MCPstable

MCP is in development

Server behavior and tool contracts may change. Tool availability depends on the server configuration.

* **set_environment**( [name](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fname): [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"), [session_id](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fsession_id)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [session_name](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fsession_name)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [socket_name](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fsocket_name)?: [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"), [value](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fvalue): [string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"), )

  tool \[[source](https://github.com/tmux-python/libtmux-mcp/blob/4daddc0dfca96c43bf521d818bf91564e1434760/src/libtmux_mcp/tools/env_tools.py#L130)][¶](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment)

  Set a tmux environment variable.

  Use to set variables that will be inherited by new panes and windows. Changes do not affect already-running processes.

  Some variables control later shell execution. Bash sources the file named by `BASH_ENV`, POSIX shells may source the file named by `ENV`, and Bash evaluates `PROMPT_COMMAND` before displaying a prompt.

  Warning

  Values set here propagate into **every** shell tmux later spawns in the targeted scope — including panes the user opens manually, not just panes the agent drives. A caller that writes `PATH`, `LD_PRELOAD`, or `AWS_*` variables can influence future commands the human user types directly. Treat this as elevated-risk within `execute`. The audit log redacts the `value` argument, but the side effects persist on disk/memory until tmux is restarted. Prefer `env VAR=value command` via [`send_keys`](https://libtmux.org/en/py/stable/mcp/tools/send_keys/) when you only need the override for a single command. See [topics/trust](https://libtmux-mcp.git-pull.com/topics/trust/).

  * MCP request method

    `tools/call` Send `set_environment` as the tool name, with the arguments below.

  ## Arguments[#](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.parameters)

  * **[`name`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fname)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Environment variable name.

  * **[`session_id`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fsession_id)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

    Session ID to set environment for.

  * **[`session_name`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fsession_name)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

    Session name to set environment for.

  * **[`socket_name`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fsocket_name)**? = `null` ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)") | [null](https://json-schema.org/understanding-json-schema/reference/null "null (JSON Schema)"))

    tmux socket name.

  * **[`value`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.input%2Fproperties%2Fvalue)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Environment variable value.

  No other arguments are accepted.

  ## Result[#](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.result)

  Returns [object](https://json-schema.org/understanding-json-schema/reference/object "object (JSON Schema)")

  * **[`name`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.output%2Fproperties%2Fname)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Variable name

  * **[`status`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.output%2Fproperties%2Fstatus)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Operation status

  * **[`value`](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.output%2Fproperties%2Fvalue)** ([string](https://json-schema.org/understanding-json-schema/reference/string "string (JSON Schema)"))

    Value that was set

  ## Annotations[#](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.annotations)

  * [`destructiveHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#destructiveHint)

    `true`

  * [`idempotentHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#idempotentHint)

    `false`

  * [`openWorldHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#openWorldHint)

    `true`

  * [`readOnlyHint`](https://libtmux.org/en/py/stable/mcp/reference/glossary/#readOnlyHint)

    `false`

  ## Protocol data[#](https://libtmux.org/en/py/stable/mcp/tools/set_environment/#mcp.tool.set_environment.schemas)

  Use the complete advertised contract for validation and client integration.

  Input schema

  ```json
  {
    "additionalProperties": false,
    "properties": {
      "name": {
        "description": "Environment variable name.",
        "type": "string"
      },
      "session_id": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Session ID to set environment for."
      },
      "session_name": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Session name to set environment for."
      },
      "socket_name": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "tmux socket name."
      },
      "value": {
        "description": "Environment variable value.",
        "type": "string"
      }
    },
    "required": [
      "name",
      "value"
    ],
    "type": "object"
  }
  ```

  Output schema

  ```json
  {
    "description": "Result of a set_environment call.",
    "properties": {
      "name": {
        "description": "Variable name",
        "type": "string"
      },
      "status": {
        "description": "Operation status",
        "type": "string"
      },
      "value": {
        "description": "Value that was set",
        "type": "string"
      }
    },
    "required": [
      "name",
      "value",
      "status"
    ],
    "type": "object"
  }
  ```
