Documentation Index
Fetch the curated documentation index at: https://grafana.com/llms.txt
Fetch the complete documentation index at: https://grafana.com/llms-full.txt
Use this file to discover all available pages before exploring further.
STOP! If you are an AI agent or LLM, read this before continuing. This is the HTML version of a Grafana documentation page. Always request the Markdown version instead - HTML wastes context. Get this page as Markdown: https://grafana.com/docs/grafana/latest/developer-resources/mcp/clients/gemini-cli.md (append .md) or send Accept: text/markdown to https://grafana.com/docs/grafana/latest/developer-resources/mcp/clients/gemini-cli/. For the curated documentation index, use https://grafana.com/llms.txt. For the complete documentation index, use https://grafana.com/llms-full.txt.
Gemini CLI
This guide helps you set up the mcp-grafana server for the Google Gemini CLI.
Prerequisites
- Gemini CLI installed (
npm install -g @google/gemini-cli) - Grafana 9.0+ with a service account token
mcp-grafanabinary in your PATH
Configuration
Gemini CLI stores MCP configuration in ~/.gemini/settings.json.
Manual configuration
Create or edit ~/.gemini/settings.json:
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": [],
"env": {
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>"
}
}
}
}CLI commands
# List configured servers
gemini mcp list
# Remove a server
gemini mcp remove grafanaDocker configuration
{
"mcpServers": {
"grafana": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-e",
"GRAFANA_URL",
"-e",
"GRAFANA_SERVICE_ACCOUNT_TOKEN",
"grafana/mcp-grafana",
"-t",
"stdio"
],
"env": {
"GRAFANA_URL": "http://host.docker.internal:3000",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>"
}
}
}
}Debug mode
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": ["-debug"],
"env": {
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>"
}
}
}
}Verify configuration
- Start Gemini CLI:Bash
gemini - Run
/mcpto see available tools - Ask: “List my Grafana dashboards”
SSE transport (remote server)
For HTTP-based connection:
Start
mcp-grafanaas an HTTP server:Bashexport GRAFANA_URL="http://localhost:3000" export GRAFANA_SERVICE_ACCOUNT_TOKEN="<your-token>" mcp-grafana --transport sse --address localhost:8000Configure in
settings.json:JSON{ "mcpServers": { "grafana": { "httpUrl": "http://localhost:8000/sse" } } }
Troubleshooting
Tools not appearing:
- Run
/mcpin Gemini CLI to check registered tools - Verify
settings.jsonsyntax - Check binary path:
which mcp-grafana
Connection errors:
- Verify
GRAFANA_URLis reachable - Check token permissions in Grafana
Read-only mode
{
"mcpServers": {
"grafana": {
"command": "mcp-grafana",
"args": ["--disable-write"],
"env": {
"GRAFANA_URL": "http://localhost:3000",
"GRAFANA_SERVICE_ACCOUNT_TOKEN": "<your-token>"
}
}
}
}Next steps
- Set up for other install options.
- Configure authentication for Grafana credentials.
Was this page helpful?
Related resources from Grafana Labs


