Skip to main content
Glama

Get Assignments

get_assignments

Retrieve assignments and quizzes for enrolled courses, including due dates, submission status, and rubric details.

Instructions

Fetch assignments and quizzes for a specific course or all enrolled courses. Shows dropbox submissions and quizzes with due dates, status, and rubric info. Use this when the user asks about assignments, homework, what to submit, quizzes, or assignment details and rubrics.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
courseIdNoCourse ID to get assignments for. If omitted, returns assignments for all enrolled courses.

Implementation Reference

  • src/index.ts:20-30 (registration)
    Import of registerGetAssignments from the tools barrel module
    import {
      registerGetMyCourses,
      registerGetUpcomingDueDates,
      registerGetMyGrades,
      registerGetAnnouncements,
      registerGetAssignments,
      registerGetCourseContent,
      registerDownloadFile,
      registerGetClasslistEmails,
      registerGetRoster,
      registerGetSyllabus,
  • src/index.ts:183-183 (registration)
    Registration call that wires up the get_assignments tool to the MCP server at startup
    registerGetAssignments(server, apiClient, config);
  • Barrel export re-exporting registerGetAssignments from get-assignments.ts
    export { registerGetAssignments } from "./get-assignments.js";
    export { registerGetCourseContent } from "./get-course-content.js";
    export { registerDownloadFile } from "./download-file.js";
    export { registerGetClasslistEmails } from "./get-classlist-emails.js";
  • Input schema for get_assignments: optional positive integer courseId; if omitted returns all courses
    export const GetAssignmentsSchema = z.object({
      courseId: z.coerce.number().int().positive().optional()
        .describe("Course ID to get assignments for. If omitted, returns assignments for all enrolled courses."),
    });
  • Full handler: registerGetAssignments function that calls server.registerTool('get_assignments', ...) with the main logic. If courseId provided, fetches assignments for that single course via fetchCourseAssignments helper; otherwise iterates all enrolled courses, applies course filter, and aggregates results. Returns structured assignment/quiz data with submissions, feedback, rubrics, and attempt info.
    export function registerGetAssignments(
      server: McpServer,
      apiClient: D2LApiClient,
      config: AppConfig
    ): void {
      server.registerTool(
        "get_assignments",
        {
          title: "Get Assignments",
          description:
            "Fetch assignments and quizzes for a specific course or all enrolled courses. Shows dropbox submissions and quizzes with due dates, status, and rubric info. Use this when the user asks about assignments, homework, what to submit, quizzes, or assignment details and rubrics.",
          inputSchema: GetAssignmentsSchema,
        },
        async (args: any) => {
          try {
            log("DEBUG", "get_assignments tool called", { args });
    
            // Parse and validate input
            const { courseId } = GetAssignmentsSchema.parse(args);
    
            // Single course case
            if (courseId) {
              const assignments = await fetchCourseAssignments(apiClient, courseId);
    
              log("INFO", `get_assignments: Retrieved ${assignments.length} assignments for course ${courseId}`);
              return toolResponse({ courseId, assignments });
            }
    
            // All courses case
            // First, fetch enrolled courses
            const enrollmentPath = apiClient.lp(
              "/enrollments/myenrollments/?orgUnitTypeId=3&isActive=true"
            );
            const enrollmentResponse = await apiClient.get<EnrollmentResponse>(
              enrollmentPath,
              { ttl: DEFAULT_CACHE_TTLS.enrollments }
            );
    
            // Apply course filter
            const filteredEnrollments = applyCourseFilter(
              enrollmentResponse.Items.map(item => ({
                id: item.OrgUnit.Id,
                name: item.OrgUnit.Name,
                code: item.OrgUnit.Code,
                isActive: item.Access.IsActive,
                ...item,
              })),
              config.courseFilter
            );
    
            // Fetch assignments for each course (handle 403s gracefully)
            const assignmentPromises = filteredEnrollments.map(async (item) => {
              try {
                const assignments = await fetchCourseAssignments(apiClient, item.OrgUnit.Id);
    
                return {
                  courseId: item.OrgUnit.Id,
                  courseName: item.OrgUnit.Name,
                  assignments,
                };
              } catch (error: any) {
                // 403 means no access (past course, etc) - log and skip
                if (error?.status === 403) {
                  log(
                    "DEBUG",
                    `get_assignments: 403 Forbidden for course ${item.OrgUnit.Id} (${item.OrgUnit.Name}) - skipping`
                  );
                  return null;
                }
                throw error; // Re-throw other errors
              }
            });
    
            const results = await Promise.allSettled(assignmentPromises);
            const courses = results
              .filter(
                (r): r is PromiseFulfilledResult<any> =>
                  r.status === "fulfilled" && r.value !== null
              )
              .map((r) => r.value);
    
            log(
              "INFO",
              `get_assignments: Retrieved assignments for ${courses.length} courses (out of ${enrollmentResponse.Items.length} enrolled)`
            );
            return toolResponse({ courses });
          } catch (error) {
            // Temporary: log full error details to stderr for debugging
            if (error instanceof Error) {
              log("ERROR", `get_assignments failed: ${error.message}\n${error.stack}`);
            }
            return sanitizeError(error);
          }
        }
      );
    }
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses that the operation is a fetch (read-only) and describes returned data. No contradictions; additional behavioral details like authentication or pagination are not critical for a simple read tool.

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, concise and front-loaded. Every sentence adds value with no redundancy.

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, description provides adequate detail about return values (dropbox submissions and quizzes with due dates, status, rubric info). Could mention if results are paginated, but overall sufficient.

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

Parameters5/5

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

Input schema has 100% coverage with parameter 'courseId' described. Description adds crucial context: omitting it returns assignments for all enrolled courses. This adds meaning beyond the schema.

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?

Description clearly states 'Fetch assignments and quizzes' with specific resources (dropbox submissions, quizzes) and details (due dates, status, rubric info). It distinguishes itself from siblings like get_course_content or get_my_grades by specifying the data type.

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?

Explicitly states when to use: 'Use this when the user asks about assignments, homework, what to submit, quizzes, or assignment details and rubrics.' Does not mention when not to use or alternatives, but context is clear.

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