Skip to main content
Glama

delete_announcement

Remove announcements from Canvas courses by specifying the course identifier and announcement ID to manage course content effectively.

Instructions

    Delete an announcement from a Canvas course.

    Announcements are technically discussion topics in Canvas, so this uses
    the discussion_topics endpoint to delete them.

    Args:
        course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID
        announcement_id: The Canvas announcement/discussion topic ID to delete

    Returns:
        String describing the deletion result with status and title

    Raises:
        HTTPError:
            - 401: User doesn't have permission to delete the announcement
            - 404: Announcement not found in the specified course
            - 403: Editing is restricted for this announcement

    Example usage:
        result = delete_announcement("60366", "925355")
        print(f"Result: {result}")
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_identifierYes
announcement_idYes

Implementation Reference

  • Core handler function that implements the 'delete_announcement' tool. Fetches announcement details, performs DELETE request to Canvas API /courses/{course_id}/discussion_topics/{announcement_id}, and returns success/error message with title.
    @mcp.tool()
    @validate_params
    async def delete_announcement(
        course_identifier: str | int,
        announcement_id: str | int
    ) -> str:
        """
        Delete an announcement from a Canvas course.
    
        Announcements are technically discussion topics in Canvas, so this uses
        the discussion_topics endpoint to delete them.
    
        Args:
            course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID
            announcement_id: The Canvas announcement/discussion topic ID to delete
    
        Returns:
            String describing the deletion result with status and title
    
        Raises:
            HTTPError:
                - 401: User doesn't have permission to delete the announcement
                - 404: Announcement not found in the specified course
                - 403: Editing is restricted for this announcement
    
        Example usage:
            result = delete_announcement("60366", "925355")
            print(f"Result: {result}")
        """
        course_id = await get_course_id(course_identifier)
    
        # First, get the announcement details to return meaningful information
        announcement = await make_canvas_request(
            "get", f"/courses/{course_id}/discussion_topics/{announcement_id}"
        )
    
        if "error" in announcement:
            return f"Error fetching announcement details: {announcement['error']}"
    
        announcement_title = announcement.get("title", "Unknown Title")
    
        # Proceed with deletion
        response = await make_canvas_request(
            "delete", f"/courses/{course_id}/discussion_topics/{announcement_id}"
        )
    
        if "error" in response:
            return f"Error deleting announcement '{announcement_title}': {response['error']}"
    
        course_display = await get_course_code(course_id) or course_identifier
        return f"Announcement deleted successfully from course {course_display}:\n\n" + \
               f"ID: {announcement_id}\n" + \
               f"Title: {announcement_title}\n" + \
               "Status: deleted\n" + \
               "Message: Announcement deleted successfully"
  • The register_discussion_tools function decorates and registers the delete_announcement handler (and other discussion tools) with the MCP server using @mcp.tool().
    def register_discussion_tools(mcp: FastMCP):
        """Register all discussion and announcement MCP tools."""
  • Invocation of register_discussion_tools(mcp) in register_all_tools, which registers the delete_announcement tool among others.
    register_discussion_tools(mcp)
  • Type definition for AnnouncementInfo, relevant for handling announcement data structures in Canvas API responses.
    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
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/vishalsachdev/canvas-mcp'

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