Canvas MCP - AI-Powered Course Management Assistant
An intelligent assistant that integrates Canvas LMS, Google Calendar, and Gmail through Claude AI (via OpenRouter). Manage your courses, assignments, calendar events, and emails through natural language conversations.
π Features
Canvas Integration
- View Courses: List all your Canvas courses with details
- Assignment Management: View upcoming assignments, create new assignments, and delete assignments
- Daily Briefing: Get a comprehensive overview of your courses and upcoming assignments
- Time Zone Support: Automatic timezone handling for assignment due dates
Google Calendar Integration
- Event Management: List, create, update, and delete calendar events
- Smart Scheduling: Natural language event creation with automatic date/time parsing
- Event Search: Find events by date range or keywords
Gmail Integration
- Email Reading: Read and search through your emails
- Email Sending: Send emails with attachments
- Inbox Management: Search and filter your inbox
AI-Powered Interface
- Natural Language: Interact with all services using plain English
- Context-Aware: Maintains conversation history for better understanding
- Multi-Tool Execution: Automatically uses the right tools to answer your queries
π Prerequisites
- Python 3.8 or higher
- OpenRouter API key (Get one here)
- Canvas API key (from your Canvas account settings)
- Google Cloud Project with Calendar and Gmail APIs enabled
- OAuth 2.0 credentials for Google services
π οΈ Installation
Clone the repository:
git clone <repository-url> cd mcp-datathonInstall dependencies:
pip install -r requirements.txtSet up environment variables:
Create a .env file in the root directory:
# Required
OPENROUTER_API_KEY=your_openrouter_api_key
CANVAS_API_KEY=your_canvas_api_key
# Optional - Custom paths for Google credentials
CALENDAR_CREDENTIALS_PATH=credentials.json
CALENDAR_TOKEN_PATH=calendar_token.json
GMAIL_CREDENTIALS_PATH=credentials.json
GMAIL_TOKEN_PATH=token.json
USER_TIMEZONE=America/New_York
π§ Setup
Canvas API Setup
- Log in to your Canvas account
- Go to Account β Settings β Approved Integrations
- Click + New Access Token
- Give it a purpose (e.g., "MCP Server")
- Copy the generated token and add it to your
.envfile asCANVAS_API_KEY
Google Services Setup
The project uses OAuth 2.0 for Google Calendar and Gmail access. You can use the same credentials file for both services.
1. Enable APIs in Google Cloud Console
- Go to Google Cloud Console
- Create a new project or select an existing one
- Navigate to APIs & Services β Library
- Enable both Calendar API and Gmail API
2. Create OAuth 2.0 Credentials
- Navigate to APIs & Services β Credentials
- Click Create Credentials β OAuth client ID
- Configure the OAuth consent screen:
- User Type: External (for personal use) or Internal (for Google Workspace)
- Fill in required app information
- Add your email to test users (if using External)
- For Application type, select Desktop app
- Download the credentials file and save it as
credentials.jsonin the project root
3. Authenticate Google Services
For Calendar:
python authenticate_calendar.py
For Gmail:
python authenticate_gmail.py
These scripts will:
- Open a browser window for OAuth authentication
- Save tokens to
calendar_token.jsonandtoken.jsonrespectively - Only need to be run once (tokens are reused until revoked)
For detailed setup instructions, see:
π Running the Application
Development Mode
- Start the FastAPI backend:
bash uvicorn backend.api:app --reload --port 8000
The backend will be available at http://localhost:8000
- Start the Streamlit frontend:
bash streamlit run frontend.py
The frontend will open at http://localhost:8501
- Open your browser:
- Navigate to
http://localhost:8501 - Start chatting with the assistant!
- Navigate to
Using MCP Servers Directly
You can also use the MCP servers directly with Claude Desktop or other MCP-compatible clients:
Canvas MCP Server:
python mcp_server.py
Calendar MCP Server:
python calendar_mcp_server.py
Gmail MCP Server:
python gmail_mcp_server.py
π¬ Example Queries
Canvas:
- "What courses do I have?"
- "Show me assignments due in the next week"
- "Create an assignment in my CS101 course due next Friday"
- "Give me my daily briefing"
Calendar:
- "What events do I have tomorrow?"
- "Create a calendar event for tomorrow at 2pm called 'Team Meeting'"
- "Show me all events this week"
Gmail:
- "Show me my recent emails"
- "Send an email to example@email.com with subject 'Hello'"
- "Search for emails from my professor"
ποΈ Architecture
βββββββββββββββββββ
β Streamlit UI β (frontend.py)
β (Frontend) β
ββββββββββ¬βββββββββ
β HTTP
βΌ
βββββββββββββββββββ
β FastAPI Backendβ (backend/api.py)
β (Backend) β
ββββββββββ¬βββββββββ
β
ββββΊ OpenRouter API (Claude AI)
β
ββββΊ Service Layer (backend/service_layer.py)
β
ββββΊ Canvas MCP Server (mcp_server.py)
ββββΊ Calendar MCP Server (calendar_mcp_server.py)
ββββΊ Gmail MCP Server (gmail_mcp_server.py)
Components
- Frontend (
frontend.py): Streamlit web interface for user interaction - Backend (
backend/api.py): FastAPI server that handles queries and integrates with OpenRouter - Service Layer (
backend/service_layer.py): Wraps MCP server functions for programmatic access - MCP Servers: Individual servers for Canvas, Calendar, and Gmail integrations
mcp_server.py: Canvas LMS integrationcalendar_mcp_server.py: Google Calendar integrationgmail_mcp_server.py: Gmail integration
π Project Structure
mcp-datathon/
βββ backend/
β βββ __init__.py
β βββ api.py # FastAPI backend server
β βββ service_layer.py # MCP service wrapper
βββ frontend.py # Streamlit frontend
βββ mcp_server.py # Canvas MCP server
βββ calendar_mcp_server.py # Calendar MCP server
βββ gmail_mcp_server.py # Gmail MCP server
βββ authenticate_calendar.py # Calendar OAuth setup
βββ authenticate_gmail.py # Gmail OAuth setup
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ README_FRONTEND.md # Frontend-specific docs
βββ FRONTEND_SETUP.md # Detailed frontend setup
βββ CALENDAR_SETUP.md # Calendar setup guide
βββ GMAIL_SETUP.md # Gmail setup guide
βββ RENDER_DEPLOYMENT.md # Backend deployment guide
βββ STREAMLIT_DEPLOYMENT.md # Frontend deployment guide
π’ Deployment
Backend Deployment (Render)
The FastAPI backend can be deployed to Render. See RENDER_DEPLOYMENT.md for detailed instructions.
Quick steps:
- Create a new Web Service on Render
- Connect your GitHub repository
- Set environment variables in Render dashboard
- Deploy!
Frontend Deployment (Streamlit Cloud)
The Streamlit frontend can be deployed to Streamlit Cloud. See STREAMLIT_DEPLOYMENT.md for detailed instructions.
Quick steps:
- Push your code to GitHub
- Go to Streamlit Cloud
- Connect your repository
- Set environment variables
- Deploy!
π Security Notes
- Never commit
.envfiles,credentials.json, or token files to version control - Add these to
.gitignore:.env credentials.json *token.json calendar_token.json - Keep your API keys secure and rotate them regularly
- For production, use environment variables or secure secret management services
π Troubleshooting
Backend Connection Issues
- Error: "Backend not accessible"
- Ensure the backend is running on port 8000
- Check that
API_URLinfrontend.pymatches your backend URL - Verify firewall settings allow local connections
Canvas API Errors
- 401 Unauthorized: Check that your
CANVAS_API_KEYis correct and not expired - 403 Forbidden: Verify your API key has the necessary permissions
Google OAuth Issues
- Token expired: Re-run the authentication scripts (
authenticate_calendar.pyorauthenticate_gmail.py) - Scope errors: Ensure both Calendar and Gmail APIs are enabled in Google Cloud Console
- Redirect URI mismatch: Make sure you're using "Desktop app" credentials type
OpenRouter API Issues
- Rate limiting: OpenRouter has rate limits on free tier accounts
- Model unavailable: Check that
anthropic/claude-3.5-sonnetis available, or change the model inbackend/api.py
π API Endpoints
Backend API
POST /chat: Process a user query and return AI response{ "query": "What courses do I have?", "conversation_history": [] }GET /health: Health check endpointGET /tools: Get all available MCP tools
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
π License
This project is part of a Datathon submission.
π Additional Resources
- Canvas API Documentation
- Google Calendar API Documentation
- Gmail API Documentation
- OpenRouter Documentation
- Model Context Protocol (MCP) Documentation
π Support
For issues and questions:
- Check the setup guides in the
*.mdfiles - Review the troubleshooting section above
- Open an issue on the repository
Built with β€οΈ for the Datathon

Log in or sign up for Devpost to join the conversation.