Docs: Update MCP server configuration (#396)

This commit is contained in:
N. Taylor Mullen 2025-05-16 17:19:00 -07:00 committed by GitHub
parent 7f7f2cd47e
commit c09bad9393
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 10 deletions

View File

@ -51,8 +51,16 @@ When you create a `.gemini/settings.json` file for project-specific settings, or
- Custom command for executing tool calls (if applicable to your setup).
- Must take function name as first argument and function arguments as JSON on `stdin`
- Must return JSON result of funcation call on `stdout`.
- **`mcpServerCommand`** (string, advanced):
- Custom command for starting an MCP server with custom tools.
- **`mcpServers`** (object, advanced):
- Configures connections to one or more Model-Context Protocol (MCP) servers for discovering and using custom tools.
- This is an object where each key is a server name and the value is an object defining the server's parameters:
- `command` (string, required): The command to execute to start the MCP server.
- `args` (array of strings, optional): Arguments to pass to the command.
- `env` (object, optional): Environment variables to set for the server process.
- `cwd` (string, optional): The working directory in which to start the server.
- Example: `"mcpServers": { "myServer": { "command": "python", "args": ["mcp_server.py", "--port", "8080"], "cwd": "./mcp_tools" } }`
- **`mcpServerCommand`** (string, advanced, **deprecated**):
- Legacy setting for configuring a single MCP server. Please use `mcpServers` instead for better flexibility and support for multiple servers.
### Example `settings.json`:
@ -62,7 +70,15 @@ When you create a `.gemini/settings.json` file for project-specific settings, or
"sandbox": "docker",
"toolDiscoveryCommand": "bin/get_tools",
"toolCallCommand": "bin/call_tool",
"mcpServerCommand": "bin/mcp_server.py"
"mcpServers": {
"mainServer": {
"command": "bin/mcp_server.py"
},
"anotherServer": {
"command": "node",
"args": ["mcp_server.js", "--verbose"]
}
}
}
```

View File

@ -54,13 +54,22 @@ These are the main pieces of information the server `Config` object holds and us
- **Purpose:** If true, instructs relevant tools (like `read_many_files` when used implicitly by the model) to gather a broad context from the `targetDir`.
- **`toolDiscoveryCommand` (string | undefined):**
- **`toolCallCommand` (string | undefined):**
- **`mcpServerCommand` (string | undefined):**
- **Source:** `settings.json` or environment variables.
- **Purpose:** Advanced settings for customizing how tools are discovered or how the server interacts with other potential components in a more complex setup.
- `toolCallCommand` (string | undefined):
- `mcpServers` (object | undefined):
- **Source:** `settings.json` (`mcpServers` key).
- **Purpose:** Advanced setting for configuring connections to Model-Context Protocol (MCP) servers. This is an object where each key is a server name and the value is an object defining the server's parameters:
- `command` (string, required): The command to execute to start the MCP server.
- `args` (array of strings, optional): Arguments to pass to the command.
- `env` (object, optional): Environment variables to set for the server process.
- `cwd` (string, optional): The working directory in which to start the server.
- Allows discovery and use of tools from multiple MCP sources.
- `mcpServerCommand` (string | undefined, **deprecated**):
- **`userAgent` (string):**
- **Source:** `settings.json` (`mcpServerCommand` key).
- **Purpose:** Legacy setting for configuring a single MCP server. Please use `mcpServers` instead.
- `userAgent` (string):
- **Source:** Automatically generated by the CLI, often including CLI package name, version, and Node.js environment details.
- **Purpose:** Sent with API requests to help identify the client making requests to the Gemini API.

View File

@ -67,6 +67,7 @@ Each of these tools extends `BaseTool` and implements the required methods for i
While direct programmatic registration of new tools by users isn't explicitly detailed as a primary workflow in the provided files for typical end-users, the architecture supports extension through:
- **Command-based Discovery:** Advanced users or project administrators can define a `toolDiscoveryCommand` in `settings.json`. This command, when run by the Gemini CLI server, should output a JSON array of `FunctionDeclaration` objects. The server will then make these available as `DiscoveredTool` instances. The corresponding `toolCallCommand` would then be responsible for actually executing these custom tools.
- **MCP Server:** For more complex scenarios, an MCP server can be set up (configured via `mcpServerCommand`) to expose tools that the Gemini CLI server can then discover and use.
\
- **MCP Server(s):** For more complex scenarios, one or more MCP servers can be set up and configured via the `mcpServers` setting in `settings.json`. The Gemini CLI server can then discover and use tools exposed by these servers. As mentioned, if you have multiple MCP servers, the tool names will be prefixed with the server name from your configuration (e.g., `serverAlias__actualToolName`).
This tool system provides a flexible and powerful way to augment the Gemini model's capabilities, making the Gemini CLI a versatile assistant for a wide range of tasks.
This tool system provides a flexible and powerful way to augment the Gemini model\'s capabilities, making the Gemini CLI a versatile assistant for a wide range of tasks.