Skip to main content
Glama

create_announcement

Create and schedule course announcements in Canvas by specifying title, message, and optional posting/lock dates for targeted student communication.

Instructions

Create a new announcement for a course with optional scheduling.

Args: course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID title: The title/subject of the announcement message: The content/body of the announcement delayed_post_at: Optional ISO 8601 datetime to schedule posting (e.g., "2024-01-15T12:00:00Z") lock_at: Optional ISO 8601 datetime to automatically lock the announcement

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_identifierYes
delayed_post_atNo
lock_atNo
messageYes
titleYes

Implementation Reference

  • The core handler function implementing the 'create_announcement' MCP tool. It creates an announcement by posting a discussion topic to the Canvas API with 'is_announcement': True, handling scheduling options, and returning formatted success details.
    @mcp.tool() @validate_params async def create_announcement(course_identifier: str | int, title: str, message: str, delayed_post_at: str | None = None, lock_at: str | None = None) -> str: """Create a new announcement for a course with optional scheduling. Args: course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID title: The title/subject of the announcement message: The content/body of the announcement delayed_post_at: Optional ISO 8601 datetime to schedule posting (e.g., "2024-01-15T12:00:00Z") lock_at: Optional ISO 8601 datetime to automatically lock the announcement """ course_id = await get_course_id(course_identifier) data = { "title": title, "message": message, "is_announcement": True, "published": True } if delayed_post_at: data["delayed_post_at"] = delayed_post_at if lock_at: data["lock_at"] = lock_at response = await make_canvas_request( "post", f"/courses/{course_id}/discussion_topics", data=data ) if "error" in response: return f"Error creating announcement: {response['error']}" announcement_id = response.get("id") announcement_title = response.get("title", title) created_at = format_date(response.get("created_at")) course_display = await get_course_code(course_id) or course_identifier return f"Announcement created successfully in course {course_display}:\n\n" + \ f"ID: {announcement_id}\n" + \ f"Title: {announcement_title}\n" + \ f"Created: {created_at}"
  • Registration call within register_all_tools() that invokes register_discussion_tools(mcp), which defines and registers the create_announcement tool via decorator.
    register_discussion_tools(mcp)
  • Import of register_discussion_tools from discussions.py, enabling its use in tool registration chain.
    from .other_tools import register_other_tools
  • Type definition for AnnouncementInfo used in codebase for announcement data structures, relevant to the tool's input/output types.
    class AnnouncementInfo(TypedDict, total=False): id: int | str title: str message: str posted_at: str | None delayed_post_at: str | None lock_at: str | None published: bool is_announcement: bool
  • Cache utilities including get_course_id() used by create_announcement to resolve course_identifier to course_id.
    # Global cache for course codes to IDs course_code_to_id_cache: dict[str, str] = {} id_to_course_code_cache: dict[str, str] = {}

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/vishalsachdev/canvas-mcp'

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