canvas-mcp-server

canvas-mcp-server

0

The Canvas MCP Server is a Python-based implementation of the Model Context Protocol server, offering integration with the Canvas API. It provides several tools for retrieving information from Canvas, such as course details and assignments.

Canvas MCP Server

A Canvas Model Context Protocol (MCP) server implemented in Python using the canvas-lms-sdk. This server exposes Canvas API functionalities as MCP tools.

Prerequisites

  • Python 3.8+
  • uv (for installation, though pip can also be used)
  • Canvas API Credentials:
    • An API URL for your Canvas instance (e.g., https://<your-institution>.instructure.com)
    • An API Key generated from your Canvas account.

Setup

  1. Clone the repository (if you haven't already):

    git clone <repository-url>
    cd canvas-mcp-server
    
  2. Set Environment Variables: Export your Canvas API URL and Key as environment variables. Replace <your-canvas-api-url> and <your-canvas-api-key> with your actual credentials.

    export CANVAS_API_URL="<your-canvas-api-url>"
    export CANVAS_API_KEY="<your-canvas-api-key>"
    

    Note: For production environments, consider more secure ways to manage secrets.

  3. Install Dependencies: Use uv to install the required packages, including the canvas-lms-sdk:

    uv pip install -r requirements.txt # Assuming a requirements.txt might be added later
    uv pip install "git+https://github.com/avarant/canvas-lms-sdk.git#subdirectory=generated_python_sdk"
    uv pip install "mcp-sdk"
    

    Alternatively, if you prefer pip:

    # pip install -r requirements.txt 
    pip install "git+https://github.com/avarant/canvas-lms-sdk.git#subdirectory=generated_python_sdk"
    pip install "mcp-sdk"
    

Running the Server

Once the setup is complete and environment variables are set, run the server:

python main.py

The server will start and print messages indicating it's running and using the configured Canvas URL. It will listen for MCP client connections.

Available Tools

The server currently provides the following tools:

  • get_active_courses: Fetches the list of active courses for the current user.
  • get_assignments_for_course: Fetches the list of assignments for a specific course ID.
  • get_calendar_due_dates: Fetches calendar events (assignments) for specified context codes (defaults to user).
  • get_upcoming_assignments: Fetches upcoming calendar events (including assignments) for the user.
  • get_class_information: Fetches detailed information for a specific course ID.