summaryrefslogtreecommitdiff
path: root/docs/tools/mcp-server.md
diff options
context:
space:
mode:
authorSeydulla Narkulyyev <[email protected]>2025-07-21 03:11:49 +0400
committerGitHub <[email protected]>2025-07-20 23:11:49 +0000
commitf4d077cc1f523ddfa278c8be09446b6da0a20839 (patch)
treed130f7213c01be6719708434e241f9b5d241dc20 /docs/tools/mcp-server.md
parent5f8fff4db3b88705a261a43f31efe93d2226c07c (diff)
docs: add documentation for mcp excludeTools and includeTools (#3409)
Co-authored-by: Jack Wotherspoon <[email protected]>
Diffstat (limited to 'docs/tools/mcp-server.md')
-rw-r--r--docs/tools/mcp-server.md21
1 files changed, 20 insertions, 1 deletions
diff --git a/docs/tools/mcp-server.md b/docs/tools/mcp-server.md
index f764d75a..96c837d4 100644
--- a/docs/tools/mcp-server.md
+++ b/docs/tools/mcp-server.md
@@ -92,6 +92,8 @@ Each server configuration supports the following properties:
- **`cwd`** (string): Working directory for Stdio transport
- **`timeout`** (number): Request timeout in milliseconds (default: 600,000ms = 10 minutes)
- **`trust`** (boolean): When `true`, bypasses all tool call confirmations for this server (default: `false`)
+- **`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.
+- **`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.
### Example Configurations
@@ -185,6 +187,22 @@ Each server configuration supports the following properties:
}
```
+#### MCP Server with Tool Filtering
+
+```json
+{
+ "mcpServers": {
+ "filteredServer": {
+ "command": "python",
+ "args": ["-m", "my_mcp_server"],
+ "includeTools": ["safe_tool", "file_reader", "data_processor"],
+ // "excludeTools": ["dangerous_tool", "file_deleter"],
+ "timeout": 30000
+ }
+ }
+}
+```
+
## Discovery Process Deep Dive
When the Gemini CLI starts, it performs MCP server discovery through the following detailed process:
@@ -207,7 +225,8 @@ Upon successful connection:
1. **Tool listing:** The client calls the MCP server's tool listing endpoint
2. **Schema validation:** Each tool's function declaration is validated
-3. **Name sanitization:** Tool names are cleaned to meet Gemini API requirements:
+3. **Tool filtering:** Tools are filtered based on `includeTools` and `excludeTools` configuration
+4. **Name sanitization:** Tool names are cleaned to meet Gemini API requirements:
- Invalid characters (non-alphanumeric, underscore, dot, hyphen) are replaced with underscores
- Names longer than 63 characters are truncated with middle replacement (`___`)