- Home
- MCP servers
- Grafana
Grafana
- typescript
1
GitHub Stars
typescript
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"quanticsoul4772-grafana-mcp": {
"command": "node",
"args": [
"/path/to/grafana-mcp/build/main.js"
],
"env": {
"GRAFANA_URL": "https://your-grafana.com",
"GRAFANA_DEBUG": "false",
"GRAFANA_TOKEN": "your-service-account-token",
"GRAFANA_TIMEOUT": "30000",
"GRAFANA_TLS_CA_FILE": "/path/to/ca.crt",
"GRAFANA_TLS_KEY_FILE": "/path/to/client.key",
"GRAFANA_TLS_CERT_FILE": "/path/to/client.crt",
"GRAFANA_TLS_SKIP_VERIFY": "false"
}
}
}
}You are working with an MCP server that enables AI-powered, programmatic integration with Grafana. It exposes Grafana’s dashboards, data sources, metrics, logs, alerting, and administrative functions through standardized MCP tools so you can automate and orchestrate Grafana tasks from your MCP client.
How to use
You will interact with the Grafana MCP Server through an MCP client. The server provides a rich set of tools to manage dashboards, query Prometheus metrics, search Loki logs, handle alerts, manage users and organizations, and generate deep links to Grafana resources. Use these tools to perform common tasks such as finding dashboards, running PromQL queries, testing datasource connections, deploying and evaluating RAMP sensor data, and generating URLs for dashboards and explore views. Your MCP client can call the tools directly, pass structured arguments, and receive typed responses that you can act upon in your automation workflows.
How to install
Prerequisites you need before installation:
-
Node.js 18+ with ES modules support
-
TypeScript 4.9+
-
Grafana v8.0+
Step-by-step setup workflow you can follow:
# Clone the repository
git clone https://github.com/your-org/grafana-mcp
cd grafana-mcp
# Install dependencies
npm install
# Build the project
npm run build
Configuration
Configure the server using environment variables. Create a .env file or export these variables in your environment.
# Required Configuration
GRAFANA_URL=https://your-grafana-instance.com
GRAFANA_TOKEN=your-service-account-token-or-api-key
# Optional Configuration
GRAFANA_DEBUG=false # Enable debug logging
GRAFANA_TIMEOUT=30000 # HTTP timeout in milliseconds
GRAFANA_DISABLE_TOOLS=admin,alerting # Disable specific tool categories
# TLS Configuration (Optional)
GRAFANA_TLS_CERT_FILE=/path/to/client.crt
GRAFANA_TLS_KEY_FILE=/path/to/client.key
GRAFANA_TLS_CA_FILE=/path/to/ca.crt
GRAFANA_TLS_SKIP_VERIFY=false # Skip certificate verification (insecure)
Security
Security is designed to protect credentials and minimize risks. The server sanitizes data in logs and errors, categorizes errors for safe user-facing messages, enforces TLS with certificate validation, and operates tools with the least privileges necessary.
Examples
Here are practical examples you can adapt to your environment. These illustrate common usage patterns without exposing protocol details.
# Example: start the server in development mode with hot reload
npm run dev
# Example: run tests
npm test
# Example: lint and format
npm run lint
npm run format
Notes
The configuration and startup steps assume you have a Grafana instance accessible at the URL you provide and a valid token. Adjust timeouts and TLS settings to match your security requirements and network conditions.
Troubleshooting
If you encounter connectivity or authentication issues, verify the Grafana URL and token, check network access, and review logs for sanitized error messages that indicate credential or permission problems.
Development
Development supports hot-reload during development, test execution, and code quality checks. Ensure you run the appropriate npm scripts and validate TypeScript types during integration.
Available tools
search_dashboards
Find dashboards by title, tags, or metadata
get_dashboard_by_uid
Retrieve complete dashboard details
get_dashboard_panel_queries
Extract queries from all panels
update_dashboard
Create or update dashboards
get_dashboard_versions
View dashboard version history
restore_dashboard_version
Restore to a specific version
delete_dashboard
Remove dashboards
list_datasources
List all configured datasources
get_datasource_by_uid
Get datasource details by UID
get_datasource_by_name
Get datasource details by name
test_datasource_connection
Test datasource connectivity
get_datasources_by_type
Filter datasources by type
get_default_datasource
Get the default datasource
check_datasource_exists
Check if a datasource exists
query_prometheus
Execute PromQL queries
get_prometheus_metadata
List available metrics
get_prometheus_labels
Get label names
get_prometheus_label_values
Get values for specific labels
get_prometheus_series
Find time series
build_prometheus_query
Interactive query builder
query_loki
Execute LogQL queries
get_loki_labels
Get log stream labels
get_loki_label_values
Get label values
get_loki_series
Find log series
build_logql_query
LogQL query builder
get_loki_stats
Ingestion statistics
list_alert_rules
List all alert rules
get_alert_rule
Get specific alert rule details
create_alert_rule
Create new alert rules
update_alert_rule
Update existing rules
delete_alert_rule
Delete alert rules
list_contact_points
List notification contact points
get_contact_point
Get contact point details
test_contact_point
Test notification delivery
list_alert_rule_groups
List alert rule groups
list_teams
List teams
get_team_by_uid
Get team details
list_users
List organization users
get_current_user
Get current user info
list_folders
List dashboard folders
get_folder_by_uid
Get folder details
list_api_keys
List API keys
list_service_accounts
List service accounts
get_current_organization
Get current organization info
generate_deeplink
Generate deeplink URLs for dashboards, panels, or Explore
generate_dashboard_url
Generate dashboard URLs with time range and variables
generate_panel_url
Generate panel-specific URLs
generate_explore_url
Generate Explore view URLs
generate_prometheus_explore_url
Generate Prometheus Explore URLs
generate_loki_explore_url
Generate Loki Explore URLs
get_time_range_presets
Get common time range presets
validate_time_range
Validate time range parameters
discover_sensors
Auto-discover Corelight sensors via SSH tunnels (ports 8080-8099)
sensor_status
Get health and version info for a sensor
query_sensor_metric
Query Prometheus metrics from a sensor's Grafana
deploy_ramp_dashboard
Deploy a standard RAMP dashboard to a sensor
list_baselines
List available performance baselines for comparison
sensor_performance_verdict
Compare current metrics against baselines (pass/marginal/fail)
annotate_test
Create Grafana annotations to mark test events