canvas_list_courses
Retrieve a list of all courses for the current user in Canvas, with the option to include ended courses, enabling efficient course management and navigation within the learning management system.
Instructions
List all courses for the current user
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_ended | No | Include ended courses |
Input Schema (JSON Schema)
{
"properties": {
"include_ended": {
"description": "Include ended courses",
"type": "boolean"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- src/index.ts:51-61 (registration)Registration of the canvas_list_courses tool in the TOOLS array, including name, description, and input schema.{ name: "canvas_list_courses", description: "List all courses for the current user", inputSchema: { type: "object", properties: { include_ended: { type: "boolean", description: "Include ended courses" } }, required: [] } },
- src/index.ts:1093-1099 (handler)MCP server handler that processes the tool call, extracts arguments, calls CanvasClient.listCourses, and returns JSON response.case "canvas_list_courses": { const { include_ended = false } = args as { include_ended?: boolean }; const courses = await this.client.listCourses(include_ended); return { content: [{ type: "text", text: JSON.stringify(courses, null, 2) }] }; }
- src/client.ts:212-223 (handler)Core implementation in CanvasClient that makes the API call to Canvas /courses endpoint with appropriate parameters based on includeEnded flag.async listCourses(includeEnded: boolean = false): Promise<CanvasCourse[]> { const params: any = { include: ['total_students', 'teachers', 'term', 'course_progress'] }; if (!includeEnded) { params.state = ['available', 'completed']; } const response = await this.client.get('/courses', { params }); return response.data; }
- src/types.ts:68-81 (schema)TypeScript interface defining the CanvasCourse type returned by the listCourses method.export interface CanvasCourse { readonly id: CourseId; readonly name: string; readonly course_code: string; readonly workflow_state: CanvasCourseState; readonly account_id: number; readonly start_at: string | null; readonly end_at: string | null; readonly enrollments?: ReadonlyArray<CanvasEnrollment>; readonly total_students?: number; readonly syllabus_body?: string; readonly term?: CanvasTerm; readonly course_progress?: CanvasCourseProgress; }