An MCP server is an application that exposes tools and resources to the Gemini CLI through the Model Context Protocol, allowing it to interact with external systems and data sources. MCP servers act as a bridge between the Gemini model and your local environment or other services like APIs.
An MCP server enables the Gemini CLI to discover and execute tools thereby extending Gemini CLI's capabilities to perform actions beyond its built-in features, such as interacting with databases, APIs, custom scripts, or specialized workflows.
You can configure MCP servers at the global level in the ~/.gemini/settings.json file or in your project's root directory. Create or open the .gemini/settings.json file. Within the file, you will need to add the mcpServers configuration block, as shown below:
"mcpServers": {
"server_name_1": {},
"server_name_2": {},
"server_name_n": {}
}
Each server configuration supports the following properties
Required (one of the following)
command (string): Path to the executable for Stdio transport
url (string): SSE endpoint URL (e.g., "http://localhost:8080/sse")
httpUrl (string): HTTP streaming endpoint URL
Optional
args (string[]): Command-line arguments for Stdio transport
headers (object): Custom HTTP headers when using url or httpUrl
env (object): Environment variables for the server process. Values can reference environment variables using $VAR_NAME or ${VAR_NAME} syntax
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.
No comments:
Post a Comment