Skip to content

Commit 7f6b82d

Browse files
tiffanyfayclaudesd2k
authored
Create formal documentation (#759)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Ben Sully <ben.sully@grafana.com>
1 parent 604d1c3 commit 7f6b82d

50 files changed

Lines changed: 3726 additions & 39 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ Forwarded headers are merged with any headers defined in `GRAFANA_EXTRA_HEADERS`
548548
- **Download binary**: Download the latest release of `mcp-grafana` from the [releases page](https://github.com/grafana/mcp-grafana/releases) and place it in your `$PATH`.
549549
550550
- **Build from source**: If you have a Go toolchain installed you can also build and install it from source, using the `GOBIN` environment variable
551-
to specify the directory where the binary should be installed. This should also be in your `PATH`.
551+
to specify the directory where the binary should be installed. This should also be in your `$PATH`.
552552
553553
```bash
554554
GOBIN="$HOME/go/bin" go install github.com/grafana/mcp-grafana/cmd/mcp-grafana@latest

docs/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DEFAULT_GOAL: help
2+
3+
# Adapted from https://www.thapaliya.com/en/writings/well-documented-makefiles/
4+
.PHONY: help
5+
help: ## Display this help.
6+
help:
7+
@awk 'BEGIN {FS = ": ##"; printf "Usage:\n make <target>\n\nTargets:\n"} /^[a-zA-Z0-9_\.\-\/%]+: ##/ { printf " %-45s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
8+
9+
include docs.mk
10+
11+
.PHONY: test
12+
test:
13+
docker run -v $(CURDIR)/sources:/hugo/content/docs/mcp-server/latest -e HUGO_REFLINKSERRORLEVEL=ERROR --rm grafana/docs-base:latest /bin/bash -c 'exec make hugo'

docs/docs.agent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Ensure you have the necessary prerequisites to install, update, and use the agen
3737

3838
### Prerequisites
3939

40-
- Python 3 `python3` in your shell `PATH`
40+
- Python 3 `python3` in your shell `$PATH`
4141
- A frontier AI model and agent, ideally with a GitHub MCP server
4242

4343
I recommend [VS Code GitHub Copilot](https://code.visualstudio.com/) as it has the following benefits:

docs/docs.agent/context.md

Lines changed: 151 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,76 @@
22

33
Follow and keep this documentation context and plan up to date.
44

5-
This repository <GIT_REPOSITORY> is the main context source.
5+
This repository **github.com/grafana/mcp-grafana** is the main context source.
66

77
If you have additional project or repository context sources, list them here:
88

9-
- Source 1
10-
- Source 2
11-
- Source 3
9+
- [Model Context Protocol](https://modelcontextprotocol.io/) specification
10+
- [Grafana API documentation](https://grafana.com/docs/grafana/latest/developers/http_api/)
1211

1312
Output docs to `docs/sources/`.
1413

15-
Order sections and articles as they are below.
14+
Order sections as they appear below: Clients, then Set up, then Configure.
1615

1716
Add articles as h3 subsections with a list of:
1817

1918
- Relevant source files for context
2019
- Things to include and not include
2120

21+
## Clients
22+
23+
Output client-specific setup docs to `docs/sources/clients/`.
24+
25+
One article per client. Each covers prerequisites, config file location, and a working server block.
26+
27+
### Claude Desktop
28+
29+
- **Context:** docs/clients/claude-desktop.md
30+
- **Include:** Config path by OS, JSON example, uvx and binary options.
31+
- **Exclude:** General MCP theory.
32+
33+
### Cursor
34+
35+
- **Context:** docs/clients/cursor.md
36+
- **Include:** Global vs project mcp.json, UI and manual config.
37+
- **Exclude:** Other clients.
38+
39+
### Other clients (Codex, VS Code Copilot, Windsurf, Zed, Claude Code, Gemini CLI)
40+
41+
- **Context:** docs/clients/*.md for each
42+
- **Include:** Same pattern – prerequisites, config path, example block.
43+
- **Exclude:** Duplicating README installation.
44+
2245
## Set up
2346

2447
Output setup docs to `docs/sources/set-up/`.
2548

26-
Create individual articles for each setup method.
27-
Order articles from recommended to advanced setups.
49+
Create individual articles for each setup method (install and run the server).
50+
Order articles from fewer steps to more involved (uvx, Docker, binary, Helm).
51+
52+
### Install with uvx
53+
54+
- **Context:** README.md (Quick Start, Usage), cmd/
55+
- **Include:** Prerequisite (uv), minimal JSON config, GRAFANA_URL and GRAFANA_SERVICE_ACCOUNT_TOKEN. Grafana Cloud URL example.
56+
- **Exclude:** All other install methods, deep configuration.
57+
58+
### Install with Docker
59+
60+
- **Context:** README.md (Docker image, STDIO vs SSE vs streamable-http)
61+
- **Include:** docker pull/run for stdio and SSE, port mapping, env vars. Override `-t stdio` for stdio mode.
62+
- **Exclude:** Helm, binary, TLS server config (cover in Configure).
63+
64+
### Install the binary
65+
66+
- **Context:** README.md (Download binary, Build from source)
67+
- **Include:** Releases page link, GOBIN/path, `go install` for source build.
68+
- **Exclude:** uvx and Docker steps.
69+
70+
### Deploy with Helm
71+
72+
- **Context:** README.md (Helm chart)
73+
- **Include:** helm repo add/install, grafana.apiKey and grafana.url. Link to helm-charts repo.
74+
- **Exclude:** In-cluster Grafana setup (out of scope).
2875

2976
## Configure
3077

@@ -33,13 +80,53 @@ Output configure docs to `docs/sources/configure/`.
3380
Create individual articles for each feature or component.
3481
Order articles from foundational to advanced configuration.
3582

83+
### Authentication
84+
85+
- **Context:** README.md (Usage, service account, env vars)
86+
- **Include:** Service account token (recommended), username/password, GRAFANA_SERVICE_ACCOUNT_TOKEN and GRAFANA_API_KEY deprecation. Link to Grafana service account docs.
87+
- **Exclude:** TLS client certs (separate article).
88+
89+
### Transports and addresses
90+
91+
- **Context:** README.md (CLI Flags Reference, Transport Options)
92+
- **Include:** stdio (default for local), sse, streamable-http; --address, --base-path, --endpoint-path. When to use each.
93+
- **Exclude:** Client config examples (covered in Set up / client docs).
94+
95+
### Enable and disable tools
96+
97+
- **Context:** README.md (Tool Configuration, --enabled-tools, --disable-*)
98+
- **Include:** --enabled-tools for runpanelquery, examples, clickhouse, cloudwatch, etc. --disable-* by category. Read-only mode (--disable-write).
99+
- **Exclude:** Full tool list (refer to README or introduction).
100+
101+
### Client TLS (Grafana connection)
102+
103+
- **Context:** README.md (TLS Configuration, Client TLS)
104+
- **Include:** --tls-cert-file, --tls-key-file, --tls-ca-file, --tls-skip-verify. Env-based config not required for this article.
105+
- **Exclude:** Server TLS (streamable-http only).
106+
107+
### Server TLS (streamable-http)
108+
109+
- **Context:** README.md (Server TLS Configuration)
110+
- **Include:** --server.tls-cert-file, --server.tls-key-file. When and why (HTTPS for MCP server).
111+
- **Exclude:** Client TLS, Docker internal networking.
112+
113+
### Multi-organization and headers
114+
115+
- **Context:** README.md (Multi-Organization Support, Custom HTTP Headers)
116+
- **Include:** GRAFANA_ORG_ID, X-Grafana-Org-Id; GRAFANA_EXTRA_HEADERS JSON.
117+
- **Exclude:** RBAC (covered in introduction or separate doc if needed).
118+
36119
## introduction.md
37120

38121
Create one `introduction.md` article covering these key unique concepts:
39122

40-
- Concept 1
41-
- Concept 2
42-
- Concept 3
123+
- **Model Context Protocol (MCP):** What MCP is and how the Grafana MCP server lets AI assistants and LLM clients talk to Grafana (dashboards, datasources, metrics, logs, traces, alerts, incidents).
124+
- **Tools and capabilities:** High-level categories (dashboards, datasources, Prometheus/Loki/others, alerting, incidents, OnCall, Sift, navigation, rendering). Configurable tool set and context-window considerations.
125+
- **Authentication and RBAC:** Service account (or user) and Grafana RBAC; least-privilege vs Editor role; link to Grafana RBAC docs.
126+
127+
- **Context:** README.md (Features, Requirements, RBAC sections)
128+
- **Include:** One-page overview for customers; link to set-up and configure; mention Grafana 9.0+.
129+
- **Exclude:** Step-by-step setup, full CLI reference (link to README or configure).
43130

44131
## Guides
45132

@@ -52,6 +139,48 @@ Show the user how to use the product and its features to solve problems.
52139
Create individual articles for each use case.
53140
Order articles from foundational to advanced use cases.
54141

142+
### Query metrics with Prometheus
143+
144+
- **Context:** README.md (Prometheus Querying), MCP tool descriptions
145+
- **Include:** Use the MCP server from a client to run PromQL (instant/range), list metrics and labels. Example use case (e.g., check a metric in a conversation).
146+
- **Exclude:** Panel query execution, Loki or other datasources.
147+
148+
### Query logs with Loki
149+
150+
- **Context:** README.md (Loki Querying)
151+
- **Include:** LogQL log and metric queries, label names/values, patterns. Example use case.
152+
- **Exclude:** Search logs tool, ClickHouse.
153+
154+
### Search and inspect dashboards
155+
156+
- **Context:** README.md (Dashboards, Context Window Management)
157+
- **Include:** Search dashboards, get summary vs full JSON, get panel queries; when to use get_dashboard_property.
158+
- **Exclude:** Update/patch dashboard (separate guide if desired).
159+
160+
### Manage alert rules
161+
162+
- **Context:** README.md (Alerting)
163+
- **Include:** List/fetch alert rules, create/update/delete; contact points and routing. RBAC requirements.
164+
- **Exclude:** OnCall alert groups (different feature).
165+
166+
### Generate deeplinks to Grafana
167+
168+
- **Context:** README.md (Navigation)
169+
- **Include:** Dashboard, panel, and Explore deeplinks; time range and variables. Use case: share accurate links from an AI assistant.
170+
- **Exclude:** Rendering (get panel image).
171+
172+
### Run a dashboard panel query
173+
174+
- **Context:** README.md (Run Panel Query)
175+
- **Include:** Enabling runpanelquery, executing a panel query with time range and variable overrides.
176+
- **Exclude:** Writing new queries in Prometheus/Loki tools.
177+
178+
### Use Grafana Incident and Sift
179+
180+
- **Context:** README.md (Incidents, Sift Investigations)
181+
- **Include:** List/create/update incidents; list investigations, find error patterns, find slow requests. Viewer vs Editor role.
182+
- **Exclude:** OnCall schedules (separate).
183+
55184
## Developer
56185

57186
Output developer docs to `docs/sources/developer/`.
@@ -61,3 +190,15 @@ Cover public user SDKs and APIs.
61190
Create individual articles for each SDK or API.
62191
Put SDKs before APIs.
63192
Order articles from most popular language or framework to least.
193+
194+
### Go SDK (programmatic use)
195+
196+
- **Context:** README.md (Programmatic Usage, TLS), pkg.go.dev reference
197+
- **Include:** Using the library in Go; ComposedStdioContextFunc, GrafanaConfig, TLSConfig. Link to pkg.go.dev.
198+
- **Exclude:** HTTP API of the server (no public HTTP API for end users).
199+
200+
### Observability (metrics and tracing)
201+
202+
- **Context:** README.md (Observability)
203+
- **Include:** --metrics, --metrics-address; Prometheus metrics (mcp_server_operation_duration_seconds, etc.). OTEL env vars and tracing.
204+
- **Exclude:** Grafana datasource setup for metrics (out of scope).

docs/docs.mk

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# The source of this file is https://raw.githubusercontent.com/grafana/writers-toolkit/main/docs/docs.mk.
2+
# A changelog is included in the head of the `make-docs` script.
3+
include variables.mk
4+
-include variables.mk.local
5+
6+
.ONESHELL:
7+
.DELETE_ON_ERROR:
8+
export SHELL := bash
9+
export SHELLOPTS := pipefail:errexit
10+
MAKEFLAGS += --warn-undefined-variables
11+
MAKEFLAGS += --no-builtin-rule
12+
13+
.DEFAULT_GOAL: help
14+
15+
# Adapted from https://www.thapaliya.com/en/writings/well-documented-makefiles/
16+
.PHONY: help
17+
help: ## Display this help.
18+
help:
19+
@awk 'BEGIN { \
20+
FS = ": ##"; \
21+
printf "Usage:\n make <target>\n\nTargets:\n" \
22+
} \
23+
/^[a-zA-Z0-9_\.\-\/%]+: ##/ { printf " %-15s %s\n", $$1, $$2 }' \
24+
$(MAKEFILE_LIST)
25+
26+
GIT_ROOT := $(shell git rev-parse --show-toplevel)
27+
28+
PODMAN := $(shell if command -v podman >/dev/null 2>&1; then echo podman; else echo docker; fi)
29+
30+
ifeq ($(PROJECTS),)
31+
$(error "PROJECTS variable must be defined in variables.mk")
32+
endif
33+
34+
# Host port to publish container port to.
35+
ifeq ($(origin DOCS_HOST_PORT), undefined)
36+
export DOCS_HOST_PORT := 3002
37+
endif
38+
39+
# Container image used to perform Hugo build.
40+
ifeq ($(origin DOCS_IMAGE), undefined)
41+
export DOCS_IMAGE := grafana/docs-base:latest
42+
endif
43+
44+
# Container image used for Vale linting.
45+
ifeq ($(origin VALE_IMAGE), undefined)
46+
export VALE_IMAGE := grafana/vale:latest
47+
endif
48+
49+
# PATH-like list of directories within which to find projects.
50+
# If all projects are checked out into the same directory, ~/repos/ for example, then the default should work.
51+
ifeq ($(origin REPOS_PATH), undefined)
52+
export REPOS_PATH := $(realpath $(GIT_ROOT)/..)
53+
endif
54+
55+
# How to treat Hugo relref errors.
56+
ifeq ($(origin HUGO_REFLINKSERRORLEVEL), undefined)
57+
export HUGO_REFLINKSERRORLEVEL := WARNING
58+
endif
59+
60+
# Whether to pull the latest container image before running the container.
61+
ifeq ($(origin PULL), undefined)
62+
export PULL := true
63+
endif
64+
65+
.PHONY: docs-rm
66+
docs-rm: ## Remove the docs container.
67+
$(PODMAN) rm -f $(DOCS_CONTAINER)
68+
69+
.PHONY: docs-pull
70+
docs-pull: ## Pull documentation base image.
71+
$(PODMAN) pull -q $(DOCS_IMAGE)
72+
73+
make-docs: ## Fetch the latest make-docs script.
74+
make-docs:
75+
if [[ ! -f "$(CURDIR)/make-docs" ]]; then
76+
echo 'WARN: No make-docs script found in the working directory. Run `make update` to download it.' >&2
77+
exit 1
78+
fi
79+
80+
.PHONY: docs
81+
docs: ## Serve documentation locally, which includes pulling the latest `DOCS_IMAGE` (default: `grafana/docs-base:latest`) container image. To not pull the image, set `PULL=false`.
82+
ifeq ($(PULL), true)
83+
docs: docs-pull make-docs
84+
else
85+
docs: make-docs
86+
endif
87+
$(CURDIR)/make-docs $(PROJECTS)
88+
89+
.PHONY: docs-debug
90+
docs-debug: ## Run Hugo web server with debugging enabled. TODO: support all SERVER_FLAGS defined in website Makefile.
91+
docs-debug: make-docs
92+
WEBSITE_EXEC='hugo server --bind 0.0.0.0 --port 3002 --logLevel debug' $(CURDIR)/make-docs $(PROJECTS)
93+
94+
.PHONY: vale
95+
vale: ## Run vale on the entire docs folder which includes pulling the latest `VALE_IMAGE` (default: `grafana/vale:latest`) container image. To not pull the image, set `PULL=false`.
96+
vale: make-docs
97+
ifeq ($(PULL), true)
98+
$(PODMAN) pull -q $(VALE_IMAGE)
99+
endif
100+
DOCS_IMAGE=$(VALE_IMAGE) $(CURDIR)/make-docs $(PROJECTS)
101+
102+
.PHONY: update
103+
update: ## Fetch the latest version of this Makefile and the `make-docs` script from Writers' Toolkit.
104+
curl -s -LO https://raw.githubusercontent.com/grafana/writers-toolkit/main/docs/docs.mk
105+
curl -s -LO https://raw.githubusercontent.com/grafana/writers-toolkit/main/docs/make-docs
106+
chmod +x make-docs
107+
108+
# ls static/templates/ | sed 's/-template\.md//' | xargs
109+
TOPIC_TYPES := concept multiple-tasks reference section task tutorial visualization
110+
.PHONY: $(patsubst %,topic/%,$(TOPIC_TYPES))
111+
topic/%: ## Create a topic from the Writers' Toolkit template. Specify the topic type as the target, for example, `make topic/task TOPIC_PATH=sources/my-new-topic.md`.
112+
$(patsubst %,topic/%,$(TOPIC_TYPES)):
113+
$(if $(TOPIC_PATH),,$(error "You must set the TOPIC_PATH variable to the path where the $(@F) topic will be created. For example: make $(@) TOPIC_PATH=sources/my-new-topic.md"))
114+
mkdir -p $(dir $(TOPIC_PATH))
115+
curl -s -o $(TOPIC_PATH) https://raw.githubusercontent.com/grafana/writers-toolkit/refs/heads/main/docs/static/templates/$(@F)-template.md

0 commit comments

Comments
 (0)