get_announcements
Retrieve course announcements and news items posted by instructors, including titles, content, attachments, and posting details.
Instructions
Get course announcements/news items from instructors. Returns: title, body (text and HTML), created date, author, attachments, whether it's pinned. Use to answer: "Any new announcements?", "What did the professor post?", "Are there any updates?", "What's the latest news?"
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/news.ts:21-25 (handler)The handler function that executes the tool logic: fetches course announcements using the D2L client for the given orgUnitId, marshals the raw data, and returns a formatted JSON string.handler: async (args: { orgUnitId?: number }): Promise<string> => { const orgUnitId = getOrgUnitId(args.orgUnitId); const news = await client.getNews(orgUnitId) as RawAnnouncement[]; return JSON.stringify(marshalAnnouncements(news), null, 2); },
- src/tools/news.ts:18-20 (schema)Zod schema defining the input parameters for the tool, specifically the optional orgUnitId.schema: { orgUnitId: z.number().optional().describe('The course ID. Optional if D2L_COURSE_ID env var is set.'), },
- src/index.ts:129-137 (registration)Registration of the 'get_announcements' tool with the MCP server, wrapping the handler to return MCP-formatted content.server.tool( 'get_announcements', newsTools.get_announcements.description, { orgUnitId: newsTools.get_announcements.schema.orgUnitId }, async (args) => { const result = await newsTools.get_announcements.handler(args as { orgUnitId?: number }); return { content: [{ type: 'text', text: result }] }; } );
- src/tools/news.ts:7-13 (helper)Helper function to resolve the orgUnitId from provided argument or environment variable, with validation.function getOrgUnitId(provided?: number): number { const orgUnitId = provided ?? DEFAULT_COURSE_ID; if (!orgUnitId) { throw new Error('orgUnitId is required. Either provide it or set D2L_COURSE_ID environment variable.'); } return orgUnitId; }