Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq
test-connection.jsβ€’1.77 kB
#!/usr/bin/env node /** * Test basic connection to Grafana instance */ require('dotenv').config(); const axios = require('axios'); const GRAFANA_URL = process.env.GRAFANA_URL; const TOKEN = process.env.GRAFANA_SERVICE_ACCOUNT_TOKEN; console.log('πŸ”Œ Testing Grafana Connection'); console.log('=============================='); console.log(`URL: ${GRAFANA_URL}`); console.log(`Token: ${TOKEN ? 'βœ“ Present' : 'βœ— Missing'}\n`); async function testConnection() { try { // Test basic API access const response = await axios.get(`${GRAFANA_URL}/api/org`, { headers: { 'Authorization': `Bearer ${TOKEN}`, 'Content-Type': 'application/json' } }); console.log('βœ… Connection successful!'); console.log(`Organization: ${response.data.name}`); console.log(`ID: ${response.data.id}\n`); // Test datasources endpoint const dsResponse = await axios.get(`${GRAFANA_URL}/api/datasources`, { headers: { 'Authorization': `Bearer ${TOKEN}` } }); console.log(`πŸ“Š Found ${dsResponse.data.length} datasources:`); dsResponse.data.forEach(ds => { console.log(` - ${ds.name} (${ds.type})`); }); // Test dashboards search const dashResponse = await axios.get(`${GRAFANA_URL}/api/search?type=dash-db`, { headers: { 'Authorization': `Bearer ${TOKEN}` } }); console.log(`\nπŸ“ˆ Found ${dashResponse.data.length} dashboards`); return true; } catch (error) { console.error('❌ Connection failed:', error.response?.data?.message || error.message); if (error.response?.status === 401) { console.error(' Authentication failed - check your service account token'); } return false; } } testConnection();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/0xteamhq/mcp-grafana'

If you have feedback or need assistance with the MCP directory API, please join our Discord server