master
md 362 lines 10.2 KB
Rendered Raw
1 # Gemini CLI
2
3 Configure Google's Gemini CLI to access your Netdata infrastructure through MCP for powerful AI-driven operations.
4
5 ## Transport Support
6
7 Gemini CLI supports all major MCP transport types, giving you maximum flexibility:
8
9 | Transport | Support | Netdata Version | Use Case |
10 |-----------|---------|-----------------|----------|
11 | **stdio** (via nd-mcp bridge) | ✅ Fully Supported | v2.6.0+ | Local bridge to WebSocket |
12 | **Streamable HTTP** | ✅ Fully Supported | v2.7.2+ | Direct connection to Netdata's HTTP endpoint (recommended) |
13 | **SSE** (Server-Sent Events) | ✅ Fully Supported | v2.7.2+ | Direct connection to Netdata's SSE endpoint |
14 | **WebSocket** | ❌ Not Supported | - | Use nd-mcp bridge or HTTP/SSE instead |
15
16 ## Prerequisites
17
18 1. **Gemini CLI installed** - Available from [GitHub](https://github.com/google-gemini/gemini-cli)
19 2. **Netdata v2.6.0 or later** with MCP support - Prefer a Netdata Parent to get infrastructure level visibility. Your AI Client (running on your desktop or laptop) needs to have direct network access to the Netdata IP and port (usually 19999).
20 - **v2.6.0 - v2.7.1**: Only WebSocket transport available, requires `nd-mcp` bridge
21 - **v2.7.2+**: Direct HTTP/SSE support available (recommended)
22 3. **For WebSocket or stdio connections: `nd-mcp` bridge** - The stdio-to-websocket bridge. [Find its absolute path](/docs/netdata-ai/mcp/README.md#finding-the-nd-mcp-bridge). Not needed for direct HTTP/SSE connections on v2.7.2+.
23 4. **Optionally, the Netdata MCP API key** that unlocks full access to sensitive observability data (protected functions, full access to logs) on your Netdata. Each Netdata Agent or Parent has its own unique API key for MCP - [Find your Netdata MCP API key](/docs/netdata-ai/mcp/README.md#finding-your-api-key)
24
25 ## Installation
26
27 ```bash
28 # Run Gemini CLI directly from GitHub
29 npx https://github.com/google-gemini/gemini-cli
30
31 # Or clone and install locally
32 git clone https://github.com/google-gemini/gemini-cli.git
33 cd gemini-cli
34 npm install
35 npm run build
36 ```
37
38 ## Configuration Methods
39
40 Gemini CLI has built-in MCP server support. For detailed MCP configuration, see the [official MCP documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md).
41
42 ### Netdata Cloud MCP
43
44 Connect to your entire Netdata Cloud infrastructure
45 through a single endpoint — no local setup, bridges,
46 or firewall changes needed.
47
48 **Prerequisites:**
49
50 - Netdata Cloud account with a Paid plan
51 - Nodes claimed to Netdata Cloud
52 - API token with `scope:mcp`
53 ([create one](/docs/netdata-cloud/authentication-and-authorization/api-tokens.md))
54
55 ```bash
56 # Using CLI command
57 gemini mcp add --transport http netdata-cloud https://app.netdata.cloud/api/v1/mcp \
58 --header "Authorization: Bearer YOUR_NETDATA_CLOUD_API_TOKEN"
59 ```
60
61 Or configure in `~/.gemini/settings.json`:
62
63 ```json
64 {
65 "mcpServers": {
66 "netdata-cloud": {
67 "httpUrl": "https://app.netdata.cloud/api/v1/mcp",
68 "headers": {
69 "Authorization": "Bearer YOUR_NETDATA_CLOUD_API_TOKEN"
70 },
71 "timeout": 30000
72 }
73 }
74 }
75 ```
76
77 Replace `YOUR_NETDATA_CLOUD_API_TOKEN` with your
78 Netdata Cloud API token (must have `scope:mcp`).
79 For more details, see
80 [Netdata Cloud MCP](/docs/netdata-ai/mcp/README.md#netdata-cloud-mcp).
81
82 ### Local Agent or Parent
83
84 The following methods connect directly to a Netdata Agent or Parent on your network.
85
86 #### Method 1: Direct HTTP Connection (Recommended for v2.7.2+)
87
88 Connect directly to Netdata's HTTP endpoint without needing any bridge:
89
90 ```bash
91 # Using CLI command
92 gemini mcp add --transport http netdata http://YOUR_NETDATA_IP:19999/mcp \
93 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
94
95 # For HTTPS connections
96 gemini mcp add --transport http netdata https://YOUR_NETDATA_IP:19999/mcp \
97 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
98 ```
99
100 Or configure in `~/.gemini/settings.json`:
101
102 ```json
103 {
104 "mcpServers": {
105 "netdata": {
106 "httpUrl": "http://YOUR_NETDATA_IP:19999/mcp",
107 "headers": [
108 "Authorization: Bearer NETDATA_MCP_API_KEY"
109 ],
110 "timeout": 30000
111 }
112 }
113 }
114 ```
115
116 #### Method 2: Direct SSE Connection (v2.7.2+)
117
118 Connect directly to Netdata's SSE endpoint:
119
120 ```bash
121 # Using CLI command
122 gemini mcp add --transport sse netdata http://YOUR_NETDATA_IP:19999/mcp?transport=sse \
123 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
124 ```
125
126 Or configure in `~/.gemini/settings.json`:
127
128 ```json
129 {
130 "mcpServers": {
131 "netdata": {
132 "url": "http://YOUR_NETDATA_IP:19999/mcp?transport=sse",
133 "headers": [
134 "Authorization: Bearer NETDATA_MCP_API_KEY"
135 ],
136 "timeout": 30000
137 }
138 }
139 }
140 ```
141
142 #### Method 3: Using nd-mcp Bridge (stdio)
143
144 For environments where you prefer or need to use the bridge:
145
146 ```bash
147 # Using CLI command
148 gemini mcp add netdata /usr/sbin/nd-mcp --bearer NETDATA_MCP_API_KEY \
149 ws://YOUR_NETDATA_IP:19999/mcp
150 ```
151
152 Or configure in `~/.gemini/settings.json`:
153
154 ```json
155 {
156 "mcpServers": {
157 "netdata": {
158 "command": "/usr/sbin/nd-mcp",
159 "args": [
160 "--bearer",
161 "NETDATA_MCP_API_KEY",
162 "ws://YOUR_NETDATA_IP:19999/mcp"
163 ],
164 "timeout": 30000
165 }
166 }
167 }
168 ```
169
170 #### Method 4: Using npx mcp-remote (Alternative Bridge for v2.7.2+)
171
172 If nd-mcp is not available, use the official MCP remote client (requires Netdata v2.7.2+). For detailed options and troubleshooting, see [Using MCP Remote Client](/docs/netdata-ai/mcp/README.md#using-mcp-remote-client).
173
174 ```bash
175 # Using CLI command with SSE
176 gemini mcp add netdata npx mcp-remote@latest \
177 --sse http://YOUR_NETDATA_IP:19999/mcp \
178 --allow-http \
179 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
180
181 # Using HTTP transport
182 gemini mcp add netdata npx mcp-remote@latest \
183 --http http://YOUR_NETDATA_IP:19999/mcp \
184 --allow-http \
185 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
186 ```
187
188 Or configure in `~/.gemini/settings.json`:
189
190 ```json
191 {
192 "mcpServers": {
193 "netdata": {
194 "command": "npx",
195 "args": [
196 "mcp-remote@latest",
197 "--sse",
198 "http://YOUR_NETDATA_IP:19999/mcp",
199 "--allow-http",
200 "--header",
201 "Authorization: Bearer NETDATA_MCP_API_KEY",
202 ]
203 }
204 }
205 }
206 ```
207
208 ## Environment Variables
209
210 Gemini CLI supports environment variable expansion in `settings.json`:
211 - `$VAR_NAME` or `${VAR_NAME}` - Expands to the value of environment variable
212
213 Example configuration with environment variables:
214
215 ```json
216 {
217 "mcpServers": {
218 "netdata": {
219 "httpUrl": "http://${NETDATA_HOST}:19999/mcp",
220 "headers": [
221 "Authorization: Bearer ${NETDATA_API_KEY}"
222 ]
223 }
224 }
225 }
226 ```
227
228 ## Verify MCP Configuration
229
230 Use these commands to verify your setup:
231
232 ```bash
233 # List all configured MCP servers
234 gemini mcp list
235
236 # Interactive MCP status (within Gemini session)
237 /mcp
238
239 # Show detailed descriptions of MCP servers and tools
240 /mcp desc
241
242 # Show MCP server schema details
243 /mcp schema
244 ```
245
246 Replace in all examples:
247 - `YOUR_NETDATA_IP` - IP address or hostname of your Netdata Agent/Parent
248 - `NETDATA_MCP_API_KEY` - Your [Netdata MCP API key](/docs/netdata-ai/mcp/README.md#finding-your-api-key)
249 - `/usr/sbin/nd-mcp` - With your [actual nd-mcp path](/docs/netdata-ai/mcp/README.md#finding-the-nd-mcp-bridge) (stdio method only)
250
251 ## How to Use
252
253 Gemini CLI can leverage Netdata's observability data for infrastructure analysis and automation:
254
255 ```
256 What's the current system performance across all monitored servers?
257 Show me any performance anomalies in the last 2 hours
258 Which services are consuming the most resources right now?
259 Analyze the database performance trends over the past week
260 ```
261
262 ## Example Workflows
263
264 **Performance Investigation:**
265
266 ```
267 Investigate why our application response times increased this afternoon
268 ```
269
270 **Resource Optimization:**
271
272 ```
273 Check memory usage patterns and suggest optimization strategies
274 ```
275
276 **Alert Analysis:**
277
278 ```
279 Explain the current active alerts and their potential impact
280 ```
281
282 > **💡 Advanced Usage:** Gemini CLI can combine observability data with system automation for powerful DevOps workflows. Learn about the opportunities and security considerations in [AI DevOps Copilot](/docs/netdata-ai/mcp/mcp-clients/ai-devops-copilot.md).
283
284 ## Troubleshooting
285
286 ### MCP Connection Issues
287
288 - Verify Netdata is accessible: `curl http://YOUR_NETDATA_IP:19999/api/v3/info`
289 - Check that the bridge path exists and is executable
290 - Ensure the Authorization header is correctly formatted
291
292 ### Limited Data Access
293
294 - Verify the Authorization header is present on each request
295 - Check that the Netdata agent is properly configured for MCP
296 - Ensure network connectivity between Gemini CLI and Netdata
297
298 ### Command Execution Problems
299
300 - Review command syntax for your specific Gemini CLI version
301 - Check MCP server configuration parameters
302 - Verify that MCP protocol is supported in your Gemini CLI installation
303
304 ## Advanced Configuration
305
306 ### Multiple Environments
307
308 Configure different Netdata instances for different purposes:
309
310 ```json
311 {
312 "mcpServers": {
313 "netdata-prod": {
314 "httpUrl": "https://prod-parent.company.com:19999/mcp",
315 "headers": [
316 "Authorization: Bearer ${PROD_API_KEY}"
317 ]
318 },
319 "netdata-staging": {
320 "httpUrl": "https://staging-parent.company.com:19999/mcp",
321 "headers": [
322 "Authorization: Bearer ${STAGING_API_KEY}"
323 ]
324 },
325 "netdata-local": {
326 "command": "/usr/sbin/nd-mcp",
327 "args": [
328 "--bearer",
329 "${LOCAL_API_KEY}",
330 "ws://localhost:19999/mcp"
331 ]
332 }
333 }
334 }
335 ```
336
337 ### Tool Filtering
338
339 Control which Netdata tools are available:
340
341 ```json
342 {
343 "mcpServers": {
344 "netdata": {
345 "httpUrl": "http://YOUR_NETDATA_IP:19999/mcp",
346 "headers": [
347 "Authorization: Bearer NETDATA_MCP_API_KEY"
348 ],
349 "includeTools": ["query_metrics", "list_alerts", "list_nodes"],
350 "excludeTools": ["execute_function", "systemd_journal"]
351 }
352 }
353 }
354 ```
355
356 ## Documentation Links
357
358 - [Gemini CLI GitHub Repository](https://github.com/google-gemini/gemini-cli)
359 - [Gemini CLI MCP Documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md)
360 - [Gemini CLI Configuration Guide](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/configuration.md)
361 - [Netdata MCP Setup](/docs/netdata-ai/mcp/README.md)
362 - [AI DevOps Best Practices](/docs/netdata-ai/mcp/mcp-clients/ai-devops-copilot.md)