brightspace-d2l-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +269 -0
  3. package/build/api/cache.js +49 -0
  4. package/build/api/client.js +345 -0
  5. package/build/api/errors.js +48 -0
  6. package/build/api/index.js +12 -0
  7. package/build/api/paginate.js +70 -0
  8. package/build/api/rate-limiter.js +52 -0
  9. package/build/api/retry.js +39 -0
  10. package/build/api/types.js +11 -0
  11. package/build/api/version-discovery.js +43 -0
  12. package/build/auth/authenticator.js +146 -0
  13. package/build/auth/browser.js +82 -0
  14. package/build/auth/index.js +6 -0
  15. package/build/auth/login.js +227 -0
  16. package/build/auth/session-store.js +46 -0
  17. package/build/auth/token-manager.js +150 -0
  18. package/build/auth/token-mint.js +75 -0
  19. package/build/cli/clients.js +344 -0
  20. package/build/cli/main.js +162 -0
  21. package/build/cli/school.js +74 -0
  22. package/build/cli/setup.js +189 -0
  23. package/build/cli/ui.js +39 -0
  24. package/build/index.js +13 -0
  25. package/build/server.js +175 -0
  26. package/build/tools/download-file.js +167 -0
  27. package/build/tools/get-announcements.js +116 -0
  28. package/build/tools/get-assignment-files.js +159 -0
  29. package/build/tools/get-assignments.js +343 -0
  30. package/build/tools/get-classlist-emails.js +38 -0
  31. package/build/tools/get-course-content.js +175 -0
  32. package/build/tools/get-discussions.js +192 -0
  33. package/build/tools/get-my-courses.js +42 -0
  34. package/build/tools/get-my-grades.js +93 -0
  35. package/build/tools/get-roster.js +99 -0
  36. package/build/tools/get-syllabus.js +154 -0
  37. package/build/tools/get-todo.js +61 -0
  38. package/build/tools/get-upcoming-due-dates.js +138 -0
  39. package/build/tools/index.js +18 -0
  40. package/build/tools/schemas.js +91 -0
  41. package/build/tools/submission-status.js +71 -0
  42. package/build/tools/tool-helpers.js +62 -0
  43. package/build/types/index.js +2 -0
  44. package/build/utils/atomic-write.js +66 -0
  45. package/build/utils/config.js +60 -0
  46. package/build/utils/course-filter.js +24 -0
  47. package/build/utils/deep-links.js +13 -0
  48. package/build/utils/download-errors.js +14 -0
  49. package/build/utils/download-helpers.js +73 -0
  50. package/build/utils/errors.js +31 -0
  51. package/build/utils/file-validator.js +121 -0
  52. package/build/utils/html-converter.js +20 -0
  53. package/build/utils/logger.js +69 -0
  54. package/build/utils/paths.js +15 -0
  55. package/build/utils/pdf-extractor.js +18 -0
  56. package/build/utils/version.js +18 -0
  57. package/build/utils/zip-extract.js +139 -0
  58. package/package.json +104 -0
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AnonymousOnyx22
4
+
5
+ Portions of this software are derived from brightspace-mcp-server,
6
+ Copyright (c) 2026 Rohan Muppa, used under the MIT License.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,269 @@
1
+ <h1 align="center">Brightspace D2L MCP Server</h1>
2
+
3
+ <p align="center">
4
+ <img src="assets/banner.svg" alt="Brightspace D2L MCP server: ask your AI what's due, what you've handed in, your grades and course files" width="100%">
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/brightspace-d2l-mcp"><img src="https://img.shields.io/npm/v/brightspace-d2l-mcp?style=flat-square&label=npm&labelColor=1b2033&color=ff6a3d" alt="npm version"></a>
9
+ <a href="https://github.com/AnonymousOnyx22/brightspace-d2l-mcp/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/AnonymousOnyx22/brightspace-d2l-mcp/ci.yml?style=flat-square&label=tests&labelColor=1b2033" alt="tests"></a>
10
+ <img src="https://img.shields.io/badge/node-20%2B-3ddc97?style=flat-square&labelColor=1b2033" alt="Node 20+">
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-9fb4ff?style=flat-square&labelColor=1b2033" alt="MIT license"></a>
12
+ </p>
13
+
14
+ <h3 align="center">Connect D2L Brightspace to Claude, ChatGPT, Cursor, Copilot<br>or any AI agent in about a minute.</h3>
15
+
16
+ <p align="center">One command. Sign in the way you always do. No passwords stored.</p>
17
+
18
+ <br>
19
+
20
+ An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that gives AI assistants and agents read access to your Brightspace courses: due dates with real submission status, grades, assignments, rubrics, course content, announcements, discussions and class lists. It works at any school that uses D2L Brightspace, including schools with Microsoft, Duo, Okta or Shibboleth single sign-on.
21
+
22
+ ## Quick start
23
+
24
+ You need [Node.js 20 or newer](https://nodejs.org/) and Google Chrome or Microsoft Edge.
25
+
26
+ ```bash
27
+ npx brightspace-d2l-mcp setup
28
+ ```
29
+
30
+ That's it. Setup asks for your school, opens a browser so you can sign in, and connects every AI app it finds.
31
+ Then ask your AI:
32
+
33
+ > **"What should I work on right now?"**
34
+
35
+ <p align="center">
36
+ <img src="assets/setup.svg" alt="The setup command finding the school, signing in, and connecting AI apps" width="760">
37
+ </p>
38
+
39
+ New to this? The **[step-by-step setup guide](docs/setup.md)** walks through everything with pictures of each step.
40
+
41
+ ## What you can ask
42
+
43
+ | | Try asking |
44
+ |---|---|
45
+ | ✅ **What's left** | "What should I work on right now?" · "What haven't I submitted yet?" |
46
+ | 📅 **Deadlines** | "What's due this week?" · "Anything due tomorrow?" |
47
+ | 📊 **Grades** | "What are my grades?" · "Am I passing Calculus?" |
48
+ | 📢 **Announcements** | "Did any professor post something today?" |
49
+ | 📚 **Course content** | "Find the midterm review slides" · "Summarize the Lab 3 instructions" |
50
+ | 📎 **Assignment files** | "What does the rubric for the project ask for?" |
51
+ | 💬 **Discussions** | "What are people saying in the final project thread?" |
52
+ | 👥 **Class list** | "Who's the TA for my networking course?" |
53
+
54
+ ### It knows what you've already handed in
55
+
56
+ Most tools only see due dates, so they keep telling you to do work you've finished.
57
+ This one checks your actual submission for every assignment:
58
+
59
+ | Status | Meaning |
60
+ |---|---|
61
+ | `submitted` / `graded` | Done. Never suggested as a to-do. |
62
+ | `not_submitted` / `draft` | Still needs doing. |
63
+ | `not_open_yet` | The dropbox hasn't opened; shows when it will. |
64
+ | `closed` / `past_due` | You can no longer submit. |
65
+ | `unknown` | Quizzes: Brightspace doesn't show students their quiz attempts, so your AI will ask you. |
66
+
67
+ ## Tools
68
+
69
+ 13 read-only MCP tools for D2L Brightspace:
70
+
71
+ | Tool | What it does |
72
+ |---|---|
73
+ | `get_todo` | Prioritized to-do list across every course: what's due soon, overdue, not open yet, and already done |
74
+ | `get_upcoming_due_dates` | Upcoming deadlines with the real submission status of each assignment |
75
+ | `get_my_courses` | Your enrolled courses with names, codes and ids |
76
+ | `get_my_grades` | Grade breakdown per course with points, percentages and instructor comments |
77
+ | `get_assignments` | Assignments (dropboxes) and quizzes with due dates, status and rubrics |
78
+ | `get_assignment_files` | Reads the instructions, handouts and rubric files attached to an assignment |
79
+ | `get_course_content` | Course modules, lecture slides, files and links |
80
+ | `get_syllabus` | Course syllabus and overview |
81
+ | `get_announcements` | Recent announcements (news) from your instructors |
82
+ | `get_discussions` | Discussion forums, topics and posts |
83
+ | `get_roster` | Instructors and TAs with contact info, optionally the full class list |
84
+ | `get_classlist_emails` | Email addresses for everyone in a course |
85
+ | `download_file` | Saves a course file or submission to a folder you choose |
86
+
87
+ ## Works at any Brightspace school
88
+
89
+ Every school signs in differently: Microsoft, ADFS, Duo, Shibboleth, Okta, Google, campus pickers, or Brightspace's own form.
90
+ Instead of guessing how your school works, setup opens a **normal browser window** and you sign in exactly like you do every day, text codes and authenticator apps included.
91
+
92
+ <p align="center">
93
+ <img src="assets/how-it-works.svg" alt="Your AI app talks to this server on your computer, which reads Brightspace with the session from your browser sign-in" width="860">
94
+ </p>
95
+
96
+ After that it stays signed in quietly in the background. If your school ever asks you to sign in again, the browser window simply pops up and closes by itself when you're done.
97
+
98
+ ## Works with your AI app or agent
99
+
100
+ **Connected automatically by setup:**
101
+ Claude Desktop · Claude Code · Cursor · VS Code (GitHub Copilot) · Windsurf · OpenAI Codex · Gemini CLI · Cline · Roo Code · OpenCode · Zed · LM Studio · Kiro
102
+
103
+ **One copy-paste away:**
104
+ ChatGPT (developer mode) · Continue · Goose · JetBrains AI Assistant · Warp · Amp · Msty · Jan · AnythingLLM
105
+
106
+ **Agent frameworks:**
107
+ OpenAI Agents SDK · Claude Agent SDK · LangChain / LangGraph · Vercel AI SDK · Mastra · CrewAI · Pydantic AI · LlamaIndex
108
+
109
+ It runs over **stdio** for local apps and **streamable HTTP** (`serve --http`) for ChatGPT and hosted agents.
110
+ See **[docs/agents.md](docs/agents.md)** for copy-paste setup for every one of these.
111
+
112
+ ## Commands
113
+
114
+ | Command | What it does |
115
+ |---|---|
116
+ | `npx brightspace-d2l-mcp setup` | Pick your school, sign in, connect your AI apps |
117
+ | `npx brightspace-d2l-mcp login` | Sign in again |
118
+ | `npx brightspace-d2l-mcp status` | Show your school, whether you're signed in, and connected apps |
119
+ | `npx brightspace-d2l-mcp logout` | Delete the saved session |
120
+ | `npx brightspace-d2l-mcp uninstall` | Remove from all AI apps and delete all local data |
121
+ | `npx brightspace-d2l-mcp serve --http` | Run over HTTP for ChatGPT and HTTP-based agents |
122
+ | `npx brightspace-d2l-mcp config` | Print the MCP config JSON for any other app |
123
+
124
+ <details>
125
+ <summary><b>Setup options</b></summary>
126
+
127
+ ```bash
128
+ npx brightspace-d2l-mcp setup --school yourschool.brightspace.com # skip the school question
129
+ npx brightspace-d2l-mcp setup --apps claude-desktop,cursor # only connect these apps
130
+ npx brightspace-d2l-mcp setup --skip-login # sign in later, on first use
131
+ npx brightspace-d2l-mcp setup --yes # accept every default
132
+ ```
133
+
134
+ App ids: `claude-desktop`, `claude-code`, `cursor`, `vscode`, `windsurf`, `codex`, `gemini-cli`, `cline`, `roo-code`, `opencode`, `zed`, `lm-studio`, `kiro`.
135
+
136
+ </details>
137
+
138
+ ## Privacy and security
139
+
140
+ - **Your password is never seen or stored.** You type it into your school's own sign-in page in a real browser.
141
+ - **Read-only.** It can't submit, post, or change anything in Brightspace.
142
+ - **Local only.** Everything runs on your computer and talks only to your school's Brightspace. There's no server in between, and no analytics.
143
+ - **Uses the official Brightspace API** with the same access you have in your browser.
144
+ - Your session is saved in `~/.brightspace-d2l-mcp/`, readable only by your user account. `logout` deletes it; `uninstall` deletes everything.
145
+
146
+ ## Troubleshooting
147
+
148
+ <details>
149
+ <summary><b>"No supported browser was found"</b></summary>
150
+
151
+ Install [Google Chrome](https://www.google.com/chrome/) or use Microsoft Edge (already on Windows).
152
+ Or install a private copy of Chromium with `npx playwright install chromium`.
153
+ </details>
154
+
155
+ <details>
156
+ <summary><b>My school address isn't accepted</b></summary>
157
+
158
+ Sign in to Brightspace in your browser, then copy the address from the address bar (any page works).
159
+ If it says your site "runs Blackboard" or "Canvas", your school doesn't use Brightspace.
160
+ </details>
161
+
162
+ <details>
163
+ <summary><b>Brightspace doesn't show up in Claude Desktop</b></summary>
164
+
165
+ Fully quit Claude Desktop (tray icon → Quit, not just closing the window), then run `setup` again.
166
+ Claude Desktop rewrites its settings while it's open, so setup offers to restart it for you.
167
+ </details>
168
+
169
+ <details>
170
+ <summary><b>It keeps asking me to sign in</b></summary>
171
+
172
+ Some schools end sessions every few hours. When that happens a browser window opens so you can sign in again.
173
+ Run `npx brightspace-d2l-mcp status` to check, or `login` to sign in right away.
174
+ If you'd rather it never opens a window on its own, add `"autoLogin": false` to `~/.brightspace-d2l-mcp/config.json`.
175
+ </details>
176
+
177
+ <details>
178
+ <summary><b>I want to filter out old courses</b></summary>
179
+
180
+ Add course ids to `~/.brightspace-d2l-mcp/config.json`:
181
+
182
+ ```json
183
+ { "excludeCourses": [123456, 789012] }
184
+ ```
185
+
186
+ Or keep only specific ones with `"includeCourses"`. Ask your AI "list my courses with their ids" to find them.
187
+ </details>
188
+
189
+ ## FAQ
190
+
191
+ <details>
192
+ <summary><b>How do I connect D2L Brightspace to Claude?</b></summary>
193
+
194
+ Run `npx brightspace-d2l-mcp setup`. It connects Claude Desktop and Claude Code automatically. Then ask Claude about your courses.
195
+ </details>
196
+
197
+ <details>
198
+ <summary><b>Is there an AI assistant for D2L Brightspace?</b></summary>
199
+
200
+ Yes. This connects Brightspace to the AI app you already use (Claude, ChatGPT, Cursor, GitHub Copilot, Gemini and others), so you can ask about deadlines, grades and course files in plain English instead of clicking through every course.
201
+ </details>
202
+
203
+ <details>
204
+ <summary><b>How do I use ChatGPT with Brightspace?</b></summary>
205
+
206
+ Run `npx brightspace-d2l-mcp serve --http`, expose it with a tunnel, and add the URL as a connector in ChatGPT developer mode. [docs/agents.md](docs/agents.md#chatgpt) walks through each step.
207
+ </details>
208
+
209
+ <details>
210
+ <summary><b>How do I connect Brightspace to Cursor, VS Code Copilot or Windsurf?</b></summary>
211
+
212
+ Run `npx brightspace-d2l-mcp setup`. It finds Cursor, VS Code, Windsurf and 10 other apps and connects them for you.
213
+ </details>
214
+
215
+ <details>
216
+ <summary><b>Can I use this with ChatGPT, a custom agent, or the Claude Agent SDK?</b></summary>
217
+
218
+ Yes. Local agents and SDKs launch it with `npx -y brightspace-d2l-mcp@latest`, and ChatGPT or HTTP-based agents use `npx brightspace-d2l-mcp serve --http`. [docs/agents.md](docs/agents.md) has copy-paste setup for ChatGPT, the OpenAI Agents SDK, Claude Agent SDK, LangChain, Vercel AI SDK and more.
219
+ </details>
220
+
221
+ <details>
222
+ <summary><b>Does it need an API key or admin access from my school?</b></summary>
223
+
224
+ No. Brightspace API keys normally require an administrator. This uses your own student sign-in instead, so it sees exactly what you see in Brightspace, and nobody at your school has to set anything up.
225
+ </details>
226
+
227
+ <details>
228
+ <summary><b>Does it work with Duo, Microsoft Authenticator or text-message codes?</b></summary>
229
+
230
+ Yes. You sign in yourself in a real browser window, so any sign-in method your school uses works.
231
+ </details>
232
+
233
+ <details>
234
+ <summary><b>Which schools does it work with?</b></summary>
235
+
236
+ Any school on D2L Brightspace, whether the address looks like `yourschool.brightspace.com`, `yourschool.desire2learn.com`, or a custom domain like `learn.yourschool.edu`.
237
+ </details>
238
+
239
+ <details>
240
+ <summary><b>Can it submit assignments or post for me?</b></summary>
241
+
242
+ No. It's read-only on purpose.
243
+ </details>
244
+
245
+ <details>
246
+ <summary><b>Is this made by D2L?</b></summary>
247
+
248
+ No. It's an independent open-source project that uses the official Brightspace API with your own sign-in. It isn't affiliated with or endorsed by D2L.
249
+ </details>
250
+
251
+ ## Development
252
+
253
+ ```bash
254
+ git clone https://github.com/AnonymousOnyx22/brightspace-d2l-mcp.git
255
+ cd brightspace-d2l-mcp
256
+ npm install
257
+ npm run build
258
+ npm test
259
+ node build/index.js setup # connects your AI apps to this local build
260
+ ```
261
+
262
+ Tools live in [`src/tools/`](src/tools), sign-in in [`src/auth/`](src/auth), and setup in [`src/cli/`](src/cli).
263
+ Issues and pull requests are welcome.
264
+
265
+ ## License
266
+
267
+ [MIT](LICENSE) © AnonymousOnyx22
268
+
269
+ D2L and Brightspace are trademarks of D2L Corporation. This project is not affiliated with D2L.
@@ -0,0 +1,49 @@
1
+ // In-memory TTL cache using Map + setTimeout
2
+ // No disk persistence per user decision
3
+ export class TTLCache {
4
+ cache = new Map();
5
+ set(key, value, ttlMs) {
6
+ // Clear existing timer if key exists
7
+ const existing = this.cache.get(key);
8
+ if (existing) {
9
+ clearTimeout(existing.timerId);
10
+ }
11
+ // Set new timer to auto-delete after TTL
12
+ const timerId = setTimeout(() => {
13
+ this.cache.delete(key);
14
+ }, ttlMs);
15
+ if (typeof timerId.unref === "function") {
16
+ timerId.unref();
17
+ }
18
+ // Store entry
19
+ this.cache.set(key, { data: value, timerId });
20
+ }
21
+ get(key) {
22
+ const entry = this.cache.get(key);
23
+ return entry?.data;
24
+ }
25
+ has(key) {
26
+ return this.cache.has(key);
27
+ }
28
+ delete(key) {
29
+ const entry = this.cache.get(key);
30
+ if (entry) {
31
+ clearTimeout(entry.timerId);
32
+ this.cache.delete(key);
33
+ return true;
34
+ }
35
+ return false;
36
+ }
37
+ clear() {
38
+ // Clear all timers
39
+ for (const entry of this.cache.values()) {
40
+ clearTimeout(entry.timerId);
41
+ }
42
+ // Clear map
43
+ this.cache.clear();
44
+ }
45
+ get size() {
46
+ return this.cache.size;
47
+ }
48
+ }
49
+ //# sourceMappingURL=cache.js.map