list_conversations
Retrieve user conversations from Canvas LMS with filtering options for scope, IDs, and participant details to organize message management.
Instructions
List conversations for the current user.
Args:
scope: Conversation scope ("unread", "starred", "sent", "archived", or "all")
filter_ids: Optional list of conversation IDs to filter by
filter_mode: How to apply filter_ids ("and" or "or")
include_participants: Include participant information
include_all_ids: Include all conversation participant IDs
Returns:
List of conversations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter_ids | No | ||
| filter_mode | No | and | |
| include_all_ids | No | ||
| include_participants | No | ||
| scope | No | unread |
Implementation Reference
- The handler function for the 'list_conversations' tool. It fetches conversations from Canvas API based on scope and filters, with input validation and error handling.@mcp.tool() async def list_conversations( scope: str = "unread", filter_ids: list[str] | None = None, filter_mode: str = "and", include_participants: bool = True, include_all_ids: bool = False ) -> dict[str, Any]: """ List conversations for the current user. Args: scope: Conversation scope ("unread", "starred", "sent", "archived", or "all") filter_ids: Optional list of conversation IDs to filter by filter_mode: How to apply filter_ids ("and" or "or") include_participants: Include participant information include_all_ids: Include all conversation participant IDs Returns: List of conversations """ valid_scopes = ["unread", "starred", "sent", "archived", "all"] if scope not in valid_scopes: return {"error": f"scope must be one of: {', '.join(valid_scopes)}"} try: params = { "scope": scope, "include_participants": include_participants, "include_all_conversation_ids": include_all_ids } if filter_ids: params["filter[]"] = filter_ids params["filter_mode"] = filter_mode response = await make_canvas_request("get", "/conversations", params=params) if "error" in response: return response return { "success": True, "conversations": response, "count": len(response) if isinstance(response, list) else 0 } except Exception as e: print(f"Error listing conversations: {str(e)}", file=sys.stderr) return {"error": f"Failed to list conversations: {str(e)}"}
- src/canvas_mcp/server.py:54-54 (registration)Registration call for messaging tools, including 'list_conversations', within the register_all_tools function.register_messaging_tools(mcp)
- src/canvas_mcp/tools/messaging.py:11-11 (registration)Function that registers all messaging tools, including the @mcp.tool() decorator for list_conversations.def register_messaging_tools(mcp: FastMCP) -> None: