@@ -42,7 +42,7 @@ type ListPrometheusMetricMetadataParams struct {
42
42
Metric string `json:"metric" jsonschema:"description=The metric to query"`
43
43
}
44
44
45
- func ListPrometheusMetricMetadata (ctx context.Context , args ListPrometheusMetricMetadataParams ) (* mcp.CallToolResult , error ) {
45
+ func listPrometheusMetricMetadata (ctx context.Context , args ListPrometheusMetricMetadataParams ) (* mcp.CallToolResult , error ) {
46
46
promClient , err := promClientFromContext (ctx , args .DatasourceUID )
47
47
if err != nil {
48
48
return nil , fmt .Errorf ("getting Prometheus client: %w" , err )
@@ -64,10 +64,10 @@ func ListPrometheusMetricMetadata(ctx context.Context, args ListPrometheusMetric
64
64
return mcp .NewToolResultText (string (b )), nil
65
65
}
66
66
67
- var ListPrometheusMetricMetadataTool , ListPrometheusMetricMetadataHandler = mcpgrafana .MustTool (
67
+ var ListPrometheusMetricMetadata = mcpgrafana .MustTool (
68
68
"list_prometheus_metric_metadata" ,
69
69
"List Prometheus metric metadata" ,
70
- ListPrometheusMetricMetadata ,
70
+ listPrometheusMetricMetadata ,
71
71
)
72
72
73
73
type QueryPrometheusParams struct {
@@ -79,7 +79,7 @@ type QueryPrometheusParams struct {
79
79
QueryType string `json:"queryType,omitempty" jsonschema:"description=The type of query to use. Either 'range' or 'instant'"`
80
80
}
81
81
82
- func QueryPrometheus (ctx context.Context , args QueryPrometheusParams ) (* mcp.CallToolResult , error ) {
82
+ func queryPrometheus (ctx context.Context , args QueryPrometheusParams ) (* mcp.CallToolResult , error ) {
83
83
promClient , err := promClientFromContext (ctx , args .DatasourceUID )
84
84
if err != nil {
85
85
return nil , fmt .Errorf ("getting Prometheus client: %w" , err )
@@ -136,10 +136,10 @@ func QueryPrometheus(ctx context.Context, args QueryPrometheusParams) (*mcp.Call
136
136
return nil , fmt .Errorf ("invalid query type: %s" , queryType )
137
137
}
138
138
139
- var QueryPrometheusTool , QueryPrometheusHandler = mcpgrafana .MustTool (
139
+ var QueryPrometheus = mcpgrafana .MustTool (
140
140
"query_prometheus" ,
141
141
"Query Prometheus using a range or instant request" ,
142
- QueryPrometheus ,
142
+ queryPrometheus ,
143
143
)
144
144
145
145
type ListPrometheusMetricNamesParams struct {
@@ -149,7 +149,7 @@ type ListPrometheusMetricNamesParams struct {
149
149
Page int `json:"page,omitempty" jsonschema:"description=The page number to return"`
150
150
}
151
151
152
- func ListPrometheusMetricNames (ctx context.Context , args ListPrometheusMetricNamesParams ) (* mcp.CallToolResult , error ) {
152
+ func listPrometheusMetricNames (ctx context.Context , args ListPrometheusMetricNamesParams ) (* mcp.CallToolResult , error ) {
153
153
promClient , err := promClientFromContext (ctx , args .DatasourceUID )
154
154
if err != nil {
155
155
return nil , fmt .Errorf ("getting Prometheus client: %w" , err )
@@ -207,10 +207,10 @@ func ListPrometheusMetricNames(ctx context.Context, args ListPrometheusMetricNam
207
207
return mcp .NewToolResultText (string (b )), nil
208
208
}
209
209
210
- var ListPrometheusMetricNamesTool , ListPrometheusMetricNamesHandler = mcpgrafana .MustTool (
210
+ var ListPrometheusMetricNames = mcpgrafana .MustTool (
211
211
"list_prometheus_metric_names" ,
212
212
"List metric names in a Prometheus datasource that match the given regex" ,
213
- ListPrometheusMetricNames ,
213
+ listPrometheusMetricNames ,
214
214
)
215
215
216
216
type LabelMatcher struct {
@@ -244,7 +244,7 @@ type ListPrometheusLabelNamesParams struct {
244
244
Limit int `json:"limit,omitempty" jsonschema:"description=Optionally, the maximum number of results to return"`
245
245
}
246
246
247
- func ListPrometheusLabelNames (ctx context.Context , args ListPrometheusLabelNamesParams ) (* mcp.CallToolResult , error ) {
247
+ func listPrometheusLabelNames (ctx context.Context , args ListPrometheusLabelNamesParams ) (* mcp.CallToolResult , error ) {
248
248
promClient , err := promClientFromContext (ctx , args .DatasourceUID )
249
249
if err != nil {
250
250
return nil , fmt .Errorf ("getting Prometheus client: %w" , err )
@@ -289,10 +289,10 @@ func ListPrometheusLabelNames(ctx context.Context, args ListPrometheusLabelNames
289
289
return mcp .NewToolResultText (string (b )), nil
290
290
}
291
291
292
- var ListPrometheusLabelNamesTool , ListPrometheusLabelNamesHandler = mcpgrafana .MustTool (
292
+ var ListPrometheusLabelNames = mcpgrafana .MustTool (
293
293
"list_prometheus_label_names" ,
294
294
"List the label names in a Prometheus datasource" ,
295
- ListPrometheusLabelNames ,
295
+ listPrometheusLabelNames ,
296
296
)
297
297
298
298
type ListPrometheusLabelValuesParams struct {
@@ -304,7 +304,7 @@ type ListPrometheusLabelValuesParams struct {
304
304
Limit int `json:"limit,omitempty" jsonschema:"description=Optionally, the maximum number of results to return"`
305
305
}
306
306
307
- func ListPrometheusLabelValues (ctx context.Context , args ListPrometheusLabelValuesParams ) (* mcp.CallToolResult , error ) {
307
+ func listPrometheusLabelValues (ctx context.Context , args ListPrometheusLabelValuesParams ) (* mcp.CallToolResult , error ) {
308
308
promClient , err := promClientFromContext (ctx , args .DatasourceUID )
309
309
if err != nil {
310
310
return nil , fmt .Errorf ("getting Prometheus client: %w" , err )
@@ -349,16 +349,16 @@ func ListPrometheusLabelValues(ctx context.Context, args ListPrometheusLabelValu
349
349
return mcp .NewToolResultText (string (b )), nil
350
350
}
351
351
352
- var ListPrometheusLabelValuesTool , ListPrometheusLabelValuesHandler = mcpgrafana .MustTool (
352
+ var ListPrometheusLabelValues = mcpgrafana .MustTool (
353
353
"list_prometheus_label_values" ,
354
354
"Get the values of a label in Prometheus" ,
355
- ListPrometheusLabelValues ,
355
+ listPrometheusLabelValues ,
356
356
)
357
357
358
358
func AddPrometheusTools (mcp * server.MCPServer ) {
359
- mcp . AddTool ( ListPrometheusMetricMetadataTool , ListPrometheusMetricMetadataHandler )
360
- mcp . AddTool ( QueryPrometheusTool , QueryPrometheusHandler )
361
- mcp . AddTool ( ListPrometheusMetricNamesTool , ListPrometheusMetricNamesHandler )
362
- mcp . AddTool ( ListPrometheusLabelNamesTool , ListPrometheusLabelNamesHandler )
363
- mcp . AddTool ( ListPrometheusLabelValuesTool , ListPrometheusLabelValuesHandler )
359
+ ListPrometheusMetricMetadata . Register ( mcp )
360
+ QueryPrometheus . Register ( mcp )
361
+ ListPrometheusMetricNames . Register ( mcp )
362
+ ListPrometheusLabelNames . Register ( mcp )
363
+ ListPrometheusLabelValues . Register ( mcp )
364
364
}
0 commit comments