Skip to content

Commit 958e66e

Browse files
authored
Merge branch 'google-gemini:main' into main
2 parents adc9074 + 45b7649 commit 958e66e

File tree

87 files changed

+4170
-1253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+4170
-1253
lines changed

docs/cli/commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Slash commands provide meta-level control over the CLI itself.
2828
- **`/compress`**
2929
- **Description:** Replace the entire chat context with a summary. This saves on tokens used for future tasks while retaining a high level summary of what has happened.
3030

31+
- **`/copy`**
32+
- **Description:** Copies the last output produced by Gemini CLI to your clipboard, for easy sharing or reuse.
33+
3134
- **`/editor`**
3235
- **Description:** Open a dialog for selecting supported editors.
3336

docs/cli/configuration.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,23 @@ In addition to a project settings file, a project's `.gemini` directory can cont
132132
- `cwd` (string, optional): The working directory in which to start the server.
133133
- `timeout` (number, optional): Timeout in milliseconds for requests to this MCP server.
134134
- `trust` (boolean, optional): Trust this server and bypass all tool call confirmations.
135+
- `includeTools` (array of strings, optional): List of tool names to include from this MCP server. When specified, only the tools listed here will be available from this server (whitelist behavior). If not specified, all tools from the server are enabled by default.
136+
- `excludeTools` (array of strings, optional): List of tool names to exclude from this MCP server. Tools listed here will not be available to the model, even if they are exposed by the server. **Note:** `excludeTools` takes precedence over `includeTools` - if a tool is in both lists, it will be excluded.
135137
- **Example:**
136138
```json
137139
"mcpServers": {
138140
"myPythonServer": {
139141
"command": "python",
140142
"args": ["mcp_server.py", "--port", "8080"],
141143
"cwd": "./mcp_tools/python",
142-
"timeout": 5000
144+
"timeout": 5000,
145+
"includeTools": ["safe_tool", "file_reader"],
143146
},
144147
"myNodeServer": {
145148
"command": "node",
146149
"args": ["mcp_server.js"],
147-
"cwd": "./mcp_tools/node"
150+
"cwd": "./mcp_tools/node",
151+
"excludeTools": ["dangerous_tool", "file_deleter"]
148152
},
149153
"myDockerServer": {
150154
"command": "docker",

docs/integration-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ This structure makes it easy to locate the artifacts for a specific test run, fi
132132

133133
## Continuous integration
134134

135-
To ensure the integration tests are always run, a GitHub Actions workflow is defined in `.github/workflows/e2e.yml`. This workflow automatically runs the integration tests on every pull request and push to the `main` branch.
135+
To ensure the integration tests are always run, a GitHub Actions workflow is defined in `.github/workflows/e2e.yml`. This workflow automatically runs the integrations tests for pull requests against the `main` branch, or when a pull request is added to a merge queue.
136136

137137
The workflow runs the tests in different sandboxing environments to ensure Gemini CLI is tested across each:
138138

docs/tools/mcp-server.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ Each server configuration supports the following properties:
9292
- **`cwd`** (string): Working directory for Stdio transport
9393
- **`timeout`** (number): Request timeout in milliseconds (default: 600,000ms = 10 minutes)
9494
- **`trust`** (boolean): When `true`, bypasses all tool call confirmations for this server (default: `false`)
95+
- **`includeTools`** (string[]): List of tool names to include from this MCP server. When specified, only the tools listed here will be available from this server (whitelist behavior). If not specified, all tools from the server are enabled by default.
96+
- **`excludeTools`** (string[]): List of tool names to exclude from this MCP server. Tools listed here will not be available to the model, even if they are exposed by the server. **Note:** `excludeTools` takes precedence over `includeTools` - if a tool is in both lists, it will be excluded.
9597

9698
### Example Configurations
9799

@@ -185,6 +187,22 @@ Each server configuration supports the following properties:
185187
}
186188
```
187189

190+
#### MCP Server with Tool Filtering
191+
192+
```json
193+
{
194+
"mcpServers": {
195+
"filteredServer": {
196+
"command": "python",
197+
"args": ["-m", "my_mcp_server"],
198+
"includeTools": ["safe_tool", "file_reader", "data_processor"],
199+
// "excludeTools": ["dangerous_tool", "file_deleter"],
200+
"timeout": 30000
201+
}
202+
}
203+
}
204+
```
205+
188206
## Discovery Process Deep Dive
189207

190208
When the Gemini CLI starts, it performs MCP server discovery through the following detailed process:
@@ -207,7 +225,8 @@ Upon successful connection:
207225

208226
1. **Tool listing:** The client calls the MCP server's tool listing endpoint
209227
2. **Schema validation:** Each tool's function declaration is validated
210-
3. **Name sanitization:** Tool names are cleaned to meet Gemini API requirements:
228+
3. **Tool filtering:** Tools are filtered based on `includeTools` and `excludeTools` configuration
229+
4. **Name sanitization:** Tool names are cleaned to meet Gemini API requirements:
211230
- Invalid characters (non-alphanumeric, underscore, dot, hyphen) are replaced with underscores
212231
- Names longer than 63 characters are truncated with middle replacement (`___`)
213232

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/src/config/config.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ vi.mock('@google/gemini-cli-core', async () => {
4343
fileCount: extensionPaths?.length || 0,
4444
}),
4545
),
46+
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS: {
47+
respectGitIgnore: false,
48+
respectGeminiIgnore: true,
49+
},
50+
DEFAULT_FILE_FILTERING_OPTIONS: {
51+
respectGitIgnore: true,
52+
respectGeminiIgnore: true,
53+
},
4654
};
4755
});
4856

@@ -479,6 +487,10 @@ describe('Hierarchical Memory Loading (config.ts) - Placeholder Suite', () => {
479487
'/path/to/ext3/context1.md',
480488
'/path/to/ext3/context2.md',
481489
],
490+
{
491+
respectGitIgnore: false,
492+
respectGeminiIgnore: true,
493+
},
482494
);
483495
});
484496

packages/cli/src/config/config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import {
1515
ApprovalMode,
1616
DEFAULT_GEMINI_MODEL,
1717
DEFAULT_GEMINI_EMBEDDING_MODEL,
18+
DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,
1819
FileDiscoveryService,
1920
TelemetryTarget,
21+
FileFilteringOptions,
2022
MCPServerConfig,
2123
IDE_SERVER_NAME,
2224
} from '@google/gemini-cli-core';
@@ -219,19 +221,22 @@ export async function loadHierarchicalGeminiMemory(
219221
debugMode: boolean,
220222
fileService: FileDiscoveryService,
221223
extensionContextFilePaths: string[] = [],
224+
fileFilteringOptions?: FileFilteringOptions,
222225
): Promise<{ memoryContent: string; fileCount: number }> {
223226
if (debugMode) {
224227
logger.debug(
225228
`CLI: Delegating hierarchical memory load to server for CWD: ${currentWorkingDirectory}`,
226229
);
227230
}
231+
228232
// Directly call the server function.
229233
// The server function will use its own homedir() for the global path.
230234
return loadServerHierarchicalMemory(
231235
currentWorkingDirectory,
232236
debugMode,
233237
fileService,
234238
extensionContextFilePaths,
239+
fileFilteringOptions,
235240
);
236241
}
237242

@@ -277,12 +282,19 @@ export async function loadCliConfig(
277282
);
278283

279284
const fileService = new FileDiscoveryService(process.cwd());
285+
286+
const fileFiltering = {
287+
...DEFAULT_MEMORY_FILE_FILTERING_OPTIONS,
288+
...settings.fileFiltering,
289+
};
290+
280291
// Call the (now wrapper) loadHierarchicalGeminiMemory which calls the server's version
281292
const { memoryContent, fileCount } = await loadHierarchicalGeminiMemory(
282293
process.cwd(),
283294
debugMode,
284295
fileService,
285296
extensionContextFilePaths,
297+
fileFiltering,
286298
);
287299

288300
let mcpServers = mergeMcpServers(settings, activeExtensions);
@@ -405,6 +417,7 @@ export async function loadCliConfig(
405417
// Git-aware file filtering settings
406418
fileFiltering: {
407419
respectGitIgnore: settings.fileFiltering?.respectGitIgnore,
420+
respectGeminiIgnore: settings.fileFiltering?.respectGeminiIgnore,
408421
enableRecursiveFileSearch:
409422
settings.fileFiltering?.enableRecursiveFileSearch,
410423
},

0 commit comments

Comments
 (0)