get_oncall_shift
Retrieve detailed information about a specific Grafana OnCall shift using its unique ID to access shift schedules, team assignments, and coverage periods.
Instructions
Get detailed information for a specific Grafana OnCall shift
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| shiftId | Yes | The ID of the shift to get details for |
Implementation Reference
- src/tools/oncall.ts:193-218 (handler)Core implementation of the 'get_oncall_shift' tool as a ToolDefinition, including the async handler function that fetches and formats shift information from the Grafana OnCall API.export const getOncallShift: ToolDefinition = { name: 'get_oncall_shift', description: 'Get detailed information for a specific Grafana OnCall shift', inputSchema: GetOncallShiftSchema, handler: async (params, context: ToolContext) => { try { const client = createOncallClient(context.config.grafanaConfig); const response = await client.get(`/on_call_shifts/${params.shiftId}`); const shift = response.data; return createToolResult({ id: shift.id, name: shift.name, type: shift.type, teamId: shift.team_id, start: shift.start, duration: shift.duration, frequency: shift.frequency, users: shift.users, }); } catch (error: any) { return createErrorResult(error.response?.data?.detail || error.message); } }, };
- src/tools/oncall.ts:26-28 (schema)Zod schema defining the input for get_oncall_shift: requires a shiftId string.const GetOncallShiftSchema = z.object({ shiftId: z.string().describe('The ID of the shift to get details for'), });
- src/tools/oncall.ts:220-226 (registration)Function that registers the get_oncall_shift tool (along with other oncall tools) by calling server.registerTool.export function registerOncallTools(server: any) { server.registerTool(listOncallSchedules); server.registerTool(listOncallTeams); server.registerTool(listOncallUsers); server.registerTool(getCurrentOncallUsers); server.registerTool(getOncallShift); }
- src/cli.ts:120-120 (registration)Main entrypoint call to registerOncallTools, enabling the tool when 'oncall' category is active.registerOncallTools(server);
- src/tools/oncall.ts:31-47 (helper)Helper utility to create an authenticated axios client for Grafana OnCall API requests, invoked in the handler.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, }); }