Skip to main content
Glama

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
NameRequiredDescriptionDefault
orgUnitIdNoThe course ID. Optional if D2L_COURSE_ID env var is set.

Implementation Reference

  • 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); },
  • 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 }] }; } );
  • 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; }
  • 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)); }

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