get_course_topic
Retrieve detailed information about a specific course topic, including its title, description, URL, and linked assignments, after identifying it in course content.
Instructions
Get details about a specific course topic/lecture/reading including title, description, URL, and linked assignments. Use after get_course_content to get more info about a specific item.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orgUnitId | No | The course ID. Optional if D2L_COURSE_ID env var is set. | |
| topicId | Yes | The TopicId from get_course_content. Example: 968299 |
Implementation Reference
- src/tools/content.ts:33-36 (handler)The handler function that implements the core logic of the get_course_topic tool. It retrieves the topic details from the D2L API using the provided orgUnitId and topicId, then marshals and stringifies the result for output.handler: async ({ orgUnitId, topicId }: { orgUnitId?: number; topicId: number }) => { const topic = await client.getContentTopic(getOrgUnitId(orgUnitId), topicId) as RawTopic; return JSON.stringify(marshalTopic(topic), null, 2); },
- src/tools/content.ts:29-32 (schema)Zod schema defining the input parameters for the get_course_topic tool: optional orgUnitId and required topicId.schema: { orgUnitId: z.number().optional().describe('The course ID. Optional if D2L_COURSE_ID env var is set.'), topicId: z.number().describe('The TopicId from get_course_content. Example: 968299'), },
- src/index.ts:66-77 (registration)Registers the get_course_topic tool with the MCP server, providing name, description, schema, and a wrapper handler that formats the response as MCP content.server.tool( 'get_course_topic', contentTools.get_course_topic.description, { orgUnitId: contentTools.get_course_topic.schema.orgUnitId, topicId: contentTools.get_course_topic.schema.topicId, }, async (args) => { const result = await contentTools.get_course_topic.handler(args as { orgUnitId?: number; topicId: number }); return { content: [{ type: 'text', text: result }] }; } );
- src/tools/content.ts:7-13 (helper)Helper function used by the handler to resolve the orgUnitId, falling back to the D2L_COURSE_ID 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:406-414 (helper)Helper function called by the handler to transform the raw API topic response into a clean, LLM-friendly JSON structure.export function marshalTopic(t: RawTopic): MarshalledTopicDetail { return removeEmpty({ id: t.TopicId, title: t.Title, description: stripHtml(t.Description?.Text || t.Description?.Html) || null, url: t.Url || null, type: t.TypeIdentifier || null, }) as MarshalledTopicDetail; }