get_course_modules
Retrieve course sections and modules to understand course structure and organization. Provides module names, descriptions, and IDs for planning and navigation.
Instructions
Get the main sections/modules of a course. Returns module names, descriptions, and ModuleIds. Use for a high-level overview of course organization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orgUnitId | No | The course ID. Optional if D2L_COURSE_ID env var is set. |
Implementation Reference
- src/tools/content.ts:44-47 (handler)The handler function that implements the core logic of the 'get_course_modules' tool. It resolves the organization unit ID, fetches the content modules from the D2L API client, marshals them, and returns a formatted JSON string.handler: async ({ orgUnitId }: { orgUnitId?: number }) => { const modules = await client.getContentModules(getOrgUnitId(orgUnitId)) as RawContentModule[]; return JSON.stringify(marshalContentModules(modules), null, 2); },
- src/tools/content.ts:41-43 (schema)The Zod input schema defining the optional orgUnitId 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:79-87 (registration)The registration of the 'get_course_modules' tool with the MCP server, including description, schema extraction, and a wrapper around the handler to format the response.server.tool( 'get_course_modules', contentTools.get_course_modules.description, { orgUnitId: contentTools.get_course_modules.schema.orgUnitId }, async (args) => { const result = await contentTools.get_course_modules.handler(args as { orgUnitId?: number }); return { content: [{ type: 'text', text: result }] }; } );
- src/tools/content.ts:7-13 (helper)Helper function used by the handler to determine the organization unit (course) ID from input or environment variable.function getOrgUnitId(orgUnitId?: number): number { const id = orgUnitId ?? DEFAULT_COURSE_ID; if (!id) { throw new Error('No course ID provided and D2L_COURSE_ID environment variable not set'); } return id; }
- src/utils/marshal.ts:358-360 (helper)Helper utility to marshal raw D2L content modules into a clean, typed structure used by the handler for output formatting.export function marshalContentModules(modules: RawContentModule[]): MarshalledModule[] { return modules.map((m) => marshalContentModule(m)); }