@google/gemini-cli-core 0.21.0-nightly.20251219.70696e364 → 0.21.0-nightly.20251220.41a1a3eed

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/docs/CONTRIBUTING.md +546 -0
  2. package/dist/docs/architecture.md +80 -0
  3. package/dist/docs/assets/connected_devtools.png +0 -0
  4. package/dist/docs/assets/gemini-screenshot.png +0 -0
  5. package/dist/docs/assets/release_patch.png +0 -0
  6. package/dist/docs/assets/theme-ansi-light.png +0 -0
  7. package/dist/docs/assets/theme-ansi.png +0 -0
  8. package/dist/docs/assets/theme-atom-one.png +0 -0
  9. package/dist/docs/assets/theme-ayu-light.png +0 -0
  10. package/dist/docs/assets/theme-ayu.png +0 -0
  11. package/dist/docs/assets/theme-custom.png +0 -0
  12. package/dist/docs/assets/theme-default-light.png +0 -0
  13. package/dist/docs/assets/theme-default.png +0 -0
  14. package/dist/docs/assets/theme-dracula.png +0 -0
  15. package/dist/docs/assets/theme-github-light.png +0 -0
  16. package/dist/docs/assets/theme-github.png +0 -0
  17. package/dist/docs/assets/theme-google-light.png +0 -0
  18. package/dist/docs/assets/theme-xcode-light.png +0 -0
  19. package/dist/docs/changelogs/index.md +592 -0
  20. package/dist/docs/changelogs/latest.md +225 -0
  21. package/dist/docs/changelogs/preview.md +129 -0
  22. package/dist/docs/changelogs/releases.md +896 -0
  23. package/dist/docs/cli/authentication.md +3 -0
  24. package/dist/docs/cli/checkpointing.md +94 -0
  25. package/dist/docs/cli/commands.md +354 -0
  26. package/dist/docs/cli/configuration.md +780 -0
  27. package/dist/docs/cli/custom-commands.md +315 -0
  28. package/dist/docs/cli/enterprise.md +565 -0
  29. package/dist/docs/cli/gemini-ignore.md +71 -0
  30. package/dist/docs/cli/gemini-md.md +108 -0
  31. package/dist/docs/cli/generation-settings.md +210 -0
  32. package/dist/docs/cli/headless.md +388 -0
  33. package/dist/docs/cli/index.md +63 -0
  34. package/dist/docs/cli/keyboard-shortcuts.md +143 -0
  35. package/dist/docs/cli/model-routing.md +37 -0
  36. package/dist/docs/cli/model.md +62 -0
  37. package/dist/docs/cli/sandbox.md +171 -0
  38. package/dist/docs/cli/session-management.md +158 -0
  39. package/dist/docs/cli/settings.md +112 -0
  40. package/dist/docs/cli/system-prompt.md +93 -0
  41. package/dist/docs/cli/telemetry.md +791 -0
  42. package/dist/docs/cli/themes.md +237 -0
  43. package/dist/docs/cli/token-caching.md +20 -0
  44. package/dist/docs/cli/trusted-folders.md +95 -0
  45. package/dist/docs/cli/tutorials.md +83 -0
  46. package/dist/docs/cli/uninstall.md +47 -0
  47. package/dist/docs/core/index.md +101 -0
  48. package/dist/docs/core/memport.md +244 -0
  49. package/dist/docs/core/policy-engine.md +267 -0
  50. package/dist/docs/core/tools-api.md +131 -0
  51. package/dist/docs/examples/proxy-script.md +83 -0
  52. package/dist/docs/extensions/extension-releasing.md +183 -0
  53. package/dist/docs/extensions/getting-started-extensions.md +245 -0
  54. package/dist/docs/extensions/index.md +293 -0
  55. package/dist/docs/faq.md +154 -0
  56. package/dist/docs/get-started/authentication.md +321 -0
  57. package/dist/docs/get-started/configuration-v1.md +888 -0
  58. package/dist/docs/get-started/configuration.md +1444 -0
  59. package/dist/docs/get-started/deployment.md +143 -0
  60. package/dist/docs/get-started/examples.md +219 -0
  61. package/dist/docs/get-started/gemini-3.md +116 -0
  62. package/dist/docs/get-started/index.md +71 -0
  63. package/dist/docs/get-started/installation.md +141 -0
  64. package/dist/docs/hooks/best-practices.md +806 -0
  65. package/dist/docs/hooks/index.md +665 -0
  66. package/dist/docs/hooks/reference.md +168 -0
  67. package/dist/docs/hooks/writing-hooks.md +1026 -0
  68. package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
  69. package/dist/docs/ide-integration/index.md +202 -0
  70. package/dist/docs/index.md +147 -0
  71. package/dist/docs/integration-tests.md +211 -0
  72. package/dist/docs/issue-and-pr-automation.md +134 -0
  73. package/dist/docs/local-development.md +128 -0
  74. package/dist/docs/mermaid/context.mmd +103 -0
  75. package/dist/docs/mermaid/render-path.mmd +64 -0
  76. package/dist/docs/npm.md +62 -0
  77. package/dist/docs/quota-and-pricing.md +158 -0
  78. package/dist/docs/release-confidence.md +164 -0
  79. package/dist/docs/releases.md +540 -0
  80. package/dist/docs/sidebar.json +297 -0
  81. package/dist/docs/tools/file-system.md +217 -0
  82. package/dist/docs/tools/index.md +95 -0
  83. package/dist/docs/tools/mcp-server.md +1044 -0
  84. package/dist/docs/tools/memory.md +54 -0
  85. package/dist/docs/tools/shell.md +260 -0
  86. package/dist/docs/tools/todos.md +57 -0
  87. package/dist/docs/tools/web-fetch.md +59 -0
  88. package/dist/docs/tools/web-search.md +42 -0
  89. package/dist/docs/tos-privacy.md +96 -0
  90. package/dist/docs/troubleshooting.md +158 -0
  91. package/dist/google-gemini-cli-core-0.21.0-nightly.20251219.70696e364.tgz +0 -0
  92. package/dist/src/agents/delegate-to-agent-tool.test.js +1 -0
  93. package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -1
  94. package/dist/src/agents/introspection-agent.d.ts +23 -0
  95. package/dist/src/agents/introspection-agent.js +72 -0
  96. package/dist/src/agents/introspection-agent.js.map +1 -0
  97. package/dist/src/agents/introspection-agent.test.d.ts +6 -0
  98. package/dist/src/agents/introspection-agent.test.js +47 -0
  99. package/dist/src/agents/introspection-agent.test.js.map +1 -0
  100. package/dist/src/agents/local-executor.js +14 -12
  101. package/dist/src/agents/local-executor.js.map +1 -1
  102. package/dist/src/agents/local-executor.test.js +3 -0
  103. package/dist/src/agents/local-executor.test.js.map +1 -1
  104. package/dist/src/agents/registry.js +6 -0
  105. package/dist/src/agents/registry.js.map +1 -1
  106. package/dist/src/agents/registry.test.js +16 -0
  107. package/dist/src/agents/registry.test.js.map +1 -1
  108. package/dist/src/config/config.d.ts +6 -0
  109. package/dist/src/config/config.js +22 -0
  110. package/dist/src/config/config.js.map +1 -1
  111. package/dist/src/config/config.test.js +59 -1
  112. package/dist/src/config/config.test.js.map +1 -1
  113. package/dist/src/core/client.js +8 -4
  114. package/dist/src/core/client.js.map +1 -1
  115. package/dist/src/core/client.test.js +20 -0
  116. package/dist/src/core/client.test.js.map +1 -1
  117. package/dist/src/core/clientHookTriggers.js +2 -2
  118. package/dist/src/core/clientHookTriggers.js.map +1 -1
  119. package/dist/src/core/coreToolHookTriggers.js +3 -3
  120. package/dist/src/core/coreToolHookTriggers.js.map +1 -1
  121. package/dist/src/core/geminiChatHookTriggers.js +3 -3
  122. package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
  123. package/dist/src/core/sessionHookTriggers.js +3 -3
  124. package/dist/src/core/sessionHookTriggers.js.map +1 -1
  125. package/dist/src/generated/git-commit.d.ts +2 -2
  126. package/dist/src/generated/git-commit.js +2 -2
  127. package/dist/src/hooks/hookEventHandler.js +10 -4
  128. package/dist/src/hooks/hookEventHandler.js.map +1 -1
  129. package/dist/src/hooks/hookEventHandler.test.js +40 -0
  130. package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
  131. package/dist/src/hooks/hookRunner.js +12 -8
  132. package/dist/src/hooks/hookRunner.js.map +1 -1
  133. package/dist/src/hooks/hookRunner.test.js +58 -33
  134. package/dist/src/hooks/hookRunner.test.js.map +1 -1
  135. package/dist/src/mcp/oauth-provider.js +6 -2
  136. package/dist/src/mcp/oauth-provider.js.map +1 -1
  137. package/dist/src/mcp/oauth-provider.test.js +4 -1
  138. package/dist/src/mcp/oauth-provider.test.js.map +1 -1
  139. package/dist/src/mcp/oauth-utils.d.ts +8 -1
  140. package/dist/src/mcp/oauth-utils.js +30 -1
  141. package/dist/src/mcp/oauth-utils.js.map +1 -1
  142. package/dist/src/mcp/oauth-utils.test.js +42 -0
  143. package/dist/src/mcp/oauth-utils.test.js.map +1 -1
  144. package/dist/src/services/contextManager.d.ts +5 -11
  145. package/dist/src/services/contextManager.js +20 -17
  146. package/dist/src/services/contextManager.js.map +1 -1
  147. package/dist/src/services/contextManager.test.js +40 -41
  148. package/dist/src/services/contextManager.test.js.map +1 -1
  149. package/dist/src/tools/get-internal-docs.d.ts +27 -0
  150. package/dist/src/tools/get-internal-docs.js +129 -0
  151. package/dist/src/tools/get-internal-docs.js.map +1 -0
  152. package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
  153. package/dist/src/tools/get-internal-docs.test.js +56 -0
  154. package/dist/src/tools/get-internal-docs.test.js.map +1 -0
  155. package/dist/src/tools/tool-names.d.ts +1 -0
  156. package/dist/src/tools/tool-names.js +1 -0
  157. package/dist/src/tools/tool-names.js.map +1 -1
  158. package/dist/src/utils/environmentContext.js +3 -0
  159. package/dist/src/utils/environmentContext.js.map +1 -1
  160. package/dist/src/utils/environmentContext.test.js +2 -0
  161. package/dist/src/utils/environmentContext.test.js.map +1 -1
  162. package/dist/src/utils/events.d.ts +3 -2
  163. package/dist/src/utils/events.js.map +1 -1
  164. package/dist/src/utils/memoryDiscovery.js +1 -1
  165. package/dist/src/utils/memoryDiscovery.js.map +1 -1
  166. package/dist/src/utils/memoryDiscovery.test.js +3 -1
  167. package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
  168. package/dist/src/utils/shell-utils.js +25 -4
  169. package/dist/src/utils/shell-utils.js.map +1 -1
  170. package/dist/tsconfig.tsbuildinfo +1 -1
  171. package/package.json +1 -1
  172. package/dist/google-gemini-cli-core-0.21.0-nightly.20251218.739c02bd6.tgz +0 -0
@@ -0,0 +1,565 @@
1
+ # Gemini CLI for the enterprise
2
+
3
+ This document outlines configuration patterns and best practices for deploying
4
+ and managing Gemini CLI in an enterprise environment. By leveraging system-level
5
+ settings, administrators can enforce security policies, manage tool access, and
6
+ ensure a consistent experience for all users.
7
+
8
+ > **A note on security:** The patterns described in this document are intended
9
+ > to help administrators create a more controlled and secure environment for
10
+ > using Gemini CLI. However, they should not be considered a foolproof security
11
+ > boundary. A determined user with sufficient privileges on their local machine
12
+ > may still be able to circumvent these configurations. These measures are
13
+ > designed to prevent accidental misuse and enforce corporate policy in a
14
+ > managed environment, not to defend against a malicious actor with local
15
+ > administrative rights.
16
+
17
+ ## Centralized configuration: The system settings file
18
+
19
+ The most powerful tools for enterprise administration are the system-wide
20
+ settings files. These files allow you to define a baseline configuration
21
+ (`system-defaults.json`) and a set of overrides (`settings.json`) that apply to
22
+ all users on a machine. For a complete overview of configuration options, see
23
+ the [Configuration documentation](../get-started/configuration.md).
24
+
25
+ Settings are merged from four files. The precedence order for single-value
26
+ settings (like `theme`) is:
27
+
28
+ 1. System Defaults (`system-defaults.json`)
29
+ 2. User Settings (`~/.gemini/settings.json`)
30
+ 3. Workspace Settings (`<project>/.gemini/settings.json`)
31
+ 4. System Overrides (`settings.json`)
32
+
33
+ This means the System Overrides file has the final say. For settings that are
34
+ arrays (`includeDirectories`) or objects (`mcpServers`), the values are merged.
35
+
36
+ **Example of merging and precedence:**
37
+
38
+ Here is how settings from different levels are combined.
39
+
40
+ - **System defaults `system-defaults.json`:**
41
+
42
+ ```json
43
+ {
44
+ "ui": {
45
+ "theme": "default-corporate-theme"
46
+ },
47
+ "context": {
48
+ "includeDirectories": ["/etc/gemini-cli/common-context"]
49
+ }
50
+ }
51
+ ```
52
+
53
+ - **User `settings.json` (`~/.gemini/settings.json`):**
54
+
55
+ ```json
56
+ {
57
+ "ui": {
58
+ "theme": "user-preferred-dark-theme"
59
+ },
60
+ "mcpServers": {
61
+ "corp-server": {
62
+ "command": "/usr/local/bin/corp-server-dev"
63
+ },
64
+ "user-tool": {
65
+ "command": "npm start --prefix ~/tools/my-tool"
66
+ }
67
+ },
68
+ "context": {
69
+ "includeDirectories": ["~/gemini-context"]
70
+ }
71
+ }
72
+ ```
73
+
74
+ - **Workspace `settings.json` (`<project>/.gemini/settings.json`):**
75
+
76
+ ```json
77
+ {
78
+ "ui": {
79
+ "theme": "project-specific-light-theme"
80
+ },
81
+ "mcpServers": {
82
+ "project-tool": {
83
+ "command": "npm start"
84
+ }
85
+ },
86
+ "context": {
87
+ "includeDirectories": ["./project-context"]
88
+ }
89
+ }
90
+ ```
91
+
92
+ - **System overrides `settings.json`:**
93
+ ```json
94
+ {
95
+ "ui": {
96
+ "theme": "system-enforced-theme"
97
+ },
98
+ "mcpServers": {
99
+ "corp-server": {
100
+ "command": "/usr/local/bin/corp-server-prod"
101
+ }
102
+ },
103
+ "context": {
104
+ "includeDirectories": ["/etc/gemini-cli/global-context"]
105
+ }
106
+ }
107
+ ```
108
+
109
+ This results in the following merged configuration:
110
+
111
+ - **Final merged configuration:**
112
+ ```json
113
+ {
114
+ "ui": {
115
+ "theme": "system-enforced-theme"
116
+ },
117
+ "mcpServers": {
118
+ "corp-server": {
119
+ "command": "/usr/local/bin/corp-server-prod"
120
+ },
121
+ "user-tool": {
122
+ "command": "npm start --prefix ~/tools/my-tool"
123
+ },
124
+ "project-tool": {
125
+ "command": "npm start"
126
+ }
127
+ },
128
+ "context": {
129
+ "includeDirectories": [
130
+ "/etc/gemini-cli/common-context",
131
+ "~/gemini-context",
132
+ "./project-context",
133
+ "/etc/gemini-cli/global-context"
134
+ ]
135
+ }
136
+ }
137
+ ```
138
+
139
+ **Why:**
140
+
141
+ - **`theme`**: The value from the system overrides (`system-enforced-theme`) is
142
+ used, as it has the highest precedence.
143
+ - **`mcpServers`**: The objects are merged. The `corp-server` definition from
144
+ the system overrides takes precedence over the user's definition. The unique
145
+ `user-tool` and `project-tool` are included.
146
+ - **`includeDirectories`**: The arrays are concatenated in the order of System
147
+ Defaults, User, Workspace, and then System Overrides.
148
+
149
+ - **Location**:
150
+ - **Linux**: `/etc/gemini-cli/settings.json`
151
+ - **Windows**: `C:\ProgramData\gemini-cli\settings.json`
152
+ - **macOS**: `/Library/Application Support/GeminiCli/settings.json`
153
+ - The path can be overridden using the `GEMINI_CLI_SYSTEM_SETTINGS_PATH`
154
+ environment variable.
155
+ - **Control**: This file should be managed by system administrators and
156
+ protected with appropriate file permissions to prevent unauthorized
157
+ modification by users.
158
+
159
+ By using the system settings file, you can enforce the security and
160
+ configuration patterns described below.
161
+
162
+ ### Enforcing system settings with a wrapper script
163
+
164
+ While the `GEMINI_CLI_SYSTEM_SETTINGS_PATH` environment variable provides
165
+ flexibility, a user could potentially override it to point to a different
166
+ settings file, bypassing the centrally managed configuration. To mitigate this,
167
+ enterprises can deploy a wrapper script or alias that ensures the environment
168
+ variable is always set to the corporate-controlled path.
169
+
170
+ This approach ensures that no matter how the user calls the `gemini` command,
171
+ the enterprise settings are always loaded with the highest precedence.
172
+
173
+ **Example wrapper script:**
174
+
175
+ Administrators can create a script named `gemini` and place it in a directory
176
+ that appears earlier in the user's `PATH` than the actual Gemini CLI binary
177
+ (e.g., `/usr/local/bin/gemini`).
178
+
179
+ ```bash
180
+ #!/bin/bash
181
+
182
+ # Enforce the path to the corporate system settings file.
183
+ # This ensures that the company's configuration is always applied.
184
+ export GEMINI_CLI_SYSTEM_SETTINGS_PATH="/etc/gemini-cli/settings.json"
185
+
186
+ # Find the original gemini executable.
187
+ # This is a simple example; a more robust solution might be needed
188
+ # depending on the installation method.
189
+ REAL_GEMINI_PATH=$(type -aP gemini | grep -v "^$(type -P gemini)$" | head -n 1)
190
+
191
+ if [ -z "$REAL_GEMINI_PATH" ]; then
192
+ echo "Error: The original 'gemini' executable was not found." >&2
193
+ exit 1
194
+ fi
195
+
196
+ # Pass all arguments to the real Gemini CLI executable.
197
+ exec "$REAL_GEMINI_PATH" "$@"
198
+ ```
199
+
200
+ By deploying this script, the `GEMINI_CLI_SYSTEM_SETTINGS_PATH` is set within
201
+ the script's environment, and the `exec` command replaces the script process
202
+ with the actual Gemini CLI process, which inherits the environment variable.
203
+ This makes it significantly more difficult for a user to bypass the enforced
204
+ settings.
205
+
206
+ ## Restricting tool access
207
+
208
+ You can significantly enhance security by controlling which tools the Gemini
209
+ model can use. This is achieved through the `tools.core` and `tools.exclude`
210
+ settings. For a list of available tools, see the
211
+ [Tools documentation](../tools/index.md).
212
+
213
+ ### Allowlisting with `coreTools`
214
+
215
+ The most secure approach is to explicitly add the tools and commands that users
216
+ are permitted to execute to an allowlist. This prevents the use of any tool not
217
+ on the approved list.
218
+
219
+ **Example:** Allow only safe, read-only file operations and listing files.
220
+
221
+ ```json
222
+ {
223
+ "tools": {
224
+ "core": ["ReadFileTool", "GlobTool", "ShellTool(ls)"]
225
+ }
226
+ }
227
+ ```
228
+
229
+ ### Blocklisting with `excludeTools`
230
+
231
+ Alternatively, you can add specific tools that are considered dangerous in your
232
+ environment to a blocklist.
233
+
234
+ **Example:** Prevent the use of the shell tool for removing files.
235
+
236
+ ```json
237
+ {
238
+ "tools": {
239
+ "exclude": ["ShellTool(rm -rf)"]
240
+ }
241
+ }
242
+ ```
243
+
244
+ **Security note:** Blocklisting with `excludeTools` is less secure than
245
+ allowlisting with `coreTools`, as it relies on blocking known-bad commands, and
246
+ clever users may find ways to bypass simple string-based blocks. **Allowlisting
247
+ is the recommended approach.**
248
+
249
+ ### Disabling YOLO mode
250
+
251
+ To ensure that users cannot bypass the confirmation prompt for tool execution,
252
+ you can disable YOLO mode at the policy level. This adds a critical layer of
253
+ safety, as it prevents the model from executing tools without explicit user
254
+ approval.
255
+
256
+ **Example:** Force all tool executions to require user confirmation.
257
+
258
+ ```json
259
+ {
260
+ "security": {
261
+ "disableYoloMode": true
262
+ }
263
+ }
264
+ ```
265
+
266
+ This setting is highly recommended in an enterprise environment to prevent
267
+ unintended tool execution.
268
+
269
+ ## Managing custom tools (MCP servers)
270
+
271
+ If your organization uses custom tools via
272
+ [Model-Context Protocol (MCP) servers](../core/tools-api.md), it is crucial to
273
+ understand how server configurations are managed to apply security policies
274
+ effectively.
275
+
276
+ ### How MCP server configurations are merged
277
+
278
+ Gemini CLI loads `settings.json` files from three levels: System, Workspace, and
279
+ User. When it comes to the `mcpServers` object, these configurations are
280
+ **merged**:
281
+
282
+ 1. **Merging:** The lists of servers from all three levels are combined into a
283
+ single list.
284
+ 2. **Precedence:** If a server with the **same name** is defined at multiple
285
+ levels (e.g., a server named `corp-api` exists in both system and user
286
+ settings), the definition from the highest-precedence level is used. The
287
+ order of precedence is: **System > Workspace > User**.
288
+
289
+ This means a user **cannot** override the definition of a server that is already
290
+ defined in the system-level settings. However, they **can** add new servers with
291
+ unique names.
292
+
293
+ ### Enforcing a catalog of tools
294
+
295
+ The security of your MCP tool ecosystem depends on a combination of defining the
296
+ canonical servers and adding their names to an allowlist.
297
+
298
+ ### Restricting tools within an MCP server
299
+
300
+ For even greater security, especially when dealing with third-party MCP servers,
301
+ you can restrict which specific tools from a server are exposed to the model.
302
+ This is done using the `includeTools` and `excludeTools` properties within a
303
+ server's definition. This allows you to use a subset of tools from a server
304
+ without allowing potentially dangerous ones.
305
+
306
+ Following the principle of least privilege, it is highly recommended to use
307
+ `includeTools` to create an allowlist of only the necessary tools.
308
+
309
+ **Example:** Only allow the `code-search` and `get-ticket-details` tools from a
310
+ third-party MCP server, even if the server offers other tools like
311
+ `delete-ticket`.
312
+
313
+ ```json
314
+ {
315
+ "mcp": {
316
+ "allowed": ["third-party-analyzer"]
317
+ },
318
+ "mcpServers": {
319
+ "third-party-analyzer": {
320
+ "command": "/usr/local/bin/start-3p-analyzer.sh",
321
+ "includeTools": ["code-search", "get-ticket-details"]
322
+ }
323
+ }
324
+ }
325
+ ```
326
+
327
+ #### More secure pattern: Define and add to allowlist in system settings
328
+
329
+ To create a secure, centrally-managed catalog of tools, the system administrator
330
+ **must** do both of the following in the system-level `settings.json` file:
331
+
332
+ 1. **Define the full configuration** for every approved server in the
333
+ `mcpServers` object. This ensures that even if a user defines a server with
334
+ the same name, the secure system-level definition will take precedence.
335
+ 2. **Add the names** of those servers to an allowlist using the `mcp.allowed`
336
+ setting. This is a critical security step that prevents users from running
337
+ any servers that are not on this list. If this setting is omitted, the CLI
338
+ will merge and allow any server defined by the user.
339
+
340
+ **Example system `settings.json`:**
341
+
342
+ 1. Add the _names_ of all approved servers to an allowlist. This will prevent
343
+ users from adding their own servers.
344
+
345
+ 2. Provide the canonical _definition_ for each server on the allowlist.
346
+
347
+ ```json
348
+ {
349
+ "mcp": {
350
+ "allowed": ["corp-data-api", "source-code-analyzer"]
351
+ },
352
+ "mcpServers": {
353
+ "corp-data-api": {
354
+ "command": "/usr/local/bin/start-corp-api.sh",
355
+ "timeout": 5000
356
+ },
357
+ "source-code-analyzer": {
358
+ "command": "/usr/local/bin/start-analyzer.sh"
359
+ }
360
+ }
361
+ }
362
+ ```
363
+
364
+ This pattern is more secure because it uses both definition and an allowlist.
365
+ Any server a user defines will either be overridden by the system definition (if
366
+ it has the same name) or blocked because its name is not in the `mcp.allowed`
367
+ list.
368
+
369
+ ### Less secure pattern: Omitting the allowlist
370
+
371
+ If the administrator defines the `mcpServers` object but fails to also specify
372
+ the `mcp.allowed` allowlist, users may add their own servers.
373
+
374
+ **Example system `settings.json`:**
375
+
376
+ This configuration defines servers but does not enforce the allowlist. The
377
+ administrator has NOT included the "mcp.allowed" setting.
378
+
379
+ ```json
380
+ {
381
+ "mcpServers": {
382
+ "corp-data-api": {
383
+ "command": "/usr/local/bin/start-corp-api.sh"
384
+ }
385
+ }
386
+ }
387
+ ```
388
+
389
+ In this scenario, a user can add their own server in their local
390
+ `settings.json`. Because there is no `mcp.allowed` list to filter the merged
391
+ results, the user's server will be added to the list of available tools and
392
+ allowed to run.
393
+
394
+ ## Enforcing sandboxing for security
395
+
396
+ To mitigate the risk of potentially harmful operations, you can enforce the use
397
+ of sandboxing for all tool execution. The sandbox isolates tool execution in a
398
+ containerized environment.
399
+
400
+ **Example:** Force all tool execution to happen within a Docker sandbox.
401
+
402
+ ```json
403
+ {
404
+ "tools": {
405
+ "sandbox": "docker"
406
+ }
407
+ }
408
+ ```
409
+
410
+ You can also specify a custom, hardened Docker image for the sandbox by building
411
+ a custom `sandbox.Dockerfile` as described in the
412
+ [Sandboxing documentation](./sandbox.md).
413
+
414
+ ## Controlling network access via proxy
415
+
416
+ In corporate environments with strict network policies, you can configure Gemini
417
+ CLI to route all outbound traffic through a corporate proxy. This can be set via
418
+ an environment variable, but it can also be enforced for custom tools via the
419
+ `mcpServers` configuration.
420
+
421
+ **Example (for an MCP server):**
422
+
423
+ ```json
424
+ {
425
+ "mcpServers": {
426
+ "proxied-server": {
427
+ "command": "node",
428
+ "args": ["mcp_server.js"],
429
+ "env": {
430
+ "HTTP_PROXY": "http://proxy.example.com:8080",
431
+ "HTTPS_PROXY": "http://proxy.example.com:8080"
432
+ }
433
+ }
434
+ }
435
+ }
436
+ ```
437
+
438
+ ## Telemetry and auditing
439
+
440
+ For auditing and monitoring purposes, you can configure Gemini CLI to send
441
+ telemetry data to a central location. This allows you to track tool usage and
442
+ other events. For more information, see the
443
+ [telemetry documentation](./telemetry.md).
444
+
445
+ **Example:** Enable telemetry and send it to a local OTLP collector. If
446
+ `otlpEndpoint` is not specified, it defaults to `http://localhost:4317`.
447
+
448
+ ```json
449
+ {
450
+ "telemetry": {
451
+ "enabled": true,
452
+ "target": "gcp",
453
+ "logPrompts": false
454
+ }
455
+ }
456
+ ```
457
+
458
+ **Note:** Ensure that `logPrompts` is set to `false` in an enterprise setting to
459
+ avoid collecting potentially sensitive information from user prompts.
460
+
461
+ ## Authentication
462
+
463
+ You can enforce a specific authentication method for all users by setting the
464
+ `enforcedAuthType` in the system-level `settings.json` file. This prevents users
465
+ from choosing a different authentication method. See the
466
+ [Authentication docs](./authentication.md) for more details.
467
+
468
+ **Example:** Enforce the use of Google login for all users.
469
+
470
+ ```json
471
+ {
472
+ "enforcedAuthType": "oauth-personal"
473
+ }
474
+ ```
475
+
476
+ If a user has a different authentication method configured, they will be
477
+ prompted to switch to the enforced method. In non-interactive mode, the CLI will
478
+ exit with an error if the configured authentication method does not match the
479
+ enforced one.
480
+
481
+ ### Restricting logins to corporate domains
482
+
483
+ For enterprises using Google Workspace, you can enforce that users only
484
+ authenticate with their corporate Google accounts. This is a network-level
485
+ control that is configured on a proxy server, not within Gemini CLI itself. It
486
+ works by intercepting authentication requests to Google and adding a special
487
+ HTTP header.
488
+
489
+ This policy prevents users from logging in with personal Gmail accounts or other
490
+ non-corporate Google accounts.
491
+
492
+ For detailed instructions, see the Google Workspace Admin Help article on
493
+ [blocking access to consumer accounts](https://support.google.com/a/answer/1668854?hl=en#zippy=%2Cstep-choose-a-web-proxy-server%2Cstep-configure-the-network-to-block-certain-accounts).
494
+
495
+ The general steps are as follows:
496
+
497
+ 1. **Intercept Requests**: Configure your web proxy to intercept all requests
498
+ to `google.com`.
499
+ 2. **Add HTTP Header**: For each intercepted request, add the
500
+ `X-GoogApps-Allowed-Domains` HTTP header.
501
+ 3. **Specify Domains**: The value of the header should be a comma-separated
502
+ list of your approved Google Workspace domain names.
503
+
504
+ **Example header:**
505
+
506
+ ```
507
+ X-GoogApps-Allowed-Domains: my-corporate-domain.com, secondary-domain.com
508
+ ```
509
+
510
+ When this header is present, Google's authentication service will only allow
511
+ logins from accounts belonging to the specified domains.
512
+
513
+ ## Putting it all together: example system `settings.json`
514
+
515
+ Here is an example of a system `settings.json` file that combines several of the
516
+ patterns discussed above to create a secure, controlled environment for Gemini
517
+ CLI.
518
+
519
+ ```json
520
+ {
521
+ "tools": {
522
+ "sandbox": "docker",
523
+ "core": [
524
+ "ReadFileTool",
525
+ "GlobTool",
526
+ "ShellTool(ls)",
527
+ "ShellTool(cat)",
528
+ "ShellTool(grep)"
529
+ ]
530
+ },
531
+ "mcp": {
532
+ "allowed": ["corp-tools"]
533
+ },
534
+ "mcpServers": {
535
+ "corp-tools": {
536
+ "command": "/opt/gemini-tools/start.sh",
537
+ "timeout": 5000
538
+ }
539
+ },
540
+ "telemetry": {
541
+ "enabled": true,
542
+ "target": "gcp",
543
+ "otlpEndpoint": "https://telemetry-prod.example.com:4317",
544
+ "logPrompts": false
545
+ },
546
+ "advanced": {
547
+ "bugCommand": {
548
+ "urlTemplate": "https://servicedesk.example.com/new-ticket?title={title}&details={info}"
549
+ }
550
+ },
551
+ "privacy": {
552
+ "usageStatisticsEnabled": false
553
+ }
554
+ }
555
+ ```
556
+
557
+ This configuration:
558
+
559
+ - Forces all tool execution into a Docker sandbox.
560
+ - Strictly uses an allowlist for a small set of safe shell commands and file
561
+ tools.
562
+ - Defines and allows a single corporate MCP server for custom tools.
563
+ - Enables telemetry for auditing, without logging prompt content.
564
+ - Redirects the `/bug` command to an internal ticketing system.
565
+ - Disables general usage statistics collection.
@@ -0,0 +1,71 @@
1
+ # Ignoring files
2
+
3
+ This document provides an overview of the Gemini Ignore (`.geminiignore`)
4
+ feature of the Gemini CLI.
5
+
6
+ The Gemini CLI includes the ability to automatically ignore files, similar to
7
+ `.gitignore` (used by Git) and `.aiexclude` (used by Gemini Code Assist). Adding
8
+ paths to your `.geminiignore` file will exclude them from tools that support
9
+ this feature, although they will still be visible to other services (such as
10
+ Git).
11
+
12
+ ## How it works
13
+
14
+ When you add a path to your `.geminiignore` file, tools that respect this file
15
+ will exclude matching files and directories from their operations. For example,
16
+ when you use the `@` command to share files, any paths in your `.geminiignore`
17
+ file will be automatically excluded.
18
+
19
+ For the most part, `.geminiignore` follows the conventions of `.gitignore`
20
+ files:
21
+
22
+ - Blank lines and lines starting with `#` are ignored.
23
+ - Standard glob patterns are supported (such as `*`, `?`, and `[]`).
24
+ - Putting a `/` at the end will only match directories.
25
+ - Putting a `/` at the beginning anchors the path relative to the
26
+ `.geminiignore` file.
27
+ - `!` negates a pattern.
28
+
29
+ You can update your `.geminiignore` file at any time. To apply the changes, you
30
+ must restart your Gemini CLI session.
31
+
32
+ ## How to use `.geminiignore`
33
+
34
+ To enable `.geminiignore`:
35
+
36
+ 1. Create a file named `.geminiignore` in the root of your project directory.
37
+
38
+ To add a file or directory to `.geminiignore`:
39
+
40
+ 1. Open your `.geminiignore` file.
41
+ 2. Add the path or file you want to ignore, for example: `/archive/` or
42
+ `apikeys.txt`.
43
+
44
+ ### `.geminiignore` examples
45
+
46
+ You can use `.geminiignore` to ignore directories and files:
47
+
48
+ ```
49
+ # Exclude your /packages/ directory and all subdirectories
50
+ /packages/
51
+
52
+ # Exclude your apikeys.txt file
53
+ apikeys.txt
54
+ ```
55
+
56
+ You can use wildcards in your `.geminiignore` file with `*`:
57
+
58
+ ```
59
+ # Exclude all .md files
60
+ *.md
61
+ ```
62
+
63
+ Finally, you can exclude files and directories from exclusion with `!`:
64
+
65
+ ```
66
+ # Exclude all .md files except README.md
67
+ *.md
68
+ !README.md
69
+ ```
70
+
71
+ To remove paths from your `.geminiignore` file, delete the relevant lines.