Skip to main content
Glama

get_my_grades

Retrieve your course grades from D2L Brightspace, including scores, percentages, and feedback for assignments, quizzes, and other grade items.

Instructions

Get your grades for a course. Returns all grade items with your scores, including: grade item name, points earned, points possible, percentage (DisplayedGrade), and any feedback comments. Use to answer: "What are my grades?", "What's my score on the quiz?", "How did I do on the assignment?", "What grade did I get?"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orgUnitIdNoThe course ID. Optional if D2L_COURSE_ID env var is set.

Implementation Reference

  • The handler function that executes the get_my_grades tool logic: resolves orgUnitId, fetches raw grades using the D2L client, marshals them to a friendly format, and returns as formatted JSON string.
    handler: async (args: { orgUnitId?: number }): Promise<string> => {
      const orgUnitId = getOrgUnitId(args.orgUnitId);
      const grades = await client.getMyGradeValues(orgUnitId) as RawGrade[];
      return JSON.stringify(marshalGrades(grades), null, 2);
    },
  • Zod schema defining the optional orgUnitId input parameter for the tool.
    schema: {
      orgUnitId: z.number().optional().describe('The course ID. Optional if D2L_COURSE_ID env var is set.'),
    },
  • src/index.ts:103-111 (registration)
    Registers the get_my_grades tool with the MCP server, providing name, description, schema, and a wrapper handler that formats the response as MCP content.
    server.tool(
      'get_my_grades',
      gradeTools.get_my_grades.description,
      { orgUnitId: gradeTools.get_my_grades.schema.orgUnitId },
      async (args) => {
        const result = await gradeTools.get_my_grades.handler(args as { orgUnitId?: number });
        return { content: [{ type: 'text', text: result }] };
      }
    );
  • Helper function to determine the course orgUnitId from the input argument or the D2L_COURSE_ID environment variable.
    function getOrgUnitId(provided?: number): number {
      const orgUnitId = provided ?? DEFAULT_COURSE_ID;
      if (!orgUnitId) {
        throw new Error('orgUnitId is required. Either provide it or set D2L_COURSE_ID environment variable.');
      }
      return orgUnitId;
    }
  • Helper utility that transforms raw grades from the D2L API into a structured, LLM-friendly format including name, score (points earned/possible), percentage, feedback, and formatted last modified date.
    export function marshalGrades(grades: RawGrade[]): MarshalledGrade[] {
      return grades.map((g) => removeEmpty({
        name: g.GradeObjectName,
        score: g.PointsNumerator !== null && g.PointsDenominator !== null
          ? `${g.PointsNumerator}/${g.PointsDenominator}`
          : null,
        percentage: g.DisplayedGrade?.trim() || null,
        feedback: g.Comments?.Text?.trim() || null,
        lastModified: formatDate(g.LastModified),
      })) as MarshalledGrade[];
    }

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/bencered/d2l-mcp-server'

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