You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit adds the ability to customise tools using `mcp.ToolOption`s,
then updates all calls to `MustTool` to include a title annotation,
which can be displayed in any UIs instead of the non-human-friendly
name.
Co-authored-by: Luccas Quadros <[email protected]>
@@ -148,6 +149,7 @@ var ListAlertRules = mcpgrafana.MustTool(
148
149
"list_alert_rules",
149
150
"Lists Grafana alert rules, returning a summary including UID, title, current state (e.g., 'pending', 'firing', 'inactive'), and labels. Supports filtering by labels using selectors and pagination. Example label selector: `[{'name': 'severity', 'type': '=', 'value': 'critical'}]`. Inactive state means the alert state is normal, not firing",
150
151
listAlertRules,
152
+
mcp.WithTitleAnnotation("List alert rules"),
151
153
)
152
154
153
155
typeGetAlertRuleByUIDParamsstruct {
@@ -179,6 +181,7 @@ var GetAlertRuleByUID = mcpgrafana.MustTool(
179
181
"get_alert_rule_by_uid",
180
182
"Retrieves the full configuration and detailed status of a specific Grafana alert rule identified by its unique ID (UID). The response includes fields like title, condition, query data, folder UID, rule group, state settings (no data, error), evaluation interval, annotations, and labels.",
@@ -252,6 +255,7 @@ var ListContactPoints = mcpgrafana.MustTool(
252
255
"list_contact_points",
253
256
"Lists Grafana notification contact points, returning a summary including UID, name, and type for each. Supports filtering by name - exact match - and limiting the number of results.",
@@ -54,12 +55,14 @@ var GetDashboardByUID = mcpgrafana.MustTool(
54
55
"get_dashboard_by_uid",
55
56
"Retrieves the complete dashboard, including panels, variables, and settings, for a specific dashboard identified by its UID.",
56
57
getDashboardByUID,
58
+
mcp.WithTitleAnnotation("Get dashboard details"),
57
59
)
58
60
59
61
varUpdateDashboard=mcpgrafana.MustTool(
60
62
"update_dashboard",
61
63
"Create or update a dashboard",
62
64
updateDashboard,
65
+
mcp.WithTitleAnnotation("Create or update dashboard"),
63
66
)
64
67
65
68
typeDashboardPanelQueriesParamsstruct {
@@ -140,6 +143,7 @@ var GetDashboardPanelQueries = mcpgrafana.MustTool(
140
143
"get_dashboard_panel_queries",
141
144
"Get the title, query string, and datasource information for each panel in a dashboard. The datasource is an object with fields `uid` (which may be a concrete UID or a template variable like \"$datasource\") and `type`. If the datasource UID is a template variable, it won't be usable directly for queries. Returns an array of objects, each representing a panel, with fields: title, query, and datasource (an object with uid and type).",
@@ -67,6 +68,7 @@ var ListDatasources = mcpgrafana.MustTool(
67
68
"list_datasources",
68
69
"List available Grafana datasources. Optionally filter by datasource type (e.g., 'prometheus', 'loki'). Returns a summary list including ID, UID, name, type, and default status.",
69
70
listDatasources,
71
+
mcp.WithTitleAnnotation("List datasources"),
70
72
)
71
73
72
74
typeGetDatasourceByUIDParamsstruct {
@@ -90,6 +92,7 @@ var GetDatasourceByUID = mcpgrafana.MustTool(
90
92
"get_datasource_by_uid",
91
93
"Retrieves detailed information about a specific datasource using its UID. Returns the full datasource model, including name, type, URL, access settings, JSON data, and secure JSON field status.",
92
94
getDatasourceByUID,
95
+
mcp.WithTitleAnnotation("Get datasource by UID"),
93
96
)
94
97
95
98
typeGetDatasourceByNameParamsstruct {
@@ -109,6 +112,7 @@ var GetDatasourceByName = mcpgrafana.MustTool(
109
112
"get_datasource_by_name",
110
113
"Retrieves detailed information about a specific datasource using its name. Returns the full datasource model, including UID, type, URL, access settings, JSON data, and secure JSON field status.",
111
114
getDatasourceByName,
115
+
mcp.WithTitleAnnotation("Get datasource by name"),
Copy file name to clipboardExpand all lines: tools/incident.go
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ import (
6
6
7
7
"github.com/grafana/incident-go"
8
8
mcpgrafana "github.com/grafana/mcp-grafana"
9
+
"github.com/mark3labs/mcp-go/mcp"
9
10
"github.com/mark3labs/mcp-go/server"
10
11
)
11
12
@@ -49,6 +50,7 @@ var ListIncidents = mcpgrafana.MustTool(
49
50
"list_incidents",
50
51
"List Grafana incidents. Allows filtering by status ('active', 'resolved') and optionally including drill incidents. Returns a preview list with basic details.",
51
52
listIncidents,
53
+
mcp.WithTitleAnnotation("List incidents"),
52
54
)
53
55
54
56
typeCreateIncidentParamsstruct {
@@ -85,6 +87,7 @@ var CreateIncident = mcpgrafana.MustTool(
85
87
"create_incident",
86
88
"Create a new Grafana incident. Requires title, severity, and room prefix. Allows setting status and labels. This tool should be used judiciously and sparingly, and only after confirmation from the user, as it may notify or alarm lots of people.",
87
89
createIncident,
90
+
mcp.WithTitleAnnotation("Create incident"),
88
91
)
89
92
90
93
typeAddActivityToIncidentParamsstruct {
@@ -112,6 +115,7 @@ var AddActivityToIncident = mcpgrafana.MustTool(
112
115
"add_activity_to_incident",
113
116
"Add a note (userNote activity) to an existing incident's timeline using its ID. The note body can include URLs which will be attached as context. Use this to add context to an incident.",
114
117
addActivityToIncident,
118
+
mcp.WithTitleAnnotation("Add activity to incident"),
115
119
)
116
120
117
121
funcAddIncidentTools(mcp*server.MCPServer) {
@@ -143,4 +147,5 @@ var GetIncident = mcpgrafana.MustTool(
143
147
"get_incident",
144
148
"Get a single incident by ID. Returns the full incident details including title, status, severity, labels, timestamps, and other metadata.",
Copy file name to clipboardExpand all lines: tools/loki.go
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ import (
13
13
"time"
14
14
15
15
mcpgrafana "github.com/grafana/mcp-grafana"
16
+
"github.com/mark3labs/mcp-go/mcp"
16
17
"github.com/mark3labs/mcp-go/server"
17
18
)
18
19
@@ -222,6 +223,7 @@ var ListLokiLabelNames = mcpgrafana.MustTool(
222
223
"list_loki_label_names",
223
224
"Lists all available label names (keys) found in logs within a specified Loki datasource and time range. Returns a list of unique label strings (e.g., `[\"app\", \"env\", \"pod\"]`). If the time range is not provided, it defaults to the last hour.",
224
225
listLokiLabelNames,
226
+
mcp.WithTitleAnnotation("List Loki label names"),
225
227
)
226
228
227
229
// ListLokiLabelValuesParams defines the parameters for listing Loki label values
@@ -260,6 +262,7 @@ var ListLokiLabelValues = mcpgrafana.MustTool(
260
262
"list_loki_label_values",
261
263
"Retrieves all unique values associated with a specific `labelName` within a Loki datasource and time range. Returns a list of string values (e.g., for `labelName=\"env\"`, might return `[\"prod\", \"staging\", \"dev\"]`). Useful for discovering filter options. Defaults to the last hour if the time range is omitted.",
// LogStream represents a stream of log entries from Loki
@@ -467,6 +470,7 @@ var QueryLokiLogs = mcpgrafana.MustTool(
467
470
"query_loki_logs",
468
471
"Executes a LogQL query against a Loki datasource to retrieve log entries or metric values. Returns a list of results, each containing a timestamp, labels, and either a log line (`line`) or a numeric metric value (`value`). Defaults to the last hour, a limit of 10 entries, and 'backward' direction (newest first). Supports full LogQL syntax for log and metric queries (e.g., `{app=\"foo\"} |= \"error\"`, `rate({app=\"bar\"}[1m])`). Prefer using `query_loki_stats` first to check stream size and `list_loki_label_names` and `list_loki_label_values` to verify labels exist.",
469
472
queryLokiLogs,
473
+
mcp.WithTitleAnnotation("Query Loki logs"),
470
474
)
471
475
472
476
// fetchStats is a method to fetch stats data from Loki API
@@ -524,6 +528,7 @@ var QueryLokiStats = mcpgrafana.MustTool(
524
528
"query_loki_stats",
525
529
"Retrieves statistics about log streams matching a given LogQL *selector* within a Loki datasource and time range. Returns an object containing the count of streams, chunks, entries, and total bytes (e.g., `{\"streams\": 5, \"chunks\": 50, \"entries\": 10000, \"bytes\": 512000}`). The `logql` parameter **must** be a simple label selector (e.g., `{app=\"nginx\", env=\"prod\"}`) and does not support line filters, parsers, or aggregations. Defaults to the last hour if the time range is omitted.",
Copy file name to clipboardExpand all lines: tools/oncall.go
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ import (
9
9
10
10
aapi "github.com/grafana/amixr-api-go-client"
11
11
mcpgrafana "github.com/grafana/mcp-grafana"
12
+
"github.com/mark3labs/mcp-go/mcp"
12
13
"github.com/mark3labs/mcp-go/server"
13
14
)
14
15
@@ -192,6 +193,7 @@ var ListOnCallSchedules = mcpgrafana.MustTool(
192
193
"list_oncall_schedules",
193
194
"List Grafana OnCall schedules, optionally filtering by team ID. If a specific schedule ID is provided, retrieves details for only that schedule. Returns a list of schedule summaries including ID, name, team ID, timezone, and shift IDs. Supports pagination.",
194
195
listOnCallSchedules,
196
+
mcp.WithTitleAnnotation("List OnCall schedules"),
195
197
)
196
198
197
199
typeGetOnCallShiftParamsstruct {
@@ -216,6 +218,7 @@ var GetOnCallShift = mcpgrafana.MustTool(
216
218
"get_oncall_shift",
217
219
"Get detailed information for a specific Grafana OnCall shift using its ID. A shift represents a designated time period within a schedule when users are actively on-call. Returns the full shift details.",
218
220
getOnCallShift,
221
+
mcp.WithTitleAnnotation("Get OnCall shift"),
219
222
)
220
223
221
224
// CurrentOnCallUsers represents the currently on-call users for a schedule
@@ -276,6 +279,7 @@ var GetCurrentOnCallUsers = mcpgrafana.MustTool(
276
279
"get_current_oncall_users",
277
280
"Get the list of users currently on-call for a specific Grafana OnCall schedule ID. Returns the schedule ID, name, and a list of detailed user objects for those currently on call.",
278
281
getCurrentOnCallUsers,
282
+
mcp.WithTitleAnnotation("Get current on-call users"),
279
283
)
280
284
281
285
typeListOnCallTeamsParamsstruct {
@@ -305,6 +309,7 @@ var ListOnCallTeams = mcpgrafana.MustTool(
305
309
"list_oncall_teams",
306
310
"List teams configured in Grafana OnCall. Returns a list of team objects with their details. Supports pagination.",
307
311
listOnCallTeams,
312
+
mcp.WithTitleAnnotation("List OnCall teams"),
308
313
)
309
314
310
315
typeListOnCallUsersParamsstruct {
@@ -348,6 +353,7 @@ var ListOnCallUsers = mcpgrafana.MustTool(
348
353
"list_oncall_users",
349
354
"List users from Grafana OnCall. Can retrieve all users, a specific user by ID, or filter by username. Returns a list of user objects with their details. Supports pagination.",
@@ -225,6 +228,7 @@ var ListPrometheusMetricNames = mcpgrafana.MustTool(
225
228
"list_prometheus_metric_names",
226
229
"List metric names in a Prometheus datasource. Retrieves all metric names and then filters them locally using the provided regex. Supports pagination.",
0 commit comments