Skip to main content
Glama
content.ts3.35 kB
import { z } from 'zod'; import { client } from '../client.js'; import { marshalToc, marshalTopic, marshalContentModules, marshalContentModule, RawTocModule, RawTopic, RawContentModule } from '../utils/marshal.js'; const DEFAULT_COURSE_ID = process.env.D2L_COURSE_ID ? parseInt(process.env.D2L_COURSE_ID) : undefined; 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; } export const contentTools = { get_course_content: { description: `Get the complete course syllabus/structure including all modules, topics, lectures, and learning materials. Returns module titles, descriptions, topic names with URLs, and linked assignments. Use to answer: "What's in this course?", "Show me the syllabus", "What topics are covered?", "What lectures are available?", "What reading materials do I have?"`, schema: { orgUnitId: z.number().optional().describe('The course ID. Optional if D2L_COURSE_ID env var is set.'), }, handler: async ({ orgUnitId }: { orgUnitId?: number }) => { const toc = await client.getContentToc(getOrgUnitId(orgUnitId)) as { Modules: RawTocModule[] }; return JSON.stringify(marshalToc(toc), null, 2); }, }, get_course_topic: { description: `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.`, 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'), }, 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); }, }, get_course_modules: { description: `Get the main sections/modules of a course. Returns module names, descriptions, and ModuleIds. Use for a high-level overview of course organization.`, schema: { orgUnitId: z.number().optional().describe('The course ID. Optional if D2L_COURSE_ID env var is set.'), }, handler: async ({ orgUnitId }: { orgUnitId?: number }) => { const modules = await client.getContentModules(getOrgUnitId(orgUnitId)) as RawContentModule[]; return JSON.stringify(marshalContentModules(modules), null, 2); }, }, get_course_module: { description: `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.`, 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'), }, 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); }, }, };

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/General-Mudkip/d2l-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server