Skip to main content
Glama

Get Upcoming Due Dates

get_upcoming_due_dates

Retrieve upcoming assignment and quiz due dates across all courses. Filter by course or specify the number of days ahead to view deadlines.

Instructions

Fetch upcoming due dates across all your courses. Shows assignments, quizzes, and other items due within the specified time window. Use this when the user asks about deadlines, what's due, upcoming work, or what they need to do this week.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysAheadNoNumber of days ahead to look for due dates
courseIdNoFilter to a specific course ID

Implementation Reference

  • The registerGetUpcomingDueDates function that registers and implements the 'get_upcoming_due_dates' tool. Fetches upcoming due dates across courses from the Brightspace calendar API, with optional courseId filter and configurable daysAhead window.
    export function registerGetUpcomingDueDates(
      server: McpServer,
      apiClient: D2LApiClient,
      config: AppConfig
    ): void {
      server.registerTool(
        "get_upcoming_due_dates",
        {
          title: "Get Upcoming Due Dates",
          description:
            "Fetch upcoming due dates across all your courses. Shows assignments, quizzes, and other items due within the specified time window. Use this when the user asks about deadlines, what's due, upcoming work, or what they need to do this week.",
          inputSchema: GetUpcomingDueDatesSchema,
        },
        async (args: any) => {
          try {
            log("DEBUG", "get_upcoming_due_dates tool called", { args });
    
            // Parse and validate input
            const { daysAhead, courseId } = GetUpcomingDueDatesSchema.parse(args);
    
            // Build time window
            const now = new Date();
            const endDate = new Date(now.getTime() + daysAhead * 24 * 60 * 60 * 1000);
    
            const startDateTime = now.toISOString();
            const endDateTime = endDate.toISOString();
    
            // D2L calendar API requires orgUnitIdsCSV — fetch enrolled course IDs if not provided
            let orgUnitIds: string;
            if (courseId) {
              orgUnitIds = String(courseId);
            } else {
              const enrollments = await apiClient.get<{ Items: EnrollmentItem[] }>(
                apiClient.lp(`/enrollments/myenrollments/?orgUnitTypeId=3&isActive=true`),
                { ttl: DEFAULT_CACHE_TTLS.enrollments }
              );
    
              // Apply course filter
              const filteredEnrollments = applyCourseFilter(
                enrollments.Items.map(item => ({
                  id: item.OrgUnit.Id,
                  name: item.OrgUnit.Name,
                  code: item.OrgUnit.Code,
                  isActive: item.Access.IsActive,
                })),
                config.courseFilter
              );
    
              orgUnitIds = filteredEnrollments.map((e) => e.id).join(",");
            }
    
            log("DEBUG", `get_upcoming_due_dates: querying orgUnitIds=${orgUnitIds}, window=${startDateTime} to ${endDateTime}`);
    
            // Build path
            const path = apiClient.leGlobal(
              `/calendar/events/myEvents/?startDateTime=${encodeURIComponent(startDateTime)}&endDateTime=${encodeURIComponent(endDateTime)}&orgUnitIdsCSV=${orgUnitIds}`
            );
    
            // Fetch events — D2L returns ObjectListPage wrapper with "Objects" array (NOT "Items")
            const response = await apiClient.get<{ Objects: EventDataInfo[]; Next: string | null }>(path, {
              ttl: DEFAULT_CACHE_TTLS.assignments,
            });
            const events = response.Objects ?? [];
            log("DEBUG", `get_upcoming_due_dates: raw response keys=${Object.keys(response).join(",")}, event count=${events.length}`);
    
            // Map to clean objects and sort by end date (soonest due first)
            const mappedEvents = events
              .map((event) => ({
                id: event.CalendarEventId,
                title: event.Title,
                courseName: event.OrgUnitName,
                courseId: event.OrgUnitId,
                startDate: event.StartDateTime,
                endDate: event.EndDateTime,
                isAllDay: event.IsAllDayEvent,
              }))
              .sort(
                (a, b) =>
                  new Date(a.endDate).getTime() - new Date(b.endDate).getTime()
              );
    
            log(
              "INFO",
              `get_upcoming_due_dates: Retrieved ${mappedEvents.length} events`
            );
            return toolResponse(mappedEvents);
          } catch (error) {
            return sanitizeError(error);
          }
        }
      );
    }
  • Zod schema for GetUpcomingDueDates tool validating two inputs: daysAhead (number, 1-90, default 7) and courseId (optional positive integer).
    export const GetUpcomingDueDatesSchema = z.object({
      daysAhead: z.coerce.number().int().min(1).max(90).default(7).describe("Number of days ahead to look for due dates"),
      courseId: z.coerce.number().int().positive().optional().describe("Filter to a specific course ID"),
    });
  • src/index.ts:20-30 (registration)
    Import of registerGetUpcomingDueDates at the top of src/index.ts.
    import {
      registerGetMyCourses,
      registerGetUpcomingDueDates,
      registerGetMyGrades,
      registerGetAnnouncements,
      registerGetAssignments,
      registerGetCourseContent,
      registerDownloadFile,
      registerGetClasslistEmails,
      registerGetRoster,
      registerGetSyllabus,
  • src/index.ts:180-180 (registration)
    Registration call: registerGetUpcomingDueDates(server, apiClient, config) in the server setup.
    registerGetUpcomingDueDates(server, apiClient, config);
  • src/tools/index.ts:9-9 (registration)
    Barrel re-export of registerGetUpcomingDueDates from tools/index.ts.
    export { registerGetUpcomingDueDates } from "./get-upcoming-due-dates.js";
Behavior3/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. It discloses that the tool fetches due dates and includes assignments, quizzes, and other items within a configurable time window. However, it does not specify the output format, potential side effects (none expected), or authentication requirements, but the basic behavior is clear.

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?

Two sentences only: the first defines the action and scope, the second provides usage guidance. No extraneous information, front-loaded with essentials.

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

Completeness4/5

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

Given no output schema, the description adequately explains the tool's purpose and parameters. It mentions the types of items returned (assignments, quizzes). For a simple fetch tool, this is sufficient, though it could hint at the output structure (e.g., dates and names).

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

Parameters4/5

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

Schema coverage is 100%, with both parameters described. The description adds value by specifying that the tool returns assignments, quizzes, and other items, which goes beyond the schema. It also clarifies the default behavior (across all courses) and the optional courseId filter.

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

Purpose5/5

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

The description clearly states it fetches upcoming due dates across all courses, showing assignments, quizzes, and other items within a time window. The verb 'fetch' and resource 'upcoming due dates' are specific, and it distinguishes from siblings like 'get_assignments' which might provide more detail but not time-bound due dates across courses.

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

Usage Guidelines4/5

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

The description explicitly instructs to use this tool when the user asks about deadlines, what's due, upcoming work, or what's needed this week. This provides clear context, though it lacks mention of when not to use it or alternatives.

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/RohanMuppa/brightspace-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server