Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

get_current_oncall_users

Retrieve the list of users currently on-call for a specific Grafana OnCall schedule using the schedule ID to identify active responders.

Instructions

Get the list of users currently on-call for a specific Grafana OnCall schedule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scheduleIdYesThe ID of the schedule to get current on-call users for

Implementation Reference

  • The ToolDefinition export for 'get_current_oncall_users', which includes the handler function that fetches the schedule data from Grafana OnCall API and extracts the currently on-call users.
    export const getCurrentOncallUsers: ToolDefinition = {
      name: 'get_current_oncall_users',
      description: 'Get the list of users currently on-call for a specific Grafana OnCall schedule',
      inputSchema: GetCurrentOncallUsersSchema,
      handler: async (params, context: ToolContext) => {
        try {
          const client = createOncallClient(context.config.grafanaConfig);
          
          const response = await client.get(`/schedules/${params.scheduleId}`);
          const schedule = response.data;
          
          // Get users currently on call
          const onCallNow = schedule.on_call_now || [];
          const users = [];
          
          for (const userInfo of onCallNow) {
            if (userInfo.user) {
              users.push({
                id: userInfo.user.id,
                username: userInfo.user.username,
                email: userInfo.user.email,
                name: userInfo.user.name,
              });
            }
          }
          
          return createToolResult({
            scheduleId: schedule.id,
            scheduleName: schedule.name,
            currentOncallUsers: users,
          });
        } catch (error: any) {
          return createErrorResult(error.response?.data?.detail || error.message);
        }
      },
    };
  • Zod schema defining the input for the 'get_current_oncall_users' tool, requiring a scheduleId.
    const GetCurrentOncallUsersSchema = z.object({
      scheduleId: z.string().describe('The ID of the schedule to get current on-call users for'),
    });
  • The registration function for all OnCall tools, which registers 'get_current_oncall_users' with the MCP server.
    export function registerOncallTools(server: any) {
      server.registerTool(listOncallSchedules);
      server.registerTool(listOncallTeams);
      server.registerTool(listOncallUsers);
      server.registerTool(getCurrentOncallUsers);
      server.registerTool(getOncallShift);
    }
  • Helper function to create an Axios client instance for interacting with the Grafana OnCall API, used by the tool 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?

With no annotations provided, the description carries full burden but only states what the tool does without behavioral details. It doesn't disclose whether this is a read-only operation, potential rate limits, authentication needs, error handling, or what the return format looks like (e.g., list structure, timestamps).

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 front-loads the core purpose with zero waste. Every word earns its place by specifying the action, resource, and context without redundancy.

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

Completeness3/5

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

For a simple read tool with one parameter and no output schema, the description is minimally adequate but lacks completeness. It doesn't explain return values, error cases, or behavioral traits, leaving gaps despite the straightforward input schema.

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?

Schema description coverage is 100%, so the schema already documents the single parameter 'scheduleId'. The description adds no additional meaning beyond implying it's for a Grafana OnCall schedule, which aligns with the schema. Baseline 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 verb ('Get') and resource ('list of users currently on-call'), specifying it's for a Grafana OnCall schedule. It distinguishes from siblings like 'list_oncall_users' by focusing on current on-call status rather than general listing, but doesn't explicitly contrast with 'get_oncall_shift' which might overlap.

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?

No explicit guidance on when to use this tool versus alternatives like 'list_oncall_users' or 'get_oncall_shift' is provided. The description implies usage for current on-call status, but lacks context on prerequisites, exclusions, or comparisons with sibling tools.

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