Skip to main content
Glama

Get Announcements

get_announcements

Retrieve course announcements and instructor updates from Brightspace. Filter by specific course or view recent posts across all courses to stay informed about class news.

Instructions

Fetch recent announcements from your courses. Can filter to a specific course or get announcements across all courses. Use this when the user asks about announcements, news, updates from instructors, recent posts, or what professors said.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
courseIdNoCourse ID to get announcements for. If omitted, returns recent announcements across all courses.
countNoMaximum number of announcements to return

Implementation Reference

  • Main handler implementation for get_announcements tool. Contains the registerGetAnnouncements function that registers the MCP tool and the async handler (lines 70-189) that executes the logic. Handles both single course and all courses scenarios, filters enrollments, fetches announcements from the D2L API, sorts by date, and returns results.
    export function registerGetAnnouncements(
      server: McpServer,
      apiClient: D2LApiClient,
      config: AppConfig
    ): void {
      server.registerTool(
        "get_announcements",
        {
          title: "Get Announcements",
          description:
            "Fetch recent announcements from your courses. Can filter to a specific course or get announcements across all courses. Use this when the user asks about announcements, news, updates from instructors, recent posts, or what professors said.",
          inputSchema: GetAnnouncementsSchema,
        },
        async (args: any) => {
          try {
            log("DEBUG", "get_announcements tool called", { args });
    
            // Parse and validate input
            const { courseId, count } = GetAnnouncementsSchema.parse(args);
    
            // Single course case
            if (courseId) {
              const path = apiClient.le(courseId, "/news/");
              const newsItems = await apiClient.get<NewsItem[]>(path, {
                ttl: DEFAULT_CACHE_TTLS.announcements,
              });
    
              // Map to clean objects
              const announcements = newsItems
                .map((item) => ({
                  id: item.Id,
                  title: item.Title,
                  body: item.Body.Text,
                  createdBy: item.CreatedBy.DisplayName,
                  createdDate: item.CreatedDate,
                  startDate: item.StartDate,
                  isPinned: item.IsPinned,
                }))
                .sort(
                  (a, b) =>
                    new Date(b.createdDate).getTime() -
                    new Date(a.createdDate).getTime()
                )
                .slice(0, count);
    
              log(
                "INFO",
                `get_announcements: Retrieved ${announcements.length} announcements for course ${courseId}`
              );
              return toolResponse(announcements);
            }
    
            // All courses case
            // First, fetch enrolled courses
            const enrollmentPath = apiClient.lp(
              "/enrollments/myenrollments/?orgUnitTypeId=3&isActive=true"
            );
            const enrollmentResponse = await apiClient.get<EnrollmentResponse>(
              enrollmentPath,
              { ttl: DEFAULT_CACHE_TTLS.enrollments }
            );
    
            // Apply course filter
            const filteredEnrollments = applyCourseFilter(
              enrollmentResponse.Items.map(item => ({
                id: item.OrgUnit.Id,
                name: item.OrgUnit.Name,
                code: item.OrgUnit.Code,
                isActive: item.Access.IsActive,
                ...item,
              })),
              config.courseFilter
            );
    
            // Fetch announcements for each course (handle 403s gracefully)
            const announcementPromises = filteredEnrollments.map(
              async (item) => {
                try {
                  const path = apiClient.le(item.OrgUnit.Id, "/news/");
                  const newsItems = await apiClient.get<NewsItem[]>(path, {
                    ttl: DEFAULT_CACHE_TTLS.announcements,
                  });
    
                  return newsItems.map((newsItem) => ({
                    id: newsItem.Id,
                    title: newsItem.Title,
                    body: newsItem.Body.Text,
                    createdBy: newsItem.CreatedBy.DisplayName,
                    createdDate: newsItem.CreatedDate,
                    startDate: newsItem.StartDate,
                    isPinned: newsItem.IsPinned,
                    courseId: item.OrgUnit.Id,
                    courseName: item.OrgUnit.Name,
                  }));
                } catch (error: any) {
                  // 403 means no access (past course, etc) - log and skip
                  if (error?.status === 403) {
                    log(
                      "DEBUG",
                      `get_announcements: 403 Forbidden for course ${item.OrgUnit.Id} (${item.OrgUnit.Name}) - skipping`
                    );
                    return [];
                  }
                  throw error; // Re-throw other errors
                }
              }
            );
    
            const results = await Promise.allSettled(announcementPromises);
            const allAnnouncements = results
              .filter(
                (r): r is PromiseFulfilledResult<any> => r.status === "fulfilled"
              )
              .flatMap((r) => r.value);
    
            // Sort by created date and slice to count
            const announcements = allAnnouncements
              .sort(
                (a, b) =>
                  new Date(b.createdDate).getTime() -
                  new Date(a.createdDate).getTime()
              )
              .slice(0, count);
    
            log(
              "INFO",
              `get_announcements: Retrieved ${announcements.length} announcements (out of ${allAnnouncements.length} total across ${enrollmentResponse.Items.length} courses)`
            );
            return toolResponse(announcements);
          } catch (error) {
            return sanitizeError(error);
          }
        }
      );
    }
  • Input validation schema for get_announcements tool using Zod. Defines optional courseId parameter to filter to a specific course, and count parameter (default 10, max 50) to limit the number of announcements returned.
    export const GetAnnouncementsSchema = z.object({
      courseId: z.number().int().positive().optional().describe("Course ID to get announcements for. If omitted, returns recent announcements across all courses."),
      count: z.number().int().min(1).max(50).default(10).describe("Maximum number of announcements to return"),
    });
  • src/index.ts:168-168 (registration)
    Tool registration call in main server initialization. Invokes registerGetAnnouncements with the MCP server instance, D2L API client, and app configuration to make the tool available to clients.
    registerGetAnnouncements(server, apiClient, config);
  • Export statement for registerGetAnnouncements function in the tools barrel file, making it available for import in the main server file.
    export { registerGetAnnouncements } from "./get-announcements.js";
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions filtering capabilities but doesn't describe what 'recent' means, whether there's pagination, rate limits, authentication requirements, or what format the announcements are returned in. For a read operation with no annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences that each serve distinct purposes - the first states the core functionality, the second provides usage guidance. It's front-loaded with the main purpose, though the second sentence could be slightly more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read operation with 2 parameters and no output schema, the description covers basic purpose and usage but lacks important context about what 'recent' means, how results are ordered, whether there are limits beyond the count parameter, and what the return format looks like. With no annotations and no output schema, more behavioral detail would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description adds marginal value by mentioning the filtering capability ('Can filter to a specific course or get announcements across all courses') but doesn't provide additional semantic context beyond what's in the parameter descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('fetch recent announcements') and resources ('from your courses'), distinguishing it from siblings like get_assignments or get_discussions. However, it doesn't explicitly differentiate from similar tools beyond mentioning filtering capabilities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('when the user asks about announcements, news, updates from instructors, recent posts, or what professors said'), but doesn't explicitly state when NOT to use it or mention specific alternatives among the sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/RohanMuppa/brightspace-mcp-server'

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