Centralized Configuration
The most powerful tools for enterprise administration are the system-wide settings files. These files allow you to define a baseline configuration (system-defaults.json) and a set of overrides (settings.json) that apply to all users on a machine.
Settings Precedence
Settings are merged from four files. The precedence order for single-value settings (liketheme) is:
For settings that are arrays (
includeDirectories) or objects (mcpServers), the values are merged.
Example: Settings Merging
Here is how settings from different levels are combined.System defaults (system-defaults.json)
System defaults (system-defaults.json)
User settings (~/.gemini/settings.json)
User settings (~/.gemini/settings.json)
Workspace settings (<project>/.gemini/settings.json)
Workspace settings (<project>/.gemini/settings.json)
System overrides (settings.json)
System overrides (settings.json)
Final merged configuration
Final merged configuration
theme: The value from the system overrides (system-enforced-theme) is used, as it has the highest precedencemcpServers: The objects are merged. Thecorp-serverdefinition from the system overrides takes precedence over the user’s definition. The uniqueuser-toolandproject-toolare includedincludeDirectories: The arrays are concatenated in the order of System Defaults, User, Workspace, and then System Overrides
System Settings File Location
- Linux
- Windows
- macOS
/etc/gemini-cli/settings.jsonThe path can be overridden using the
GEMINI_CLI_SYSTEM_SETTINGS_PATH environment variable.This file should be managed by system administrators and protected with appropriate file permissions to prevent unauthorized modification by users.
Enforcing System Settings with a Wrapper Script
While theGEMINI_CLI_SYSTEM_SETTINGS_PATH environment variable provides flexibility, a user could potentially override it to point to a different settings file, bypassing the centrally managed configuration. To mitigate this, enterprises can deploy a wrapper script or alias that ensures the environment variable is always set to the corporate-controlled path.
Example wrapper script:
Administrators can create a script named gemini and place it in a directory that appears earlier in the user’s PATH than the actual Gemini CLI binary (e.g., /usr/local/bin/gemini).
GEMINI_CLI_SYSTEM_SETTINGS_PATH is set within the script’s environment, and the exec command replaces the script process with the actual Gemini CLI process, which inherits the environment variable. This makes it significantly more difficult for a user to bypass the enforced settings.
User Isolation in Shared Environments
In shared compute environments (like ML experiment runners or shared build servers), you can isolate Gemini CLI state by overriding the user’s home directory. By default, Gemini CLI stores configuration and history in~/.gemini. You can use the GEMINI_CLI_HOME environment variable to point to a unique directory for a specific user or job. The CLI will create a .gemini folder inside the specified path.
Restricting Tool Access
You can significantly enhance security by controlling which tools the Gemini model can use. This is achieved through thetools.core setting.
Allowlisting with coreTools
The most secure approach is to explicitly add the tools and commands that users are permitted to execute to an allowlist. This prevents the use of any tool not on the approved list.
Example: Allow only safe, read-only file operations and listing files.
Blocklisting with excludeTools
Alternatively, you can add specific tools that are considered dangerous in your environment to a blocklist.
Example: Prevent the use of the shell tool for removing files.
Security note: Blocklisting with
excludeTools is less secure than allowlisting with coreTools, as it relies on blocking known-bad commands, and clever users may find ways to bypass simple string-based blocks. Allowlisting is the recommended approach.Disabling YOLO Mode
To ensure that users cannot bypass the confirmation prompt for tool execution, you can disable YOLO mode at the policy level. This adds a critical layer of safety, as it prevents the model from executing tools without explicit user approval. Example: Force all tool executions to require user confirmation.Managing Custom Tools (MCP Servers)
If your organization uses custom tools via Model-Context Protocol (MCP) servers, it is crucial to understand how server configurations are managed to apply security policies effectively.How MCP Server Configurations Are Merged
Gemini CLI loadssettings.json files from three levels: System, Workspace, and User. When it comes to the mcpServers object, these configurations are merged:
- Merging: The lists of servers from all three levels are combined into a single list
- Precedence: If a server with the same name is defined at multiple levels (e.g., a server named
corp-apiexists in both system and user settings), the definition from the highest-precedence level is used. The order of precedence is: System > Workspace > User
This means a user cannot override the definition of a server that is already defined in the system-level settings. However, they can add new servers with unique names.
Restricting Tools Within an MCP Server
For even greater security, especially when dealing with third-party MCP servers, you can restrict which specific tools from a server are exposed to the model. This is done using theincludeTools and excludeTools properties within a server’s definition.
Following the principle of least privilege, it is highly recommended to use includeTools to create an allowlist of only the necessary tools.
Example: Only allow the code-search and get-ticket-details tools from a third-party MCP server.
Secure Pattern: Define and Allowlist in System Settings
To create a secure, centrally-managed catalog of tools, the system administrator must do both of the following in the system-levelsettings.json file:
Define full configuration
Define the full configuration for every approved server in the
mcpServers object. This ensures that even if a user defines a server with the same name, the secure system-level definition will take precedence.settings.json:
mcp.allowed list.
Less Secure Pattern: Omitting the Allowlist
Example systemsettings.json (not recommended):
settings.json. Because there is no mcp.allowed list to filter the merged results, the user’s server will be added to the list of available tools and allowed to run.
Enforcing Sandboxing for Security
To mitigate the risk of potentially harmful operations, you can enforce the use of sandboxing for all tool execution. The sandbox isolates tool execution in a containerized environment. Example: Force all tool execution to happen within a Docker sandbox.You can also specify a custom, hardened Docker image for the sandbox by building a custom
sandbox.Dockerfile.Controlling Network Access via Proxy
In corporate environments with strict network policies, you can configure Gemini CLI to route all outbound traffic through a corporate proxy. This can be set via an environment variable, but it can also be enforced for custom tools via themcpServers configuration.
Example:
Telemetry and Auditing
For auditing and monitoring purposes, you can configure Gemini CLI to send telemetry data to a central location. This allows you to track tool usage and other events. Example: Enable telemetry and send it to a local OTLP collector.Authentication
You can enforce a specific authentication method for all users by setting theenforcedAuthType in the system-level settings.json file. This prevents users from choosing a different authentication method.
Example: Enforce the use of Google login for all users.
If a user has a different authentication method configured, they will be prompted to switch to the enforced method. In non-interactive mode, the CLI will exit with an error if the configured authentication method does not match the enforced one.
Restricting Logins to Corporate Domains
For enterprises using Google Workspace, you can enforce that users only authenticate with their corporate Google accounts. This is a network-level control that is configured on a proxy server, not within Gemini CLI itself. It works by intercepting authentication requests to Google and adding a special HTTP header. For detailed instructions, see the Google Workspace Admin Help article. The general steps are as follows:
Example header:
Complete Example: System Settings
Here is an example of a systemsettings.json file that combines several of the patterns discussed above to create a secure, controlled environment for Gemini CLI.
- Forces all tool execution into a Docker sandbox
- Strictly uses an allowlist for a small set of safe shell commands and file tools
- Defines and allows a single corporate MCP server for custom tools
- Enables telemetry for auditing, without logging prompt content
- Redirects the
/bugcommand to an internal ticketing system - Disables general usage statistics collection