get_unread_count
Retrieve the number of unread conversations in Canvas LMS to monitor new messages and stay updated on course communications.
Instructions
Get number of unread conversations.
Returns:
Unread conversation count
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The main handler function for the 'get_unread_count' tool. It makes an API request to Canvas's /conversations/unread_count endpoint, handles errors, and returns the unread count or error details. The @mcp.tool() decorator registers this function as an MCP tool.@mcp.tool() async def get_unread_count() -> dict[str, Any]: """ Get number of unread conversations. Returns: Unread conversation count """ try: response = await make_canvas_request("get", "/conversations/unread_count") if "error" in response: return response return { "success": True, "unread_count": response.get("unread_count", 0) } except Exception as e: print(f"Error getting unread count: {str(e)}", file=sys.stderr) return {"error": f"Failed to get unread count: {str(e)}"}
- src/canvas_mcp/server.py:54-54 (registration)Within register_all_tools, this call to register_messaging_tools(mcp) executes the registration of the messaging tools module, including the get_unread_count tool via its decorator.register_messaging_tools(mcp)