Skip to main content
Glama

bulk_delete_announcements

Delete multiple announcements from a Canvas course simultaneously, with options to handle errors during batch processing.

Instructions

    Delete multiple announcements from a Canvas course.

    Args:
        course_identifier: The Canvas course code or ID
        announcement_ids: List of announcement IDs to delete
        stop_on_error: If True, stop processing on first error; if False, continue with remaining

    Returns:
        String with detailed results including successful and failed deletions

    Example usage:
        results = bulk_delete_announcements(
            "60366",
            ["925355", "925354", "925353"],
            stop_on_error=False
        )
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
course_identifierYes
announcement_idsYes
stop_on_errorNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function implementing the bulk_delete_announcements MCP tool. It iterates over a list of announcement IDs, fetches details, deletes each via Canvas API, tracks successes and failures, and returns a formatted summary.
    @mcp.tool()
    @validate_params
    async def bulk_delete_announcements(
        course_identifier: str | int,
        announcement_ids: list[str | int],
        stop_on_error: bool = False
    ) -> str:
        """
        Delete multiple announcements from a Canvas course.
    
        Args:
            course_identifier: The Canvas course code or ID
            announcement_ids: List of announcement IDs to delete
            stop_on_error: If True, stop processing on first error; if False, continue with remaining
    
        Returns:
            String with detailed results including successful and failed deletions
    
        Example usage:
            results = bulk_delete_announcements(
                "60366",
                ["925355", "925354", "925353"],
                stop_on_error=False
            )
        """
        course_id = await get_course_id(course_identifier)
    
        successful = []
        failed = []
    
        for announcement_id in announcement_ids:
            try:
                # Get announcement details first
                announcement = await make_canvas_request(
                    "get", f"/courses/{course_id}/discussion_topics/{announcement_id}"
                )
    
                if "error" in announcement:
                    failed.append({
                        "id": str(announcement_id),
                        "error": announcement["error"],
                        "message": "Failed to fetch announcement details"
                    })
                    if stop_on_error:
                        break
                    continue
    
                # Proceed with deletion
                response = await make_canvas_request(
                    "delete", f"/courses/{course_id}/discussion_topics/{announcement_id}"
                )
    
                if "error" in response:
                    failed.append({
                        "id": str(announcement_id),
                        "title": announcement.get("title", "Unknown Title"),
                        "error": response["error"],
                        "message": "Failed to delete announcement"
                    })
                    if stop_on_error:
                        break
                else:
                    successful.append({
                        "id": str(announcement_id),
                        "title": announcement.get("title", "Unknown Title")
                    })
    
            except Exception as e:
                failed.append({
                    "id": str(announcement_id),
                    "error": str(e),
                    "message": "Unexpected error during deletion"
                })
                if stop_on_error:
                    break
    
        # Format results
        summary = {
            "total": len(announcement_ids),
            "successful": len(successful),
            "failed": len(failed)
        }
    
        course_display = await get_course_code(course_id) or course_identifier
        result = f"Bulk deletion results for course {course_display}:\n\n"
        result += f"Summary: {summary['successful']} successful, {summary['failed']} failed out of {summary['total']} total\n\n"
    
        if successful:
            result += "Successfully deleted:\n"
            for item in successful:
                result += f"  - ID: {item['id']}, Title: {item['title']}\n"
            result += "\n"
    
        if failed:
            result += "Failed to delete:\n"
            for item in failed:
                result += f"  - ID: {item['id']}"
                if 'title' in item:
                    result += f", Title: {item['title']}"
                result += f", Error: {item['error']}\n"
    
        return result
  • Registration of discussion tools (including bulk_delete_announcements) in the main server setup.
    register_course_tools(mcp)
    register_assignment_tools(mcp)
    register_discussion_tools(mcp)
    register_other_tools(mcp)
    register_rubric_tools(mcp)
    register_peer_review_tools(mcp)
    register_peer_review_comment_tools(mcp)
    register_messaging_tools(mcp)
    register_student_tools(mcp)
    register_accessibility_tools(mcp)
    register_discovery_tools(mcp)
    register_code_execution_tools(mcp)
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: it's a destructive operation (implied by 'Delete'), includes error handling behavior via 'stop_on_error' parameter, and specifies the return format ('String with detailed results'). However, it doesn't mention permissions needed, rate limits, or whether deletions are reversible.

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 well-structured with clear sections (purpose, args, returns, example) and front-loaded with the core functionality. The example usage is helpful but slightly verbose; every sentence earns its place by adding value beyond the schema.

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

Completeness4/5

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

For a destructive bulk operation with 3 parameters and no annotations, the description is reasonably complete: it explains what the tool does, documents all parameters, describes the return value, and provides an example. With an output schema present, it doesn't need to detail return structure further. Minor gaps include lack of permission requirements or confirmation prompts.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining all three parameters: 'course_identifier' (Canvas course code or ID), 'announcement_ids' (list of IDs to delete), and 'stop_on_error' (control over error handling). The example usage further clarifies parameter formats and relationships.

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

Purpose5/5

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

The description clearly states the specific action ('Delete multiple announcements') and resource ('from a Canvas course'), distinguishing it from sibling tools like 'delete_announcement' (singular) and 'delete_announcements_by_criteria' (criteria-based). It explicitly mentions bulk deletion, which is a key differentiator.

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

Usage Guidelines3/5

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

The description implies usage through the example (deleting multiple announcements by ID), but doesn't explicitly state when to use this tool versus alternatives like 'delete_announcement' (for single deletions) or 'delete_announcements_by_criteria' (for criteria-based deletions). No guidance on prerequisites or error handling context is provided.

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

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