feat: add support to remote MCP servers for custom HTTP headers (#2477)

This commit is contained in:
Adam Spiers
2025-06-30 01:09:08 +01:00
committed by GitHub
parent d1eb86581c
commit 0fd602eb43
4 changed files with 149 additions and 2 deletions

View File

@@ -87,6 +87,7 @@ Each server configuration supports the following properties:
#### Optional
- **`args`** (string[]): Command-line arguments for Stdio transport
- **`headers`** (object): Custom HTTP headers when using `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)
@@ -166,6 +167,24 @@ Each server configuration supports the following properties:
}
```
#### HTTP-based MCP Server with Custom Headers
```json
{
"mcpServers": {
"httpServerWithAuth": {
"httpUrl": "http://localhost:3000/mcp",
"headers": {
"Authorization": "Bearer your-api-token",
"X-Custom-Header": "custom-value",
"Content-Type": "application/json"
},
"timeout": 5000
}
}
}
```
## Discovery Process Deep Dive
When the Gemini CLI starts, it performs MCP server discovery through the following detailed process: