|
| 1 | +# grafana MCP Server |
| 2 | + |
| 3 | +MCP server for Grafana |
| 4 | + |
| 5 | +[What is an MCP Server?](https://www.anthropic.com/news/model-context-protocol) |
| 6 | + |
| 7 | +|<!-- -->|<!-- -->| |
| 8 | +|-|-| |
| 9 | +**Image Source**|Official Image |
| 10 | +|**Author**|[grafana](https://github.com/grafana) |
| 11 | +**Repository**|https://github.com/grafana/mcp-grafana |
| 12 | +**Dockerfile**|https://github.com/grafana/mcp-grafana/blob/main/Dockerfile |
| 13 | +**Docker Image built by**|Docker Inc. |
| 14 | +**Licence**|Apache License 2.0 |
| 15 | + |
| 16 | +## Summary |
| 17 | +1. `add_activity_to_incident` Add a note to an incident's timeline. |
| 18 | +1. `create_incident` Create an incident |
| 19 | +1. `get_alert_rule_by_uid` Retrieves detailed information about a specific alert rule by its UID. |
| 20 | +1. `get_current_oncall_users` Get users currently on-call for a specific schedule. |
| 21 | +1. `get_dashboard_by_uid` Get dashboard by uid |
| 22 | +1. `get_datasource_by_name` Get datasource by name |
| 23 | +1. `get_datasource_by_uid` Get datasource by uid |
| 24 | +1. `get_incident` Get a single incident by ID. |
| 25 | +1. `get_oncall_shift` Get details for a specific OnCall shift. |
| 26 | +1. `list_alert_rules` Lists alert rules with their current states (pending, firing, error, recovering, inactive) and labels. |
| 27 | +1. `list_contact_points` Lists notification contact points with their type, name, and configuration. |
| 28 | +1. `list_datasources` List datasources |
| 29 | +1. `list_incidents` List incidents |
| 30 | +1. `list_loki_label_names` List all available label names in a Loki datasource for the given time range. |
| 31 | +1. `list_loki_label_values` Retrieve all possible values for a specific label in Loki within the given time range. |
| 32 | +1. `list_oncall_schedules` List OnCall schedules. |
| 33 | +1. `list_oncall_teams` List teams from Grafana OnCall |
| 34 | +1. `list_oncall_users` List users from Grafana OnCall. |
| 35 | +1. `list_prometheus_label_names` List the label names in a Prometheus datasource |
| 36 | +1. `list_prometheus_label_values` Get the values of a label in Prometheus |
| 37 | +1. `list_prometheus_metric_metadata` List Prometheus metric metadata |
| 38 | +1. `list_prometheus_metric_names` List metric names in a Prometheus datasource that match the given regex |
| 39 | +1. `query_loki_logs` Query and retrieve log entries or metric values from a Loki datasource using LogQL. |
| 40 | +1. `query_loki_stats` Query statistics about log streams in a Loki datasource, using LogQL selectors to select streams |
| 41 | +1. `query_prometheus` Query Prometheus using a range or instant request |
| 42 | +1. `search_dashboards` Search for dashboards |
| 43 | + |
| 44 | +## Tools |
| 45 | + |
| 46 | +### Tool `add_activity_to_incident` |
| 47 | +Add a note to an incident's timeline. The note will appear in the incident's activity feed. Use this if there is a request to add context to an incident with a note. |
| 48 | + |
| 49 | +Parameter|Type|Description |
| 50 | +-|-|- |
| 51 | +`body`|`string` *optional*|The body of the activity. URLs will be parsed and attached as context |
| 52 | +`eventTime`|`string` *optional*|The time that the activity occurred. If not provided |
| 53 | +`incidentId`|`string` *optional*|The ID of the incident to add the activity to |
| 54 | + |
| 55 | +### Tool `create_incident` |
| 56 | +Create an incident |
| 57 | + |
| 58 | +Parameter|Type|Description |
| 59 | +-|-|- |
| 60 | +`attachCaption`|`string` *optional*|The caption of the attachment |
| 61 | +`attachUrl`|`string` *optional*|The URL of the attachment |
| 62 | +`isDrill`|`boolean` *optional*|Whether the incident is a drill incident |
| 63 | +`labels`|`array` *optional*|The labels to add to the incident |
| 64 | +`roomPrefix`|`string` *optional*|The prefix of the room to create the incident in |
| 65 | +`severity`|`string` *optional*|The severity of the incident |
| 66 | +`status`|`string` *optional*|The status of the incident |
| 67 | +`title`|`string` *optional*|The title of the incident |
| 68 | + |
| 69 | +### Tool `get_alert_rule_by_uid` |
| 70 | +Retrieves detailed information about a specific alert rule by its UID. |
| 71 | + |
| 72 | +Parameter|Type|Description |
| 73 | +-|-|- |
| 74 | +`uid`|`string`|The uid of the alert rule |
| 75 | + |
| 76 | +### Tool `get_current_oncall_users` |
| 77 | +Get users currently on-call for a specific schedule. A schedule is a calendar-based system defining when team members are on-call. This tool will return info about all users currently on-call for the schedule, regardless of team. |
| 78 | + |
| 79 | +Parameter|Type|Description |
| 80 | +-|-|- |
| 81 | +`scheduleId`|`string`|The ID of the schedule to get current on-call users for |
| 82 | + |
| 83 | +### Tool `get_dashboard_by_uid` |
| 84 | +Get dashboard by uid |
| 85 | + |
| 86 | +Parameter|Type|Description |
| 87 | +-|-|- |
| 88 | +`uid`|`string`|The UID of the dashboard |
| 89 | + |
| 90 | +### Tool `get_datasource_by_name` |
| 91 | +Get datasource by name |
| 92 | + |
| 93 | +Parameter|Type|Description |
| 94 | +-|-|- |
| 95 | +`name`|`string`|The name of the datasource |
| 96 | + |
| 97 | +### Tool `get_datasource_by_uid` |
| 98 | +Get datasource by uid |
| 99 | + |
| 100 | +Parameter|Type|Description |
| 101 | +-|-|- |
| 102 | +`uid`|`string`|The uid of the datasource |
| 103 | + |
| 104 | +### Tool `get_incident` |
| 105 | +Get a single incident by ID. Returns the full incident details including title, status, severity, and other metadata. |
| 106 | + |
| 107 | +Parameter|Type|Description |
| 108 | +-|-|- |
| 109 | +`id`|`string` *optional*|The ID of the incident to retrieve |
| 110 | + |
| 111 | +### Tool `get_oncall_shift` |
| 112 | +Get details for a specific OnCall shift. A shift represents a designated time period within a rotation when a team or individual is actively on-call |
| 113 | + |
| 114 | +Parameter|Type|Description |
| 115 | +-|-|- |
| 116 | +`shiftId`|`string`|The ID of the shift to get details for |
| 117 | + |
| 118 | +### Tool `list_alert_rules` |
| 119 | +Lists alert rules with their current states (pending, firing, error, recovering, inactive) and labels. Inactive state means the alert state is normal, not firing. |
| 120 | + |
| 121 | +Parameter|Type|Description |
| 122 | +-|-|- |
| 123 | +`label_selectors`|`array` *optional*|Optionally |
| 124 | +`limit`|`integer` *optional*|The maximum number of results to return. Default is 100. |
| 125 | +`page`|`integer` *optional*|The page number to return. |
| 126 | + |
| 127 | +### Tool `list_contact_points` |
| 128 | +Lists notification contact points with their type, name, and configuration. |
| 129 | + |
| 130 | +Parameter|Type|Description |
| 131 | +-|-|- |
| 132 | +`limit`|`integer` *optional*|The maximum number of results to return. Default is 100. |
| 133 | +`name`|`string` *optional*|Filter contact points by name |
| 134 | + |
| 135 | +### Tool `list_datasources` |
| 136 | +List datasources |
| 137 | + |
| 138 | +Parameter|Type|Description |
| 139 | +-|-|- |
| 140 | +`type`|`string` *optional*|The type of datasources to search for. For example |
| 141 | + |
| 142 | +### Tool `list_incidents` |
| 143 | +List incidents |
| 144 | + |
| 145 | +Parameter|Type|Description |
| 146 | +-|-|- |
| 147 | +`drill`|`boolean` *optional*|Whether to include drill incidents |
| 148 | +`limit`|`integer` *optional*|The maximum number of incidents to return |
| 149 | +`status`|`string` *optional*|The status of the incidents to include. Valid values: 'active' |
| 150 | + |
| 151 | +### Tool `list_loki_label_names` |
| 152 | +List all available label names in a Loki datasource for the given time range. Returns the set of unique label keys found in the logs. |
| 153 | + |
| 154 | +Parameter|Type|Description |
| 155 | +-|-|- |
| 156 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 157 | +`endRfc3339`|`string` *optional*|Optionally |
| 158 | +`startRfc3339`|`string` *optional*|Optionally |
| 159 | + |
| 160 | +### Tool `list_loki_label_values` |
| 161 | +Retrieve all possible values for a specific label in Loki within the given time range. Useful for exploring available options for filtering logs. |
| 162 | + |
| 163 | +Parameter|Type|Description |
| 164 | +-|-|- |
| 165 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 166 | +`labelName`|`string`|The name of the label to retrieve values for (e.g. 'app' |
| 167 | +`endRfc3339`|`string` *optional*|Optionally |
| 168 | +`startRfc3339`|`string` *optional*|Optionally |
| 169 | + |
| 170 | +### Tool `list_oncall_schedules` |
| 171 | +List OnCall schedules. A schedule is a calendar-based system defining when team members are on-call. Optionally provide a scheduleId to get details for a specific schedule |
| 172 | + |
| 173 | +Parameter|Type|Description |
| 174 | +-|-|- |
| 175 | +`page`|`integer` *optional*|The page number to return (1-based) |
| 176 | +`scheduleId`|`string` *optional*|The ID of the schedule to get details for. If provided |
| 177 | +`teamId`|`string` *optional*|The ID of the team to list schedules for |
| 178 | + |
| 179 | +### Tool `list_oncall_teams` |
| 180 | +List teams from Grafana OnCall |
| 181 | + |
| 182 | +Parameter|Type|Description |
| 183 | +-|-|- |
| 184 | +`page`|`integer` *optional*|The page number to return |
| 185 | + |
| 186 | +### Tool `list_oncall_users` |
| 187 | +List users from Grafana OnCall. If user ID is provided, returns details for that specific user. If username is provided, returns the user matching that username |
| 188 | + |
| 189 | +Parameter|Type|Description |
| 190 | +-|-|- |
| 191 | +`page`|`integer` *optional*|The page number to return |
| 192 | +`userId`|`string` *optional*|The ID of the user to get details for. If provided |
| 193 | +`username`|`string` *optional*|The username to filter users by. If provided |
| 194 | + |
| 195 | +### Tool `list_prometheus_label_names` |
| 196 | +List the label names in a Prometheus datasource |
| 197 | + |
| 198 | +Parameter|Type|Description |
| 199 | +-|-|- |
| 200 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 201 | +`endRfc3339`|`string` *optional*|Optionally |
| 202 | +`limit`|`integer` *optional*|Optionally |
| 203 | +`matches`|`array` *optional*|Optionally |
| 204 | +`startRfc3339`|`string` *optional*|Optionally |
| 205 | + |
| 206 | +### Tool `list_prometheus_label_values` |
| 207 | +Get the values of a label in Prometheus |
| 208 | + |
| 209 | +Parameter|Type|Description |
| 210 | +-|-|- |
| 211 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 212 | +`labelName`|`string`|The name of the label to query |
| 213 | +`endRfc3339`|`string` *optional*|Optionally |
| 214 | +`limit`|`integer` *optional*|Optionally |
| 215 | +`matches`|`array` *optional*|Optionally |
| 216 | +`startRfc3339`|`string` *optional*|Optionally |
| 217 | + |
| 218 | +### Tool `list_prometheus_metric_metadata` |
| 219 | +List Prometheus metric metadata |
| 220 | + |
| 221 | +Parameter|Type|Description |
| 222 | +-|-|- |
| 223 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 224 | +`limit`|`integer` *optional*|The maximum number of metrics to return |
| 225 | +`limitPerMetric`|`integer` *optional*|The maximum number of metrics to return per metric |
| 226 | +`metric`|`string` *optional*|The metric to query |
| 227 | + |
| 228 | +### Tool `list_prometheus_metric_names` |
| 229 | +List metric names in a Prometheus datasource that match the given regex |
| 230 | + |
| 231 | +Parameter|Type|Description |
| 232 | +-|-|- |
| 233 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 234 | +`limit`|`integer` *optional*|The maximum number of results to return |
| 235 | +`page`|`integer` *optional*|The page number to return |
| 236 | +`regex`|`string` *optional*|The regex to match against the metric names |
| 237 | + |
| 238 | +### Tool `query_loki_logs` |
| 239 | +Query and retrieve log entries or metric values from a Loki datasource using LogQL. Returns either log lines or numeric values with timestamps and labels. Use `query_loki_stats` first to check stream size, then `list_loki_label_names` and `list_loki_label_values` to verify labels exist. Supports full LogQL syntax including both log queries and metric queries (e.g., rate, count_over_time). |
| 240 | + |
| 241 | +Parameter|Type|Description |
| 242 | +-|-|- |
| 243 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 244 | +`logql`|`string`|The LogQL query to execute against Loki. This can be a simple label matcher or a complex query with filters |
| 245 | +`direction`|`string` *optional*|Optionally |
| 246 | +`endRfc3339`|`string` *optional*|Optionally |
| 247 | +`limit`|`integer` *optional*|Optionally |
| 248 | +`startRfc3339`|`string` *optional*|Optionally |
| 249 | + |
| 250 | +### Tool `query_loki_stats` |
| 251 | +Query statistics about log streams in a Loki datasource, using LogQL selectors to select streams |
| 252 | + |
| 253 | +Parameter|Type|Description |
| 254 | +-|-|- |
| 255 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 256 | +`logql`|`string`|The LogQL matcher expression to execute. This parameter only accepts label matcher expressions and does not support full LogQL queries. Line filters |
| 257 | +`endRfc3339`|`string` *optional*|Optionally |
| 258 | +`startRfc3339`|`string` *optional*|Optionally |
| 259 | + |
| 260 | +### Tool `query_prometheus` |
| 261 | +Query Prometheus using a range or instant request |
| 262 | + |
| 263 | +Parameter|Type|Description |
| 264 | +-|-|- |
| 265 | +`datasourceUid`|`string`|The UID of the datasource to query |
| 266 | +`expr`|`string`|The PromQL expression to query |
| 267 | +`startRfc3339`|`string`|The start time in RFC3339 format |
| 268 | +`endRfc3339`|`string` *optional*|The end time in RFC3339 format. Required if queryType is 'range' |
| 269 | +`queryType`|`string` *optional*|The type of query to use. Either 'range' or 'instant' |
| 270 | +`stepSeconds`|`integer` *optional*|The time series step size in seconds. Required if queryType is 'range' |
| 271 | + |
| 272 | +### Tool `search_dashboards` |
| 273 | +Search for dashboards |
| 274 | + |
| 275 | +Parameter|Type|Description |
| 276 | +-|-|- |
| 277 | +`query`|`string` *optional*|The query to search for |
| 278 | + |
| 279 | +## Use this MCP Server |
| 280 | + |
| 281 | +```json |
| 282 | +{ |
| 283 | + "mcpServers": { |
| 284 | + "grafana": { |
| 285 | + "command": "docker", |
| 286 | + "args": [ |
| 287 | + "run", |
| 288 | + "-i", |
| 289 | + "--rm", |
| 290 | + "-e", |
| 291 | + "GRAFANA_URL", |
| 292 | + "-e", |
| 293 | + "GRAFANA_API_KEY", |
| 294 | + "mcp/grafana", |
| 295 | + "--transport=stdio" |
| 296 | + ], |
| 297 | + "env": { |
| 298 | + "GRAFANA_URL": "http://localhost:3000", |
| 299 | + "GRAFANA_API_KEY": "<your service account token>" |
| 300 | + } |
| 301 | + } |
| 302 | + } |
| 303 | +} |
| 304 | +``` |
| 305 | + |
| 306 | +[Why is it safer to run MCP Servers with Docker?](https://www.docker.com/blog/the-model-context-protocol-simplifying-building-ai-apps-with-anthropic-claude-desktop-and-docker/) |
0 commit comments