get_course_details
Retrieve comprehensive course information from Canvas LMS using a course code or ID to access details like assignments, materials, and announcements.
Instructions
Get detailed information about a specific course.
Args:
course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| course_identifier | Yes |
Implementation Reference
- src/canvas_mcp/tools/courses.py:88-121 (handler)The handler function for the 'get_course_details' MCP tool. It resolves the course identifier to an ID, fetches course details from the Canvas API, updates caches, and returns a formatted string with key course information including code, name, dates, time zone, etc.@mcp.tool() @validate_params async def get_course_details(course_identifier: str | int) -> str: """Get detailed information about a specific course. Args: course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID """ course_id = await get_course_id(course_identifier) response = await make_canvas_request("get", f"/courses/{course_id}") if "error" in response: return f"Error fetching course details: {response['error']}" # Update our caches with the course data if "id" in response and "course_code" in response: course_code_to_id_cache[response["course_code"]] = str(response["id"]) id_to_course_code_cache[str(response["id"])] = response["course_code"] details = [ f"Code: {response.get('course_code', 'N/A')}", f"Name: {response.get('name', 'N/A')}", f"Start Date: {format_date(response.get('start_at'))}", f"End Date: {format_date(response.get('end_at'))}", f"Time Zone: {response.get('time_zone', 'N/A')}", f"Default View: {response.get('default_view', 'N/A')}", f"Public: {response.get('is_public', False)}", f"Blueprint: {response.get('blueprint', False)}" ] # Prefer to show course code in the output course_display = response.get("course_code", course_identifier) return f"Course Details for {course_display}:\n\n" + "\n".join(details)
- src/canvas_mcp/server.py:47-47 (registration)The registration call for course tools (including get_course_details) in the main server setup function register_all_tools.register_course_tools(mcp)
- src/canvas_mcp/tools/courses.py:40-40 (registration)The function that registers all course-related tools, including get_course_details, by applying @mcp.tool() decorators to the handler functions.def register_course_tools(mcp: FastMCP):