master
md 301 lines 10.1 KB
Rendered Raw
1 # Claude Code
2
3 Configure Claude Code to access your Netdata infrastructure through MCP.
4
5 ## Transport Support
6
7 Claude Code supports multiple MCP transport types, giving you flexibility in how you connect to Netdata:
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+ | Remote SCP servers that expose SSE |
14 | **WebSocket** | ❌ Not Supported | - | Use nd-mcp bridge or HTTP/SSE wrappers |
15
16 ## Prerequisites
17
18 1. **Claude Code installed** - Available at [anthropic.com/claude-code](https://www.anthropic.com/claude-code)
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 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 ## Configuration Methods
26
27 Claude Code has comprehensive MCP server management capabilities. For detailed documentation on all configuration options and commands, see the [official Claude Code MCP documentation](https://docs.anthropic.com/en/docs/claude-code/mcp).
28
29 > **Reference:** Claude Code’s official guide documents HTTP, SSE, and stdio transports with both CLI and `.mcp.json` configurations (https://docs.claude.com/en/docs/claude-code/mcp).
30
31 ### Netdata Cloud MCP
32
33 Connect to your entire Netdata Cloud infrastructure
34 through a single endpoint — no local setup, bridges,
35 or firewall changes needed.
36
37 **Prerequisites:**
38
39 - Netdata Cloud account with a Paid plan
40 - Nodes claimed to Netdata Cloud
41 - API token with `scope:mcp`
42 ([create one](/docs/netdata-cloud/authentication-and-authorization/api-tokens.md))
43
44 ```bash
45 # Add for all your projects (user-scoped, personal)
46 claude mcp add --transport http --scope user netdata-cloud \
47 https://app.netdata.cloud/api/v1/mcp \
48 --header "Authorization: Bearer YOUR_NETDATA_CLOUD_API_TOKEN"
49
50 # Or add for team sharing via version control (project-scoped)
51 claude mcp add --transport http --scope project netdata-cloud \
52 https://app.netdata.cloud/api/v1/mcp \
53 --header "Authorization: Bearer YOUR_NETDATA_CLOUD_API_TOKEN"
54 ```
55
56 Or in `.mcp.json`:
57
58 ```json
59 {
60 "mcpServers": {
61 "netdata-cloud": {
62 "type": "http",
63 "url": "https://app.netdata.cloud/api/v1/mcp",
64 "headers": {
65 "Authorization": "Bearer YOUR_NETDATA_CLOUD_API_TOKEN"
66 }
67 }
68 }
69 }
70 ```
71
72 Replace `YOUR_NETDATA_CLOUD_API_TOKEN` with your
73 Netdata Cloud API token (must have `scope:mcp`).
74 For more details, see
75 [Netdata Cloud MCP](/docs/netdata-ai/mcp/README.md#netdata-cloud-mcp).
76
77 ### Local Agent or Parent
78
79 The following methods connect directly to a Netdata Agent or Parent on your network.
80
81 #### Method 1: Direct HTTP Connection (Recommended for v2.7.2+)
82
83 Connect directly to Netdata's HTTP endpoint without needing the nd-mcp bridge:
84
85 ```bash
86 # Add Netdata via direct HTTP connection (project-scoped for team sharing)
87 claude mcp add --transport http --scope project netdata \
88 http://YOUR_NETDATA_IP:19999/mcp \
89 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
90
91 # Or add locally for personal use only
92 claude mcp add --transport http netdata \
93 http://YOUR_NETDATA_IP:19999/mcp \
94 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
95
96 # For HTTPS connections
97 claude mcp add --transport http --scope project netdata \
98 https://YOUR_NETDATA_IP:19999/mcp \
99 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
100 ```
101
102 #### Method 2: Using nd-mcp Bridge (stdio)
103
104 For environments where you prefer or need to use the bridge:
105
106 ```bash
107 # Add Netdata via nd-mcp bridge (project-scoped)
108 claude mcp add --scope project netdata /usr/sbin/nd-mcp \
109 --bearer NETDATA_MCP_API_KEY \
110 ws://YOUR_NETDATA_IP:19999/mcp
111
112 # Or add locally for personal use only
113 claude mcp add netdata /usr/sbin/nd-mcp \
114 --bearer NETDATA_MCP_API_KEY \
115 ws://YOUR_NETDATA_IP:19999/mcp
116 ```
117
118 #### Method 3: Using npx mcp-remote (Alternative Bridge for v2.7.2+)
119
120 If nd-mcp is not available, you can 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).
121
122 ```bash
123 # Using SSE transport
124 claude mcp add --scope project netdata npx mcp-remote@latest \
125 --sse http://YOUR_NETDATA_IP:19999/mcp \
126 --allow-http \
127 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
128
129 # Using HTTP transport
130 claude mcp add --scope project netdata npx mcp-remote@latest \
131 --http http://YOUR_NETDATA_IP:19999/mcp \
132 --allow-http \
133 --header "Authorization: Bearer NETDATA_MCP_API_KEY"
134 ```
135
136 #### Verify Configuration
137
138 ```bash
139 # List configured servers
140 claude mcp list
141
142 # Get server details
143 claude mcp get netdata
144 ```
145
146 Replace in all examples:
147 - `YOUR_NETDATA_IP` - IP address or hostname of your Netdata Agent/Parent
148 - `NETDATA_MCP_API_KEY` - Your [Netdata MCP API key](/docs/netdata-ai/mcp/README.md#finding-your-api-key)
149 - `/usr/sbin/nd-mcp` - With your [actual nd-mcp path](/docs/netdata-ai/mcp/README.md#finding-the-nd-mcp-bridge) (stdio method only)
150
151 **Project-scoped configuration** creates a `.mcp.json` file that can be shared with your team via version control.
152
153 ## How to Use
154
155 Claude Code can automatically use Netdata MCP when you ask infrastructure-related questions. If Netdata is your only observability solution configured via MCP, simply ask your question naturally:
156
157 ```
158 What's the current CPU usage across all servers?
159 Show me any anomalies in the last hour
160 Which processes are consuming the most memory?
161 ```
162
163 ### Explicit MCP Server Selection
164
165 Claude Code also allows you to explicitly specify which MCP server to use with the `/mcp` command:
166
167 1. Open Claude Code in the directory containing `.mcp.json`
168 2. Type `/mcp` to verify Netdata is available
169 3. Use `/mcp netdata` followed by your query:
170
171 ```
172 /mcp netdata describe my infrastructure
173 /mcp netdata what alerts are currently active?
174 /mcp netdata show me database performance metrics
175 ```
176
177 This is particularly useful when you have multiple MCP servers configured and want to ensure Claude uses the correct one.
178
179 > **💡 Advanced Usage:** Claude Code 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).
180
181 ## Project-Based Configuration
182
183 Claude Code's strength is project-specific configurations. You can have different project directories with different MCP servers, allowing you to control the MCP servers based on the directory from which you started Claude Code.
184
185 ### Configuration File Format (`.mcp.json`)
186
187 #### Direct HTTP Connection (Recommended)
188
189 Create `~/projects/production/.mcp.json`:
190
191 ```json
192 {
193 "mcpServers": {
194 "netdata": {
195 "type": "http",
196 "url": "http://prod-parent.company.com:19999/mcp",
197 "headers": [
198 "Authorization: Bearer ${NETDATA_API_KEY}"
199 ]
200 }
201 }
202 }
203 ```
204
205 #### Using nd-mcp Bridge
206
207 Create `~/projects/production/.mcp.json`:
208
209 ```json
210 {
211 "mcpServers": {
212 "netdata": {
213 "command": "/usr/sbin/nd-mcp",
214 "args": [
215 "--bearer",
216 "${NETDATA_API_KEY}",
217 "ws://prod-parent.company.com:19999/mcp"
218 ]
219 }
220 }
221 }
222 ```
223
224 #### Using npx mcp-remote
225
226 Create `~/projects/production/.mcp.json`:
227
228 ```json
229 {
230 "mcpServers": {
231 "netdata": {
232 "command": "npx",
233 "args": [
234 "mcp-remote@latest",
235 "--sse",
236 "http://prod-parent.company.com:19999/mcp",
237 "--allow-http",
238 "--header",
239 "Authorization: Bearer ${NETDATA_API_KEY}",
240 ]
241 }
242 }
243 }
244 ```
245
246 ### Environment Variables
247
248 Claude Code supports environment variable expansion in `.mcp.json`:
249 - `${VAR}` - Expands to the value of environment variable `VAR`
250 - `${VAR:-default}` - Uses `VAR` if set, otherwise uses `default`
251
252 This allows you to keep sensitive API keys out of version control.
253
254 ## Claude Instructions
255
256 Create a `CLAUDE.md` file in your project root with default instructions:
257
258 ```markdown
259 # Claude Instructions
260
261 You have access to Netdata monitoring for our production infrastructure.
262
263 When I ask about performance or issues:
264 1. Always check current metrics first
265 2. Look for anomalies in the relevant time period
266 3. Check logs if investigating errors
267 4. Provide specific metric values and timestamps
268
269 Our key services to monitor:
270 - Web servers (nginx)
271 - Databases (PostgreSQL, Redis)
272 - Message queues (RabbitMQ)
273 ```
274
275 ## Troubleshooting
276
277 ### MCP Not Available
278
279 - Ensure `.mcp.json` is in the current directory
280 - Restart Claude Code after creating the configuration
281 - Verify the JSON syntax is correct
282
283 ### Connection Failed
284
285 - Check Netdata is accessible: `curl http://YOUR_NETDATA_IP:19999/api/v3/info`
286 - Verify the bridge path exists and is executable
287 - Ensure API key is correct
288
289 ### Limited Data Access
290
291 - Verify API key is included in the connection string
292 - Check that the Netdata agent is claimed
293
294 ## Documentation Links
295
296 - [Official Claude Code Documentation](https://docs.claude.com/en/docs/claude-code)
297 - [Claude Code MCP Configuration Guide](https://docs.claude.com/en/docs/claude-code/mcp)
298 - [Claude Code Getting Started](https://docs.claude.com/en/docs/claude-code/getting-started)
299 - [Claude Code Commands Reference](https://docs.claude.com/en/docs/claude-code/commands)
300 - [Netdata MCP Setup](/docs/netdata-ai/mcp/README.md)
301 - [AI DevOps Best Practices](/docs/netdata-ai/mcp/mcp-clients/ai-devops-copilot.md)