list_pages
Retrieve and organize course pages from Canvas LMS by specifying a course identifier, with options to sort, filter by published status, and search content.
Instructions
List pages for a specific course.
Args:
course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID
sort: Sort criteria ('title', 'created_at', 'updated_at')
order: Sort order ('asc' or 'desc')
search_term: Search for pages containing this term in title or body
published: Filter by published status (True, False, or None for all)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| course_identifier | Yes | ||
| order | No | asc | |
| published | No | ||
| search_term | No | ||
| sort | No | title |
Implementation Reference
- The complete handler function for the 'list_pages' tool, decorated with @mcp.tool() for registration and @validate_params for schema validation. It fetches paginated pages from Canvas API, applies filters, formats the output with titles, URLs, status, and update dates.@mcp.tool() @validate_params async def list_pages(course_identifier: str | int, sort: str | None = "title", order: str | None = "asc", search_term: str | None = None, published: bool | None = None) -> str: """List pages for a specific course. Args: course_identifier: The Canvas course code (e.g., badm_554_120251_246794) or ID sort: Sort criteria ('title', 'created_at', 'updated_at') order: Sort order ('asc' or 'desc') search_term: Search for pages containing this term in title or body published: Filter by published status (True, False, or None for all) """ course_id = await get_course_id(course_identifier) params = {"per_page": 100} if sort: params["sort"] = sort if order: params["order"] = order if search_term: params["search_term"] = search_term if published is not None: params["published"] = published pages = await fetch_all_paginated_results(f"/courses/{course_id}/pages", params) if isinstance(pages, dict) and "error" in pages: return f"Error fetching pages: {pages['error']}" if not pages: return f"No pages found for course {course_identifier}." pages_info = [] for page in pages: url = page.get("url", "No URL") title = page.get("title", "Untitled page") published_status = "Published" if page.get("published", False) else "Unpublished" is_front_page = page.get("front_page", False) updated_at = format_date(page.get("updated_at")) front_page_indicator = " (Front Page)" if is_front_page else "" pages_info.append( f"URL: {url}\nTitle: {title}{front_page_indicator}\nStatus: {published_status}\nUpdated: {updated_at}\n" ) course_display = await get_course_code(course_id) or course_identifier return f"Pages for Course {course_display}:\n\n" + "\n".join(pages_info)
- src/canvas_mcp/server.py:50-50 (registration)The call to register_other_tools(mcp) in the server's register_all_tools function, which triggers the registration of the list_pages tool (and other tools in that module).register_other_tools(mcp)