@daanrongen/grafana-mcp 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -0
- package/dist/main.js +44833 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# grafana-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [Grafana](https://grafana.com/) — manage dashboards, datasources, alert rules, folders, and annotations over stdio.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx -y @daanrongen/grafana-mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Tools (17 total)
|
|
12
|
+
|
|
13
|
+
| Domain | Tools | Coverage |
|
|
14
|
+
| --------------- | --------------------------------------------------------------------------------------- | ---------------------------------------------------- |
|
|
15
|
+
| **Dashboards** | `list_dashboards`, `get_dashboard`, `create_dashboard`, `update_dashboard`, `delete_dashboard` | Full dashboard lifecycle |
|
|
16
|
+
| **Datasources** | `list_datasources`, `get_datasource`, `create_datasource`, `delete_datasource` | Datasource management |
|
|
17
|
+
| **Alerts** | `list_alert_rules`, `get_alert_rule`, `list_alert_instances` | Alert rules and firing Alertmanager instances |
|
|
18
|
+
| **Folders** | `list_folders`, `create_folder`, `delete_folder` | Folder organisation |
|
|
19
|
+
| **Annotations** | `list_annotations`, `create_annotation` | Dashboard and global annotations |
|
|
20
|
+
| **Health** | `health_check` | Grafana instance status |
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
### Environment variables
|
|
25
|
+
|
|
26
|
+
| Variable | Required | Description |
|
|
27
|
+
| ----------------- | -------- | --------------------------------------------------- |
|
|
28
|
+
| `GRAFANA_URL` | Yes | Grafana base URL (e.g. `http://localhost:3000`) |
|
|
29
|
+
| `GRAFANA_API_KEY` | Yes | Grafana service account token or API key |
|
|
30
|
+
|
|
31
|
+
### Claude Desktop
|
|
32
|
+
|
|
33
|
+
Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"grafana": {
|
|
39
|
+
"type": "stdio",
|
|
40
|
+
"command": "npx",
|
|
41
|
+
"args": ["-y", "@daanrongen/grafana-mcp"],
|
|
42
|
+
"env": {
|
|
43
|
+
"GRAFANA_URL": "http://localhost:3000",
|
|
44
|
+
"GRAFANA_API_KEY": "your-service-account-token"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or via the CLI:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
claude mcp add grafana \
|
|
55
|
+
-e GRAFANA_URL=http://localhost:3000 \
|
|
56
|
+
-e GRAFANA_API_KEY=your-service-account-token \
|
|
57
|
+
-- npx -y @daanrongen/grafana-mcp
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
bun install
|
|
64
|
+
bun run dev # run with --watch
|
|
65
|
+
bun test # run test suite
|
|
66
|
+
bun run build # bundle to dist/main.js
|
|
67
|
+
bun run inspect # open MCP Inspector in browser
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Architecture
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
src/
|
|
74
|
+
├── config.ts # Effect Config — GRAFANA_URL, GRAFANA_API_KEY
|
|
75
|
+
├── main.ts # Entry point — ManagedRuntime + StdioServerTransport
|
|
76
|
+
├── domain/
|
|
77
|
+
│ ├── GrafanaClient.ts # Context.Tag service interface
|
|
78
|
+
│ ├── errors.ts # GrafanaError, NotFoundError
|
|
79
|
+
│ └── models.ts # Schema.Class models (Dashboard, Datasource, AlertRule, …)
|
|
80
|
+
├── infra/
|
|
81
|
+
│ ├── GrafanaClientLive.ts # Layer using fetch against the Grafana HTTP API
|
|
82
|
+
│ └── GrafanaClientTest.ts # In-memory Ref-based test adapter
|
|
83
|
+
└── mcp/
|
|
84
|
+
├── server.ts # McpServer wired to ManagedRuntime
|
|
85
|
+
├── utils.ts # formatSuccess, formatError
|
|
86
|
+
└── tools/ # dashboards.ts, datasources.ts, alerts.ts, folders.ts, annotations.ts, health.ts
|
|
87
|
+
```
|