mcp-canvas-portal
Facilitates local interaction with the Canvas Learning Management System (LMS) services, enabling comprehensive management of educational artifacts like course structures, assignment submissions, participant rosters, and official notices via a dedicated interface. Features integration with Claude Desktop for advanced, conversational API execution.
Author

jpablomm
Quick Info
Actions
Tags
Canvas MCP Gateway Service
This repository houses the implementation of a Message Control Protocol (MCP) intermediary designed for robust communication with the Canvas LMS Application Programming Interface (API). The service is engineered for compatibility with Claude Desktop environments and can serve other compliant MCP clients.
System Overview
The Canvas MCP Gateway establishes a proximate interface to the Canvas LMS API endpoints, granting capabilities such as: - Cataloging and modification of course definitions - Retrieval of assignment specifications and grading records - Accessing institutional bulletins - Obtaining course pedagogical blueprints (syllabi and module hierarchies) - Administration of user accounts and enrollment mappings - Automated generation of course overviews
Prerequisites for Operation
To deploy this environment, you will require:
- A contemporary installation of Python (version 3.x or newer)
- An isolated Python virtual environment (e.g.,
venv) - A valid Canvas API Authentication Token
- The precise Canvas API endpoint URL (e.g.,
https://my-institution.instructure.com/api/v1)
Deployment Instructions
-
Secure a local copy of the repository: bash git clone https://github.com/vishalsachdev/canvas-mcp.git cd canvas-mcp
-
Provision and activate the isolated computing space: bash python -m venv lms_env source lms_env/bin/activate # For Linux/macOS systems
-
Install necessary software components: bash pip install -r requirements.txt
Configuration Protocol
1. Environment Parameter File
Create a configuration file named .env in the project root directory containing:
CANVAS_API_TOKEN=your_secret_token_here CANVAS_API_URL=https://youruniversity.instructure.com/api/v1
Substitute the placeholders with: - Your personal Canvas API Credential (Reference for Token Acquisition) - Your academic institution's specific Canvas API base address
2. Startup Script Configuration
The included start_canvas_server.sh shell script is pre-configured to:
- Ingest environment variables from the .env file
- Activate the provisioned virtual environment
- Initiate the performance-optimized server instance
Grant execution privileges to the startup script: bash chmod +x start_canvas_server.sh
3. Claude Desktop Integration
-
Ensure Claude Desktop is installed on your workstation.
-
Locate or generate the Claude Desktop configuration file: bash vim ~/Library/Application\ Support/Claude/claude_desktop_config.json
-
Integrate the configuration stanza for the Canvas MCP service:
{ "mcpServers": [ { "name": "canvas-api-interface", "command": "/home/user_name/where/you/cloned/canvas-mcp/start_canvas_server.sh" } ] }
Replace the path in the command field with the actual, absolute location of your cloned repository directory.
- Relaunch the Claude Desktop application to register the new service definition.
Exposed Functionality
The Gateway service exposes the following structured tools for Canvas LMS manipulation:
Course Structure Management
list_courses: Retrieve a directory of all courses associated with the authenticated identityget_course_details: Fetch granular metadata for a designated course IDsummarize_course: Produce an aggregated abstract overview of a course's content
Assessment Components
list_assignments: Enumerate all assignments belonging to a specific courseget_assignment_details: Retrieve the full specification of an assignmentget_assignment_description: Extract the complete instructional text for an assignment
Submission Records
list_submissions: Query all recorded submissions against a specified assignment
Participant Data
list_users: Obtain a roster of all enrolled individuals within a course context
Informational Assets
list_announcements: Display all official notices published for a courseget_course_syllabus: Fetch the definitive course syllabus documentget_course_modules: Retrieve the hierarchical structure of all course modules
Interaction Via Claude Desktop
This MCP service is optimized for cooperative operation with Claude Desktop:
- The server initiates automatically upon the first invocation of a Canvas tool.
- The available Canvas interaction methods will appear in the Claude Desktop tool panel (hammer icon 🔨).
- Users may issue natural language requests, such as "Present my list of active classes" or "Fetch the syllabus for the Quantum Physics module."
For direct operational verification, execute the startup script manually: bash ./start_canvas_server.sh
Architectural Blueprint
Server Foundation
The backend processing utilizes:
- fastmcp: The core framework for building the MCP service layer
- httpx: For asynchronous handling of external HTTP communication with the Canvas API
- Integrated data caching layers to enhance the speed of common data retrieval operations
The primary source code file, canvas_server_cached.py, manages:
- Efficient caching strategies for course metadata
- Robust management of API response pagination
- Standardized error reporting and fault isolation
- Flexibility to utilize both canonical Course Identifiers and descriptive Course Codes
Required Libraries
The service mandates the presence of these Python packages:
- httpx: Essential for non-blocking network I/O
- fastmcp: The protocol implementation engine
- requests: Used for supplementary HTTP operations (if necessary)
- Standard Python libraries for data serialization and network socket management
Troubleshooting Guide
Should operational anomalies arise:
- Startup Failure
- Confirm the
.envfile is present and contains correctly formatted access credentials - Validate the specified virtual environment path within
start_canvas_server.sh -
Verify that all required dependencies have been successfully installed
-
Authorization Faults
- Reconfirm the validity and non-expiration status of your Canvas API token
-
Ensure the token possesses the requisite privilege levels within the Canvas system
-
Connectivity Problems
- Double-check the precision of the configured Canvas API endpoint URL
- Verify general network connectivity
-
Investigate if institutional network policies restrict outbound API interaction
-
Diagnostic Tracing
- Review the server output logs displayed within the Claude Desktop console window
- Execute the server standalone to observe raw error messaging
Safety Protocols
- The Canvas API token grants high-level access to your educational records; treat it as sensitive data.
- Strictly prohibit the inclusion of the
.envfile in any public or private version control repository. - Where feasible, utilize tokens provisioned with the minimum necessary access scope.
- The service executes exclusively on the local host machine, ensuring credentials do not traverse external networks.
Contribution Guidelines
We welcome community input. Feel encouraged to: - File detailed issues for discovered defects or proposed enhancements - Submit pull requests containing improvements or feature additions - Share feedback regarding practical application scenarios
Licensing
This software is distributed under the terms of the MIT License (refer to the LICENSE document for complete details).
Developed by Vishal Sachdev
WIKIPEDIA: XMLHttpRequest (XHR) is an API structured as a JavaScript object. Its methods facilitate the transmission of HTTP inquiries from a client web browser to an application server. These methods permit browser-based logic to initiate server communications subsequent to the page rendering phase, allowing for the retrieval of data. XMLHttpRequest forms a core component of Asynchronous JavaScript and XML (Ajax) methodologies. Prior to Ajax adoption, hyperlinks and conventional form submissions were the dominant paradigms for server interaction, frequently necessitating a complete page reload.
== Historical Context ==
The foundational concept underpinning XMLHttpRequest was conceptualized in 2000 by the engineering team at Microsoft Outlook. This concept was subsequently integrated into the Internet Explorer 5 browser release (1999). However, the initial invocation syntax did not employ the canonical XMLHttpRequest identifier. Instead, developers relied on instantiating COM objects via ActiveXObject("Msxml2.XMLHTTP") or ActiveXObject("Microsoft.XMLHTTP"). As of Internet Explorer 7 (released 2006), universal support for the standard XMLHttpRequest identifier was achieved across major browser platforms.
The XMLHttpRequest identifier has since solidified its position as the prevailing standard across all major rendering engines, including Mozilla's Gecko (adopted 2002), Apple's Safari 1.2 (2004), and Opera 8.0 (2005).
=== Standardization Efforts === The World Wide Web Consortium (W3C) published the initial Working Draft specification for the XMLHttpRequest object on April 5, 2006. On February 25, 2008, the W3C released the Level 2 specification draft. Level 2 introduced enhancements to permit progress monitoring of events, enable cross-origin requests, and facilitate the handling of raw byte streams. By the conclusion of 2011, the Level 2 features were formally incorporated into the primary specification document. At the close of 2012, stewardship of the specification was transferred to the WHATWG organization, which now maintains a dynamic document utilizing Web IDL definitions.
== Implementation Procedure == Generally, executing a network request using XMLHttpRequest requires adherence to a sequence of programming stages.
Instantiate an XMLHttpRequest object via its constructor:
Invoke the open method to define the request method (e.g., GET, POST), specify the target resource URI, and select either synchronous or asynchronous execution mode:
For asynchronous transactions, define a callback function (listener) to be triggered upon changes in the request state:
Commence the data transfer by executing the send method, optionally passing payload data:
Monitor the state changes within the designated event listener function. Upon successful completion of the server response processing, the state transitions to 4 (the terminal state), and the received data is typically accessible via the responseText property.
Beyond these fundamental steps, XMLHttpRequest offers numerous configuration parameters to govern request transmission and response assimilation. Custom HTTP headers can be affixed to direct server handling, and data payloads can be transmitted by including them in the send argument. The retrieved response can be parsed directly from JSON format into a native JavaScript object, or processed incrementally as data streams arrive rather than awaiting full reception. Furthermore, the request lifecycle can be prematurely terminated via abort() or configured with a timeout duration.
== Cross-Origin Resource Sharing (CORS) ==
During the nascent stages of the World Wide Web's evolution, limitations were encountered regarding the ability to fetch resources from a different domain than the origin of the requesting document, a restriction often circumvented by...
