Skip to main content
Glama
brendan-ch

Canvas Assignment Assistant

by brendan-ch

list_courses

Retrieve your enrolled courses from Canvas LMS with filtering options for active, completed, or all courses to organize your academic workflow.

Instructions

Lists all courses you are enrolled in, with options to filter by active, completed, or all courses.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateNoFilter courses by state: active, completed, or allactive

Implementation Reference

  • The handler function executes the tool logic: fetches courses from Canvas API filtered by state (active, completed, all), formats a list with IDs, names, and terms, or returns an error message.
    async ({ state }) => {
      try {
        const courses = await canvasApiRequest<CanvasCourse[]>(`/courses?enrollment_state=${state}&include[]=term`);
    
        if (courses.length === 0) {
          return {
            content: [{
              type: "text",
              text: `No ${state} courses found.`
            }]
          };
        }
    
        const courseList = courses.map((course) => {
          const termName = course.term ? `(${course.term.name})` : '';
          return `- ID: ${course.id} | ${course.name} ${termName}`;
        }).join('\n');
    
        return {
          content: [{
            type: "text",
            text: `Your ${state} courses:\n\n${courseList}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Failed to fetch courses: ${(error as Error).message}`
          }],
          isError: true
        };
      }
    }
  • Input schema using Zod: 'state' parameter as enum ['active', 'completed', 'all'] with default 'active'.
    {
      state: z.enum(['active', 'completed', 'all']).default('active')
        .describe("Filter courses by state: active, completed, or all"),
    },
  • The registerListCoursesTool function registers the 'list_courses' tool on the MCP server, specifying name, description, input schema, and handler.
    export function registerListCoursesTool(server: McpServer) {
      server.tool(
        "list_courses",
        "Lists all courses you are enrolled in, with options to filter by active, completed, or all courses.",
        {
          state: z.enum(['active', 'completed', 'all']).default('active')
            .describe("Filter courses by state: active, completed, or all"),
        },
        async ({ state }) => {
          try {
            const courses = await canvasApiRequest<CanvasCourse[]>(`/courses?enrollment_state=${state}&include[]=term`);
    
            if (courses.length === 0) {
              return {
                content: [{
                  type: "text",
                  text: `No ${state} courses found.`
                }]
              };
            }
    
            const courseList = courses.map((course) => {
              const termName = course.term ? `(${course.term.name})` : '';
              return `- ID: ${course.id} | ${course.name} ${termName}`;
            }).join('\n');
    
            return {
              content: [{
                type: "text",
                text: `Your ${state} courses:\n\n${courseList}`
              }]
            };
          } catch (error) {
            return {
              content: [{
                type: "text",
                text: `Failed to fetch courses: ${(error as Error).message}`
              }],
              isError: true
            };
          }
        }
      );
    }
  • src/index.ts:24-24 (registration)
    Main server initialization calls registerListCoursesTool to add the tool to the MCP server.
    registerListCoursesTool(server);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions filtering options but fails to cover critical aspects such as whether this is a read-only operation, potential rate limits, authentication requirements, or the format of returned data (e.g., pagination). This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Lists all courses you are enrolled in') and adds necessary detail about filtering. It avoids redundancy and wastes no words, though it could be slightly more structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameter context but lacks details on behavioral traits and output, which are needed for full agent understanding despite the simple schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already fully documents the single parameter 'state' with its enum values and default. The description adds minimal value by mentioning the filtering options, but doesn't provide additional semantics beyond what the schema specifies, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Lists') and resource ('courses you are enrolled in'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'canvas_list_active_courses' or 'search_assignments', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the phrase 'with options to filter by active, completed, or all courses,' suggesting when to use different parameter values. However, it lacks explicit guidance on when to choose this tool over alternatives like 'canvas_list_active_courses' or 'get_assignment,' leaving room for ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/brendan-ch/canvas-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server