Skip to main content
Glama
brendan-ch

Canvas Assignment Assistant

by brendan-ch

canvas_list_active_courses

Retrieve your currently active Canvas courses using the dashboard API for faster access to current semester classes.

Instructions

Lists only your active/current courses using the dashboard API. Much faster than list_courses.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the tool logic: fetches active courses from Canvas dashboard API and returns a formatted text list or error.
    async () => {
      try {
        const dashboardCards = await canvasApiRequest<any[]>(`/dashboard/dashboard_cards`);
    
        if (dashboardCards.length === 0) {
          return {
            content: [{
              type: "text",
              text: "No active courses found in your dashboard."
            }]
          };
        }
    
        const courseList = dashboardCards.map((card) => {
          const termName = card.term ? `(${card.term})` : '';
          return `- ID: ${card.id} | ${card.shortName} ${termName}`;
        }).join('\n');
    
        return {
          content: [{
            type: "text",
            text: `Your active courses:\n\n${courseList}`
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Failed to fetch active courses: ${(error as Error).message}`
          }],
          isError: true
        };
      }
    }
  • The server.tool() registration of the canvas_list_active_courses tool, including name, description, empty input schema, and handler reference.
    server.tool(
      "canvas_list_active_courses",
      "Lists only your active/current courses using the dashboard API. Much faster than list_courses.",
      {},
      async () => {
        try {
          const dashboardCards = await canvasApiRequest<any[]>(`/dashboard/dashboard_cards`);
    
          if (dashboardCards.length === 0) {
            return {
              content: [{
                type: "text",
                text: "No active courses found in your dashboard."
              }]
            };
          }
    
          const courseList = dashboardCards.map((card) => {
            const termName = card.term ? `(${card.term})` : '';
            return `- ID: ${card.id} | ${card.shortName} ${termName}`;
          }).join('\n');
    
          return {
            content: [{
              type: "text",
              text: `Your active courses:\n\n${courseList}`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: `Failed to fetch active courses: ${(error as Error).message}`
            }],
            isError: true
          };
        }
      }
    );
  • src/index.ts:25-25 (registration)
    The call to register the tool on the main MCP server instance in the entrypoint file.
    registerListActiveCoursesTool(server);
  • Supporting utility function canvasApiRequest used by the handler to perform authenticated GET/POST requests to the Canvas API.
    export async function canvasApiRequest<T>(path: string, method = 'GET', body?: any): Promise<T> {
      if (!canvasApiToken) {
        throw new Error("Canvas API token not set. Please check CANVAS_API_TOKEN environment variable.");
      }
    
      const url = `${getBaseUrl()}${path}`;
      const response = await fetch(url, {
        method,
        headers: {
          'Authorization': `Bearer ${canvasApiToken}`,
          'Content-Type': 'application/json',
        },
        body: body ? JSON.stringify(body) : undefined,
      });
    
      if (!response.ok) {
        const error = await response.text();
        throw new Error(`Canvas API error: ${response.status} - ${error}`);
      }
    
      return response.json() as Promise<T>;
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It adds useful context: it specifies the API used ('dashboard API') and a performance trait ('Much faster than list_courses'). However, it doesn't disclose other behavioral aspects such as authentication requirements, rate limits, pagination, or what 'active/current' means precisely (e.g., based on enrollment status or term dates). The description doesn't contradict any annotations, but it could be more comprehensive given the lack of annotations.

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

Conciseness5/5

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

The description is very concise and well-structured: two sentences that efficiently convey the tool's purpose and key advantage. Every sentence adds value—the first defines what it does, and the second provides a performance comparison. It's front-loaded with the core functionality, with no wasted words.

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 complexity (simple listing with no parameters) and the lack of annotations and output schema, the description is somewhat complete but has gaps. It covers the purpose and a performance hint but doesn't explain what 'active/current' entails, the return format, or any error conditions. For a tool with no structured behavioral data, more context on these aspects would improve completeness.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so the schema fully documents that no inputs are required. The description doesn't need to add parameter details, but it implicitly confirms this by not mentioning any parameters. Since there are no parameters, the baseline is 4, as the description doesn't detract from or conflict with the schema.

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 tool's purpose: 'Lists only your active/current courses using the dashboard API.' It specifies the verb ('Lists'), resource ('active/current courses'), and method ('dashboard API'), which is clear and specific. However, it doesn't explicitly distinguish this tool from its sibling 'list_courses' beyond mentioning it's 'much faster'—it could more directly contrast their scopes (active vs. all courses).

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

Usage Guidelines4/5

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

The description provides good usage guidance by stating when to use this tool: 'Lists only your active/current courses' and comparing it to an alternative: 'Much faster than list_courses.' This implies that 'list_courses' is a sibling tool for broader listing, but it doesn't explicitly state when not to use this tool (e.g., for archived or all courses) or name 'list_courses' as the direct alternative for non-active courses.

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