Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

list_oncall_teams

Retrieve a list of teams configured in Grafana OnCall to manage on-call rotations and incident response assignments.

Instructions

List teams configured in Grafana OnCall

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoThe page number to return

Implementation Reference

  • The ToolDefinition object for 'list_oncall_teams' containing the handler function that executes the tool logic: creates an OnCall API client, fetches teams from '/teams' endpoint with optional pagination, formats the response, and returns it.
    export const listOncallTeams: ToolDefinition = { name: 'list_oncall_teams', description: 'List teams configured in Grafana OnCall', inputSchema: ListOncallTeamsSchema, handler: async (params, context: ToolContext) => { try { const client = createOncallClient(context.config.grafanaConfig); const queryParams: any = {}; if (params.page) queryParams.page = params.page; const response = await client.get('/teams', { params: queryParams }); const teams = response.data.results || []; // Format the response const formatted = teams.map((team: any) => ({ id: team.id, name: team.name, email: team.email, avatarUrl: team.avatar_url, })); return createToolResult(formatted); } catch (error: any) { return createErrorResult(error.response?.data?.detail || error.message); } }, };
  • Zod input schema definition for the 'list_oncall_teams' tool, allowing optional page parameter for pagination.
    const ListOncallTeamsSchema = z.object({ page: z.number().optional().describe('The page number to return'), });
  • The registerOncallTools function that registers the 'list_oncall_teams' tool (and other oncall tools) with the MCP server.
    export function registerOncallTools(server: any) { server.registerTool(listOncallSchedules); server.registerTool(listOncallTeams); server.registerTool(listOncallUsers); server.registerTool(getCurrentOncallUsers); server.registerTool(getOncallShift); }
  • src/cli.ts:119-120 (registration)
    The call to registerOncallTools in the CLI entrypoint, conditionally enabling oncall tools including 'list_oncall_teams' based on configuration.
    if (enabledTools.has('oncall')) { registerOncallTools(server);
  • Helper function createOncallClient used by the handler to create an axios client configured for Grafana OnCall API with authentication.
    function createOncallClient(config: any) { const headers: any = { 'User-Agent': 'mcp-grafana/1.0.0', }; if (config.serviceAccountToken) { headers['Authorization'] = `Bearer ${config.serviceAccountToken}`; } else if (config.apiKey) { headers['Authorization'] = `Bearer ${config.apiKey}`; } return axios.create({ baseURL: `${config.url}/api/plugins/grafana-oncall-app/resources/api/v1`, headers, timeout: 30000, }); }

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