Skip to main content
Glama

get_course_module

Retrieve detailed contents of a specific course module including topics, sub-modules, and materials to explore one section of a D2L Brightspace course.

Instructions

Get all contents within a specific course module/section including child topics, sub-modules, and materials. Use to explore one section of the course in detail.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orgUnitIdNoThe course ID. Optional if D2L_COURSE_ID env var is set.
moduleIdYesThe ModuleId from get_course_modules or get_course_content. Example: 968296

Implementation Reference

  • Handler function that fetches the course module data using the D2L client API and marshals it to a formatted JSON string for the tool response.
    handler: async ({ orgUnitId, moduleId }: { orgUnitId?: number; moduleId: number }) => {
      const structure = await client.getContentModule(getOrgUnitId(orgUnitId), moduleId) as RawContentModule;
      return JSON.stringify(marshalContentModule(structure), null, 2);
    },
  • Zod schema defining the input parameters for the tool: optional orgUnitId (course ID) and required moduleId.
    schema: {
      orgUnitId: z.number().optional().describe('The course ID. Optional if D2L_COURSE_ID env var is set.'),
      moduleId: z.number().describe('The ModuleId from get_course_modules or get_course_content. Example: 968296'),
    },
  • src/index.ts:89-100 (registration)
    Registers the get_course_module tool with the MCP server using server.tool(), referencing the description and schema from contentTools, and providing a wrapper handler that formats the response as MCP content.
    server.tool(
      'get_course_module',
      contentTools.get_course_module.description,
      {
        orgUnitId: contentTools.get_course_module.schema.orgUnitId,
        moduleId: contentTools.get_course_module.schema.moduleId,
      },
      async (args) => {
        const result = await contentTools.get_course_module.handler(args as { orgUnitId?: number; moduleId: number });
        return { content: [{ type: 'text', text: result }] };
      }
    );
  • Helper function used by the handler to transform raw D2L ContentModule API response into a clean, structured JSON object suitable for LLM consumption, handling HTML stripping, null removal, and recursive marshalling.
    export function marshalContentModule(m: RawContentModule): MarshalledModule {
      return removeEmpty({
        id: m.ModuleId,
        title: m.Title,
        description: stripHtml(m.Description?.Text || m.Description?.Html) || null,
        topics: m.Topics?.map((t) => removeEmpty({
          id: t.TopicId,
          title: t.Title,
          url: t.Url || null,
          type: t.TypeIdentifier || null,
        })) as MarshalledTopic[] | undefined,
        modules: m.Modules?.length ? marshalContentModules(m.Modules) : undefined,
      }) as MarshalledModule;
    }

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