Skip to main content
Glama

list_courses

Retrieve a list of enrolled Canvas courses with details including ID, name, course code, and term. Filter to show only active courses if needed.

Instructions

List enrolled courses. Returns id, name, course_code, term.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
active_onlyNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The tool handler for 'list_courses'. Decorated with @mcp.tool(), it fetches courses from Canvas API /api/v1/courses, optionally filtering by active enrollment state, and returns a list of dicts with id, name, and course_code.
    @mcp.tool()
    def list_courses(active_only: bool = True) -> list[dict]:
        """List enrolled courses. Returns id, name, course_code, term."""
        p = "/api/v1/courses"
        params = {"enrollment_state": "active"} if active_only else {}
        cs = _get(p, **params)
        return [{"id": c["id"], "name": c.get("name"), "course_code": c.get("course_code")} for c in cs]
  • The @mcp.tool() decorator registers 'list_courses' as an MCP tool via the FastMCP instance.
    @mcp.tool()
    def list_courses(active_only: bool = True) -> list[dict]:
  • The _get helper function that performs paginated HTTP GET requests to the Canvas API, used by list_courses to fetch course data.
    def _get(path: str, **params) -> Any:
        params.setdefault("per_page", 100)
        url = f"{BASE}{path}"
        out = []
        with httpx.Client(headers=HEAD, timeout=30) as c:
            while url:
                r = c.get(url, params=params)
                r.raise_for_status()
                data = r.json()
                if isinstance(data, list):
                    out.extend(data)
                else:
                    return data
                url = None
                params = {}
                link = r.headers.get("Link", "")
                for part in link.split(","):
                    if 'rel="next"' in part:
                        url = part[part.find("<")+1:part.find(">")]
        return out
Behavior2/5

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

No annotations provided, and the description only states the basic action and returned fields, lacking details on side effects or limitations.

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 concise at one sentence, but could be more structured by including parameter info.

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

Completeness2/5

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

Given the sibling tools and the output schema, the description lacks parameter elaboration and usage context, making it incomplete.

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

Parameters1/5

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

The schema has one parameter (active_only) with default true, but the description provides no explanation of its meaning or purpose.

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 'List enrolled courses' and lists returned fields, but does not differentiate from sibling list tools.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs alternatives like list_assignments or list_modules.

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/admin978/canvas-mcp'

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