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
| Name | Required | Description | Default |
|---|---|---|---|
| orgUnitId | No | The course ID. Optional if D2L_COURSE_ID env var is set. | |
| moduleId | Yes | The ModuleId from get_course_modules or get_course_content. Example: 968296 |
Implementation Reference
- src/tools/content.ts:56-59 (handler)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); },
- src/tools/content.ts:52-55 (schema)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 }] }; } );
- src/utils/marshal.ts:362-375 (helper)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; }