docs/netdata-ai/mcp/mcp-clients/opencode.md
Configure SST's OpenCode to access your Netdata infrastructure through MCP for terminal-based AI-powered DevOps operations.
OpenCode supports both local and remote MCP servers:
| Transport | Support | Netdata Version | Use Case |
|---|---|---|---|
| stdio (via nd-mcp bridge) | ✅ Fully Supported | v2.6.0+ | Local bridge to WebSocket |
| Streamable HTTP (remote) | ✅ Fully Supported | v2.7.2+ | Direct connection to Netdata's HTTP endpoint (recommended) |
| SSE (Server-Sent Events) | ⚠️ Limited Support | v2.7.2+ | Known issues with SSE servers |
| WebSocket | ❌ Not Supported | - | Use nd-mcp bridge or HTTP instead |
Note: OpenCode has reported issues with SSE-based MCP servers (GitHub Issue #834). Use HTTP streamable transport for best compatibility.
nd-mcp bridgend-mcp bridge - The stdio-to-websocket bridge. Find its absolute path. Not needed for direct HTTP connections on v2.7.2+.Export
ND_MCP_BEARER_TOKENwith your MCP key before launching OpenCode to keep secrets out of configuration files:bashexport ND_MCP_BEARER_TOKEN="$(cat /var/lib/netdata/mcp_dev_preview_api_key)"
Install OpenCode using one of these methods:
# Using npm (recommended)
npm i -g opencode-ai@latest
# Using Homebrew
brew install sst/tap/opencode
# Using curl installation script
curl -fsSL https://opencode.ai/install.sh | bash
OpenCode uses an opencode.json configuration file with MCP servers defined under the mcp key.
Connect to your entire Netdata Cloud infrastructure through a single endpoint — no local setup, bridges, or firewall changes needed.
Prerequisites:
scope:mcp
(create one){
"mcp": {
"netdata-cloud": {
"type": "remote",
"url": "https://app.netdata.cloud/api/v1/mcp",
"oauth": false,
"headers": {
"Authorization": "Bearer YOUR_NETDATA_CLOUD_API_TOKEN"
},
"enabled": true
}
}
}
Replace YOUR_NETDATA_CLOUD_API_TOKEN with your
Netdata Cloud API token (must have scope:mcp).
For more details, see
Netdata Cloud MCP.
The following methods connect directly to a Netdata Agent or Parent on your network.
Connect directly to Netdata's HTTP endpoint without needing the nd-mcp bridge:
{
"mcp": {
"netdata": {
"type": "remote",
"url": "http://YOUR_NETDATA_IP:19999/mcp",
"headers": {
"Authorization": "Bearer NETDATA_MCP_API_KEY"
},
"enabled": true
}
}
}
For HTTPS connections:
{
"mcp": {
"netdata": {
"type": "remote",
"url": "https://YOUR_NETDATA_IP:19999/mcp",
"headers": {
"Authorization": "Bearer NETDATA_MCP_API_KEY"
},
"enabled": true
}
}
}
For environments where you prefer or need to use the bridge:
{
"mcp": {
"netdata": {
"type": "local",
"command": ["/usr/sbin/nd-mcp", "ws://YOUR_NETDATA_IP:19999/mcp"],
"enabled": true
}
}
}
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.
{
"mcp": {
"netdata": {
"type": "local",
"command": [
"npx",
"mcp-remote@latest",
"--http",
"http://YOUR_NETDATA_IP:19999/mcp",
"--allow-http",
"--header",
"Authorization: Bearer NETDATA_MCP_API_KEY"
],
"enabled": true
}
}
}
OpenCode supports environment variables in local server configurations:
{
"mcp": {
"netdata": {
"type": "local",
"command": ["/usr/sbin/nd-mcp", "ws://YOUR_NETDATA_IP:19999/mcp"],
"enabled": true,
"environment": {
"ND_MCP_BEARER_TOKEN": "your-api-key-here"
}
}
}
}
For remote servers with environment variables:
{
"mcp": {
"netdata": {
"type": "remote",
"url": "https://YOUR_NETDATA_IP:19999/mcp",
"headers": {
"Authorization": "Bearer ${NETDATA_API_KEY}"
},
"enabled": true
}
}
}
Replace in all examples:
YOUR_NETDATA_IP - IP address or hostname of your Netdata Agent/ParentND_MCP_BEARER_TOKEN - Export with your Netdata MCP API key before launching OpenCode/usr/sbin/nd-mcp - With your actual nd-mcp path (local method only)Once configured, OpenCode can leverage Netdata's observability data through its terminal interface:
# Start OpenCode
opencode
# The AI assistant will have access to Netdata tools
# Ask infrastructure questions naturally:
What's the current CPU usage across all servers?
Show me any performance anomalies in the last hour
Which services are consuming the most resources?
OpenCode allows fine-grained control over MCP tool availability per agent:
{
"mcp": {
"netdata": {
"type": "remote",
"url": "http://YOUR_NETDATA_IP:19999/mcp",
"headers": {
"Authorization": "Bearer NETDATA_MCP_API_KEY"
},
"enabled": true
}
},
"tools": {
"netdata*": false
},
"agent": {
"infrastructure-analyst": {
"tools": {
"netdata*": true
}
}
}
}
This configuration:
Performance Investigation:
Investigate why our application response times increased this afternoon using Netdata metrics
Resource Optimization:
Check memory usage patterns across all nodes and suggest optimization strategies
Alert Analysis:
Explain the current active alerts from Netdata and their potential impact
Anomaly Detection:
Find any anomalous metrics in the last 2 hours and explain what might be causing them
💡 Advanced Usage: OpenCode's terminal-based interface combined with Netdata observability creates powerful DevOps workflows. Learn about the opportunities and security considerations in AI DevOps Copilot.
curl http://YOUR_NETDATA_IP:19999/api/v3/infoopencode.json file"enabled": true)OpenCode has known issues with SSE-based MCP servers. If you encounter "UnknownError Server error" messages:
?transport=sse from URL)["command", "arg1", "arg2"]"url": "http://..."Configure different Netdata instances for different purposes:
{
"mcp": {
"netdata-prod": {
"type": "remote",
"url": "https://prod-parent.company.com:19999/mcp",
"headers": {
"Authorization": "Bearer ${PROD_API_KEY}"
},
"enabled": true
},
"netdata-staging": {
"type": "remote",
"url": "https://staging-parent.company.com:19999/mcp",
"headers": {
"Authorization": "Bearer ${STAGING_API_KEY}"
},
"enabled": false
},
"netdata-local": {
"type": "local",
"command": ["/usr/sbin/nd-mcp", "ws://localhost:19999/mcp"],
"environment": {
"ND_MCP_BEARER_TOKEN": "${LOCAL_API_KEY}"
},
"enabled": true
}
}
}
Enable verbose logging to troubleshoot MCP issues:
{
"mcp": {
"netdata": {
"type": "remote",
"url": "http://YOUR_NETDATA_IP:19999/mcp",
"headers": {
"Authorization": "Bearer NETDATA_MCP_API_KEY"
},
"enabled": true,
"debug": true
}
}
}