Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/grafana/next/developer-resources/mcp/clients/vscode-copilot.md, or by sending Accept: text/markdown to https://grafana.com/docs/grafana/next/developer-resources/mcp/clients/vscode-copilot/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana documentation. For the latest stable release, go to the latest version.
VS Code and GitHub Copilot
This guide helps you set up the mcp-grafana server for VS Code with GitHub Copilot agent mode.
Prerequisites
- VS Code with GitHub Copilot extension
- Grafana 9.0+ with a service account token
mcp-grafanabinary installed
Important
GitHub Copilot in VS Code uses SSE transport, not stdio. You need to run mcp-grafana as an HTTP server.
Setup
1. Start the MCP server
export GRAFANA_URL="http://localhost:3000"
export GRAFANA_SERVICE_ACCOUNT_TOKEN="<your-token>"
mcp-grafana --transport sse --address localhost:8000Or with Docker:
docker run --rm -p 8000:8000 \
-e GRAFANA_URL=http://host.docker.internal:3000 \
-e GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token> \
grafana/mcp-grafana --transport sse --address :80002. Configure VS Code
Add to your VS Code settings (settings.json):
{
"github.copilot.chat.mcpServers": {
"grafana": {
"url": "http://localhost:8000/sse"
}
}
}Or use workspace settings (.vscode/settings.json) for project-specific config.
Debug mode
Start the server with debug logging:
mcp-grafana --transport sse --address localhost:8000 -debugVerify configuration
- Restart VS Code after configuration changes
- Open Copilot Chat (Ctrl+Shift+I)
- Type:
@grafana list dashboards - If tools are available, Copilot will query Grafana
Troubleshooting
Server not connecting:
- Verify server is running:
curl http://localhost:8000/sse - Check firewall allows port 8000
- Restart VS Code after configuration changes
Tools not appearing:
- GitHub Copilot agent mode required (may need Copilot Chat enabled)
- Check VS Code output panel for MCP errors
Running as a service
For persistent server, create a systemd unit or launchd plist.
Linux systemd (~/.config/systemd/user/mcp-grafana.service):
[Unit]
Description=Grafana MCP Server
After=network.target
[Service]
ExecStart=/path/to/mcp-grafana --transport sse --address localhost:8000
Environment=GRAFANA_URL=http://localhost:3000
Environment=GRAFANA_SERVICE_ACCOUNT_TOKEN=<your-token>
Restart=always
[Install]
WantedBy=default.targetEnable with:
systemctl --user enable --now mcp-grafanaRead-only mode
mcp-grafana --transport sse --address localhost:8000 --disable-writeNext steps
- Transports and addresses for SSE details.
- Configure authentication for Grafana credentials.
Was this page helpful?
Related resources from Grafana Labs


