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
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | The page number to return |
Implementation Reference
- src/tools/oncall.ts:87-115 (handler)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); } }, };
- src/tools/oncall.ts:12-14 (schema)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'), });
- src/tools/oncall.ts:220-226 (registration)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);
- src/tools/oncall.ts:31-47 (helper)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, }); }