get_discussion_topic_details
Retrieve comprehensive details about a specific Canvas discussion topic using course identifier and topic ID to access information for academic management.
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 primary handler implementation for the 'get_discussion_topic_details' MCP tool. This async function fetches detailed information about a Canvas discussion topic using the course identifier and topic ID, processes the API response to extract key metadata (title, author, dates, stats, settings), formats it into a readable string, and returns it. Decorated with @mcp.tool() for automatic registration and @validate_params for input validation based on type hints.@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:42-64 (registration)Registration point for all tools including discussions. The register_discussion_tools(mcp) call at line 49 triggers the definition and @mcp.tool() registration of get_discussion_topic_details within the discussions.py module's register_discussion_tools function.def register_all_tools(mcp: FastMCP) -> None: """Register all MCP tools, resources, and prompts.""" log_info("Registering Canvas MCP tools...") # Register tools by category 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) # Register resources and prompts register_resources_and_prompts(mcp) log_info("All Canvas MCP tools registered successfully!")
- src/canvas_mcp/tools/__init__.py:1-6 (registration)Imports register_discussion_tools from discussions.py, enabling its use in server.py for tool registration chain."""Tool modules for Canvas MCP server.""" from .courses import register_course_tools from .assignments import register_assignment_tools from .discussions import register_discussion_tools from .other_tools import register_other_tools