get_discussion_topic_details
Retrieve detailed information about a specific discussion topic in a Canvas course by providing the course identifier and topic ID.
Instructions
Get detailed information about a specific discussion topic.
Args:
course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID
topic_id: The Canvas discussion topic ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| course_identifier | Yes | ||
| topic_id | Yes |
Implementation Reference
- The handler function for the 'get_discussion_topic_details' tool. It fetches discussion topic details from the Canvas API using make_canvas_request, extracts key information like title, author, dates, statistics, and settings, formats it into a readable string, and returns it.@mcp.tool() @validate_params async def get_discussion_topic_details(course_identifier: str | int, topic_id: str | int) -> str: """Get detailed information about a specific discussion topic. Args: course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID topic_id: The Canvas discussion topic ID """ course_id = await get_course_id(course_identifier) response = await make_canvas_request( "get", f"/courses/{course_id}/discussion_topics/{topic_id}" ) if "error" in response: return f"Error fetching discussion topic details: {response['error']}" # Extract topic details title = response.get("title", "Untitled") message = response.get("message", "") is_announcement = response.get("is_announcement", False) author = response.get("author", {}) author_name = author.get("display_name", "Unknown author") author_id = author.get("id", "Unknown") created_at = format_date(response.get("created_at")) posted_at = format_date(response.get("posted_at")) # Discussion statistics discussion_entries_count = response.get("discussion_entries_count", 0) unread_count = response.get("unread_count", 0) read_state = response.get("read_state", "unknown") # Topic settings locked = response.get("locked", False) pinned = response.get("pinned", False) require_initial_post = response.get("require_initial_post", False) # Format the output course_display = await get_course_code(course_id) or course_identifier topic_type = "Announcement" if is_announcement else "Discussion" result = f"{topic_type} Details for Course {course_display}:\n\n" result += f"Title: {title}\n" result += f"ID: {topic_id}\n" result += f"Type: {topic_type}\n" result += f"Author: {author_name} (ID: {author_id})\n" result += f"Created: {created_at}\n" result += f"Posted: {posted_at}\n" if locked: result += "Status: Locked\n" if pinned: result += "Pinned: Yes\n" if require_initial_post: result += "Requires Initial Post: Yes\n" result += f"Total Entries: {discussion_entries_count}\n" if unread_count > 0: result += f"Unread Entries: {unread_count}\n" result += f"Read State: {read_state.title()}\n" if message: result += f"\nContent:\n{message}" return result
- src/canvas_mcp/server.py:49-49 (registration)The registration of discussion tools, including 'get_discussion_topic_details', occurs here via the call to register_discussion_tools(mcp) within the register_all_tools function.register_discussion_tools(mcp)
- src/canvas_mcp/tools/__init__.py:5-5 (registration)Import of register_discussion_tools from discussions.py, enabling its use in the main server registration.from .discussions import register_discussion_tools