Pensum
README.md
# Pensum: The Canvas connector for AI
*pensum* (Latin): the day's assigned work.
**Pensum is a Canvas LMS MCP server: self-hosted, remote, and it works with any Canvas school.** Deploy it once and use it from Claude on the web, the desktop app and your phone as a custom connector. Most Canvas MCP servers run locally, on one computer, inside one desktop app. This one runs on a host you control and answers over HTTPS, so every Claude client you use can reach it.
- **Single user.** One deployment serves one Canvas account: yours.
- **Read-only toward Canvas.** It never writes to Canvas. Its one write tool, `profile_save`, saves your own course profile to your own storage.
- **Any school.** Set `CANVAS_DOMAIN` to your school's Canvas hostname. There are no school defaults.
- **Two skills** (`canvas-setup`, `canvas-due`) that turn the tools into a reliable "what's due today" check.
Also runs locally over stdio if that's all you need.
**Companion project:** [Excerpta](https://github.com/LukePAndersen/excerpta), a page-accurate book indexer and MCP server for PDF books and McGraw-Hill e-textbooks you own. Pensum works without it; when both connectors are present, `canvas-setup` links the textbooks named in your syllabi to Excerpta's book ids.
## Contents
- [Tools](#tools)
- [Quick start](#quick-start)
- [Authentication: header or URL path](#authentication-header-or-url-path)
- [Profile storage](#profile-storage)
- [Textbooks: Excerpta](#textbooks-excerpta)
- [Skills](#skills)
- [Configuration reference](#configuration-reference)
- [Local development](#local-development)
- [Security](#security)
## Tools
Canvas tools (always available, all read-only):
| Tool | What it does |
|---|---|
| `canvas_whoami` | Checks the token, shows the account, and reports the timezone the server uses for dates. Run it first. |
| `canvas_list_courses` | Your courses, optionally for one term. Returns the course ids other tools take. |
| `canvas_list_assignments` | Assignments for one course, with your submission status and discussion checkpoints. |
| `canvas_upcoming_work` | Everything due from now through N days ahead, across all active courses. |
| `canvas_planner_items` | Your Canvas planner (To Do) for a range of local days: assignments, quizzes, discussions and their checkpoints, pages with to-do dates, calendar events, peer reviews, planner notes. |
| `canvas_priority_dashboard` | Pending work across courses, ranked by urgency. |
| `canvas_get_grades` | Current score and letter grade per course. |
| `canvas_get_grade_breakdown` | A course grade split by assignment group, weighted only if the course is. |
| `canvas_get_assignment` | One assignment's full description, rubric, checkpoints and submission state. |
| `canvas_get_syllabus` | A course syllabus as plain text. |
| `canvas_list_announcements` | Recent instructor announcements. |
| `canvas_list_modules` | A course's modules and items, with completion state. |
| `canvas_list_files` | Files posted in a course, optionally filtered by name. |
| `canvas_get_instructor_info` | Teacher and TA contact details for a course. |
Profile tools (always registered, so `profile_get` can report when no storage is set up):
| Tool | What it does |
|---|---|
| `profile_get` | Reads your saved course profile. Reports `storage`: `supabase`, `file` or `none`. |
| `profile_save` | Saves (replaces) your course profile. The only write tool. Keeps the previous 5 versions and returns a diff. |
Dated responses include `timezone`, `timezone_source` (`env`, `canvas` or `fallback`) and `today_local`, so clients without a clock still get the right day.
## Quick start
### 1. Get a Canvas token
In Canvas: **Account > Settings > Approved Integrations > + New Access Token**. Copy it. Canvas shows it only once.
> Check your school's policy on personal access tokens. Some schools restrict them or set an expiry. When a token expires or you revoke it, make a new one and update `CANVAS_API_TOKEN`.
The token can do anything your Canvas account can do. This server only reads with it, but guard it like a password.
### 2. Configure
```sh
cp .env.example .env
openssl rand -hex 32 # paste the output into MCP_AUTH_TOKEN
```
Fill in the three required values:
| Variable | Value |
|---|---|
| `CANVAS_API_TOKEN` | The token from step 1 |
| `CANVAS_DOMAIN` | Your school's Canvas hostname, e.g. `your-school.instructure.com` (no `https://`, no path) |
| `MCP_AUTH_TOKEN` | A random secret of at least 24 characters. Every client must present it. |
Everything else is optional. See [Configuration reference](#configuration-reference).
### 3. Deploy
The server needs a public HTTPS URL for Claude on the web and phone to reach it.
**Railway** (the repo includes `railway.json`):
1. Fork this repo and create a Railway project from your fork. Railway builds the `Dockerfile` and health-checks `/health`.
2. Under **Variables**, add `CANVAS_API_TOKEN`, `CANVAS_DOMAIN`, `MCP_AUTH_TOKEN` and, for claude.ai, `AUTH_IN_PATH=true` ([why](#authentication-header-or-url-path)). Railway sets `PORT` itself.
3. Under **Networking**, generate a domain. Your MCP URL is `https://<your-domain>/mcp`.
4. For profile storage without Supabase, see [Profile storage](#profile-storage).
**Docker** (any host that runs containers):
```sh
docker build -t pensum .
docker volume create pensum-data
docker run -d --name pensum -p 3000:3000 --env-file .env \
-e PROFILE_PATH=/data/profile.json -v pensum-data:/data pensum
curl http://localhost:3000/health # {"ok":true}
```
Put it behind HTTPS (a reverse proxy or tunnel) before you connect a remote client. If more than one proxy sits in front of it, set `TRUST_PROXY` to the number of hops.
### 4. Connect Claude
**claude.ai (web, desktop app and mobile).** Add a custom connector in Claude's connector settings (available on plans that support custom connectors). Many accounts can't attach a custom header to a connector, so set `AUTH_IN_PATH=true` on the server and use this URL:
```
https://<your-domain>/mcp/<MCP_AUTH_TOKEN>
```
Name the connector `Canvas`; the skills refer to "the Canvas connector". Connectors you add on claude.ai are also available in Claude's desktop and mobile apps.
**Claude Code** (header auth, no `AUTH_IN_PATH` needed):
```sh
claude mcp add --transport http canvas https://<your-domain>/mcp \
--header "Authorization: Bearer <MCP_AUTH_TOKEN>"
```
**Other MCP clients that can set headers** (Cursor, VS Code with GitHub Copilot, Gemini CLI and others): URL `https://<your-domain>/mcp`, header `Authorization: Bearer <MCP_AUTH_TOKEN>`.
**ChatGPT** (Developer Mode; not tested yet). ChatGPT can't send a custom header, so set `AUTH_IN_PATH=true` on the server, create a connector with authentication set to **No auth**, and use `https://<your-domain>/mcp/<MCP_AUTH_TOKEN>` as its URL. The skills are written for Claude, so in ChatGPT you get the tools without them.
**Local only (stdio).** No server, no `MCP_AUTH_TOKEN`. Build once (`npm ci && npm run build`), then point a desktop client at it:
```json
{
"mcpServers": {
"canvas": {
"command": "node",
"args": ["/absolute/path/to/pensum/dist/index.js"],
"env": {
"TRANSPORT": "stdio",
"CANVAS_API_TOKEN": "replace_me",
"CANVAS_DOMAIN": "your-school.instructure.com"
}
}
}
}
```
### 5. Check it
Ask Claude: "Use the Canvas connector's `canvas_whoami` tool." You should see your name and a timezone. If `timezone_source` is `fallback`, set `TIMEZONE` (for example `America/New_York`).
Then install the [skills](#skills) and run `canvas-setup` once.
## Authentication: header or URL path
The MCP endpoint is public, so the token is what keeps it private. There are two ways to send it:
| | Bearer header (always on) | Token in path (`AUTH_IN_PATH=true`) |
|---|---|---|
| URL | `https://<host>/mcp` | `https://<host>/mcp/<MCP_AUTH_TOKEN>` |
| Sent as | `Authorization: Bearer <MCP_AUTH_TOKEN>` | part of the URL |
| Works with | Claude Code, most MCP clients | claude.ai and ChatGPT connectors that can't set headers |
| Risk | Header rarely ends up anywhere visible | URLs leak more easily: screenshots, shared settings, browser history, proxy logs |
Both use a constant-time comparison. The server redacts the token from its own log lines. The bearer header keeps working when `AUTH_IN_PATH` is on. With `AUTH_IN_PATH=true` the token must be URL-safe (letters, digits, `.`, `_`, `~`, `-`); `openssl rand -hex 32` output is.
**If the token leaks, rotate it:** generate a new `MCP_AUTH_TOKEN`, redeploy, and update every connector. OAuth is not supported in this version.
After 10 failed auth attempts from one IP within 10 minutes, that IP gets `429` for 10 minutes. A request with the correct token is never blocked.
## Profile storage
The `canvas-setup` skill learns rules a plain due-date list gets wrong (weekly rhythms, discussion checkpoints, undated deadlines, external tools that auto-zero at the deadline) and saves them as your profile. The server stores it in the first of these that is configured:
| Storage | Set | Notes |
|---|---|---|
| `supabase` | `SUPABASE_URL` + `SUPABASE_SERVICE_ROLE_KEY`, migration `0001_profiles.sql` applied ([`supabase/README.md`](supabase/README.md)) | Survives redeploys. Keeps 5 previous versions. |
| `file` | `PROFILE_PATH` | A JSON file with the current profile and 5 previous versions, written atomically. |
| `none` | nothing | `profile_save` returns an error; the skill gives you the profile JSON to keep as a file in a Claude Project. |
**A container's filesystem is wiped on every redeploy.** For file storage on a host, mount a persistent volume at `/data` and set `PROFILE_PATH=/data/profile.json`. The image creates `/data` owned by its non-root user (UID/GID 10001).
- **Docker:** a named volume (`-v pensum-data:/data`, as above) picks up that ownership. For a bind mount, make the host folder writable by UID 10001 (`sudo chown 10001:10001 <folder>`).
- **Railway:** add a volume with mount path `/data`. Railway mounts volumes as root, so per Railway's volume docs a non-root image needs Railway's own `RAILWAY_RUN_UID=0` variable to write there. That runs the container as root. If you'd rather not, use Supabase storage instead.
## Textbooks: Excerpta
Pensum has no textbook tools. Book lookup lives in a separate project, [Excerpta](https://github.com/LukePAndersen/excerpta): you index PDF books and McGraw-Hill e-textbooks you have the right to use into your own Supabase project, and its MCP server returns exercises, pages and passages with printed page numbers.
The two are independent. If Excerpta is also connected, `canvas-setup` matches textbooks named in a syllabus to Excerpta's book ids and records them in your profile (`courses[].textbooks`). If it isn't, the titles are still recorded and the skill mentions Excerpta once.
## Skills
The `skills/` folder holds two skills that use the connector. Details in [`skills/README.md`](skills/README.md).
| Skill | Use it for | In Claude Code | On claude.ai |
|---|---|---|---|
| `canvas-setup` | Build your course profile at the start of each term, after add/drop, or to repair a missed item | `/pensum:canvas-setup` | `canvas-setup` |
| `canvas-due` | Everything still to do on a day (default today), with early warnings | `/pensum:canvas-due` | `canvas-due` |
**Claude Code:** this repo is also a plugin marketplace.
```
/plugin marketplace add LukePAndersen/pensum
/plugin install pensum@pensum
```
On recent Claude Code versions, one step also works: `/plugin install pensum --marketplace LukePAndersen/pensum`. Plugin skills are namespaced, so you run them as `/pensum:canvas-due` and so on, or just ask ("what's due tomorrow?").
**claude.ai:** zip one skill folder (for example `cd skills && zip -r canvas-due.zip canvas-due`) and upload the skill folder as a zip in Claude's skill settings. Repeat for each skill. Uploaded skills keep their plain names (`canvas-due`) and are picked up when you ask in plain words.
The plugin contains skills only. It does not configure the connector, because the URL and token are yours; add the connector as in [step 4](#4-connect-claude).
## Configuration reference
| Variable | Required | Default | Meaning |
|---|---|---|---|
| `CANVAS_API_TOKEN` | yes | | Canvas personal access token |
| `CANVAS_DOMAIN` | yes | | Canvas hostname, e.g. `your-school.instructure.com` |
| `MCP_AUTH_TOKEN` | when `TRANSPORT=http` | | Client secret, at least 24 characters |
| `TRANSPORT` | no | `http` | `http` (remote, `/mcp`) or `stdio` (local) |
| `PORT` | no | `3000` | Listen port; most hosts set it |
| `AUTH_IN_PATH` | no | `false` | Also accept `/mcp/<MCP_AUTH_TOKEN>` |
| `TRUST_PROXY` | no | `1` | Reverse-proxy hops in front of the server, used to find the client IP for the rate limit. `0` if none. |
| `TIMEZONE` | no | Canvas profile time zone, else `UTC` | IANA zone used to bucket every date |
| `EXCLUDE_TERMS` | no | none | Comma-separated term names whose courses are hidden. Hidden courses are listed in `excluded_courses`. |
| `PROFILE_PATH` | no | | Profile file path when Supabase is not configured, e.g. `/data/profile.json` |
| `SUPABASE_URL` | no | | `https://YOUR-PROJECT-REF.supabase.co`. Set with the key to store your profile in Supabase. |
| `SUPABASE_SERVICE_ROLE_KEY` | with `SUPABASE_URL` | | Service-role JWT or `sb_secret_...` key |
A bad or missing value stops the server at startup with a message naming each variable to fix.
## Local development
Node 22 or newer.
```sh
npm ci
npm run build
npm test # builds, then runs test/*.test.mjs (no network)
node --env-file=.env dist/index.js # HTTP server on PORT
npm run stdio # stdio transport (CANVAS_* must be in the environment)
```
Routes: `GET /health` returns `{"ok":true}` and nothing else. `POST /mcp` is the Streamable HTTP endpoint (stateless, JSON responses); `GET` and `DELETE` on it return `405`. With `AUTH_IN_PATH=true`, the same routes also exist at `/mcp/<MCP_AUTH_TOKEN>`.
## Security
Short version: one deployment is one person's Canvas data, and anyone with `MCP_AUTH_TOKEN` can read your courses and grades through it. Keep the token, the Canvas token and the Supabase key out of git and chats, rotate them if they leak, and prefer the header over the URL path when your client allows it. Read [SECURITY.md](SECURITY.md) for the threat model and how to report a vulnerability.
## License and trademarks
MIT. See [LICENSE](LICENSE).
Not affiliated with Instructure. Canvas is a trademark of Instructure, Inc.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues