Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

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
NameRequiredDescriptionDefault
shiftIdYesThe ID of the shift to get details for

Implementation Reference

  • 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); } }, };
  • 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'), });
  • 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);
  • 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, }); }

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