Skip to main content
Glama
0xteamhq

Grafana MCP Server

by 0xteamhq

list_oncall_schedules

Retrieve Grafana OnCall schedules to manage team rotations and on-call assignments. Filter by team ID or specific schedule to focus on relevant duty rosters.

Instructions

List Grafana OnCall schedules, optionally filtering by team ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoThe page number to return (1-based)
scheduleIdNoThe ID of a specific schedule to retrieve
teamIdNoThe ID of the team to list schedules for

Implementation Reference

  • The asynchronous handler function for the 'list_oncall_schedules' tool. It creates an API client, constructs query parameters and endpoint based on input, fetches schedules from Grafana OnCall API, formats the response, and returns it or an error.
    handler: async (params, context: ToolContext) => {
      try {
        const client = createOncallClient(context.config.grafanaConfig);
        
        const queryParams: any = {};
        if (params.teamId) queryParams.team_id = params.teamId;
        if (params.page) queryParams.page = params.page;
        
        let endpoint = '/schedules';
        if (params.scheduleId) {
          endpoint = `/schedules/${params.scheduleId}`;
        }
        
        const response = await client.get(endpoint, { params: queryParams });
        
        const schedules = params.scheduleId ? [response.data] : response.data.results || [];
        
        // Format the response
        const formatted = schedules.map((schedule: any) => ({
          id: schedule.id,
          name: schedule.name,
          teamId: schedule.team_id,
          timezone: schedule.time_zone,
          shiftIds: schedule.on_call_now || [],
        }));
        
        return createToolResult(formatted);
      } catch (error: any) {
        return createErrorResult(error.response?.data?.detail || error.message);
      }
    },
  • Zod input schema for the 'list_oncall_schedules' tool defining optional parameters: teamId, scheduleId, and page.
    const ListOncallSchedulesSchema = z.object({
      teamId: z.string().optional().describe('The ID of the team to list schedules for'),
      scheduleId: z.string().optional().describe('The ID of a specific schedule to retrieve'),
      page: z.number().optional().describe('The page number to return (1-based)'),
    });
  • Registration function that registers the 'list_oncall_schedules' 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);
    }
  • Helper function to create an Axios client configured for the Grafana OnCall API, used by the tool handler to make authenticated requests.
    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 for behavioral disclosure. It mentions filtering capability but doesn't describe pagination behavior (implied by 'page' parameter), rate limits, authentication requirements, or what happens when no filters are applied. For a list operation with 3 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 and includes the key optional capability. Every word earns its place with zero redundancy or unnecessary elaboration.

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 list operation with 3 well-documented parameters but no annotations and no output schema, the description provides adequate basic context but leaves gaps. It doesn't address pagination behavior, response format, error conditions, or how the optional parameters interact. The description is complete enough for basic usage but insufficient for full understanding of tool behavior.

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 all parameters thoroughly. The description adds minimal value by mentioning team ID filtering but doesn't provide additional context about parameter interactions (e.g., whether scheduleId overrides other filters) or usage patterns beyond what's in the schema descriptions.

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 action ('List') and resource ('Grafana OnCall schedules'), making the purpose immediately understandable. It distinguishes from some siblings like 'get_oncall_shift' (singular retrieval) but doesn't explicitly differentiate from other list tools like 'list_oncall_teams' or 'list_oncall_users' that operate on different resources.

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

Usage Guidelines3/5

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

The description provides implied usage context through the optional filtering capability ('optionally filtering by team ID'), suggesting when this tool might be preferred over unfiltered listing. However, it doesn't explicitly state when to use this tool versus alternatives like 'list_oncall_teams' or provide any exclusion criteria or prerequisites.

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