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,
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'Get[s] detailed information,' implying a read-only operation, but doesn't specify what 'detailed information' includes, whether it requires authentication, any rate limits, error conditions, or the response format. For a tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized for a simple lookup tool and front-loaded with the core action, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is incomplete. It doesn't explain what 'detailed information' includes, how to interpret results, or any behavioral nuances. Given the complexity of fetching shift details in an on-call system, more context is needed to help the agent use this tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'shiftId' parameter clearly documented as 'The ID of the shift to get details for.' The description adds no additional meaning beyond this, such as format examples or constraints. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get detailed information for a specific Grafana OnCall shift.' It uses a specific verb ('Get') and resource ('Grafana OnCall shift'), making it easy to understand. However, it doesn't explicitly distinguish this tool from potential siblings like 'get_current_oncall_users' or 'list_oncall_schedules,' which reduces clarity in a crowded toolset.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a shift ID), exclusions, or how it differs from related tools like 'list_oncall_schedules' or 'get_current_oncall_users.' This leaves the agent to infer usage from the tool name alone, which is insufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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