brightspace-mcp-server 3.7.5 → 3.7.8

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.
@@ -26,9 +26,9 @@ export async function loadConfig() {
26
26
  ? expandTilde(store.sessionDir)
27
27
  : path.join(os.homedir(), ".d2l-session");
28
28
  // Code-entry and other interactive MFA methods need a visible browser.
29
- const headless = process.env.D2L_HEADLESS !== undefined
30
- ? process.env.D2L_HEADLESS !== "false"
31
- : store?.headless ?? true;
29
+ const headless = envBoolean(process.env.D2L_HEADLESS, "D2L_HEADLESS")
30
+ ?? store?.headless
31
+ ?? true;
32
32
  // Resolve tokenTtl: env > store > default (3600)
33
33
  const tokenTtl = positiveSeconds(process.env.D2L_TOKEN_TTL, "D2L_TOKEN_TTL")
34
34
  ?? positiveSeconds(store?.tokenTtl, "tokenTtl in config.json")
@@ -42,10 +42,9 @@ export async function loadConfig() {
42
42
  ? process.env.D2L_EXCLUDE_COURSES.split(',').map(s => parseInt(s.trim(), 10)).filter(n => !isNaN(n))
43
43
  : store?.excludeCourses;
44
44
  // Resolve activeOnly: env > store > default (true)
45
- let activeOnly = store?.activeOnly ?? true;
46
- if (process.env.D2L_ACTIVE_ONLY !== undefined) {
47
- activeOnly = process.env.D2L_ACTIVE_ONLY !== 'false';
48
- }
45
+ const activeOnly = envBoolean(process.env.D2L_ACTIVE_ONLY, "D2L_ACTIVE_ONLY")
46
+ ?? store?.activeOnly
47
+ ?? true;
49
48
  const configuredUrl = new URL(process.env.D2L_BASE_URL || store?.baseUrl || "https://purdue.brightspace.com");
50
49
  if (configuredUrl.protocol !== "https:" || configuredUrl.username || configuredUrl.password) {
51
50
  throw new Error("The Brightspace URL must be an HTTPS school URL without embedded credentials.");
@@ -93,6 +92,24 @@ function positiveSeconds(value, source) {
93
92
  console.error(`[config] Ignoring ${source}=${JSON.stringify(value)}: expected a positive whole number of seconds`);
94
93
  return undefined;
95
94
  }
95
+ /**
96
+ * An on/off environment variable. Comparing against the exact string "false"
97
+ * read "0", "no", "False" and a typo as true, so D2L_HEADLESS=0 kept the
98
+ * browser hidden from a user who needed it to enter an MFA code. An empty
99
+ * value counts as unset, and anything unrecognized is ignored with a warning
100
+ * so config.json or the default applies, as positiveSeconds does.
101
+ */
102
+ function envBoolean(value, source) {
103
+ const text = value?.trim().toLowerCase();
104
+ if (!text)
105
+ return undefined;
106
+ if (["true", "1", "yes", "on"].includes(text))
107
+ return true;
108
+ if (["false", "0", "no", "off"].includes(text))
109
+ return false;
110
+ console.error(`[config] Ignoring ${source}=${JSON.stringify(value)}: expected true or false`);
111
+ return undefined;
112
+ }
96
113
  function expandTilde(filePath) {
97
114
  if (filePath.startsWith("~")) {
98
115
  return path.join(os.homedir(), filePath.slice(1));
@@ -18,6 +18,10 @@
18
18
  * from inside a live process, which is the thing this package deliberately
19
19
  * does not do.
20
20
  *
21
+ * Automatic sign-in (`--automatic`, spawned by the server's AuthRunner) never
22
+ * re-execs: it must run the auth CLI shipped alongside that server, not
23
+ * whatever npm calls latest. Only a user-run `auth` self-updates.
24
+ *
21
25
  * Opt out with D2L_NO_UPDATE_CHECK.
22
26
  */
23
27
  import { spawn } from "node:child_process";
@@ -61,10 +65,12 @@ export async function reexecLatestIfStale(deps = {}) {
61
65
  const { env = process.env, argv = process.argv, installedVersion, fetchImpl = fetch, runningFromNpxCache = ownNpxCacheDir() !== null, platform = process.platform, spawnImpl = spawn, } = deps;
62
66
  if (installedVersion === undefined)
63
67
  return null;
64
- // Cheap local checks first, so an opted-out or npx-launched run never even
65
- // touches the network.
68
+ // Cheap local checks first, so an opted-out, npx-launched, or automatic run
69
+ // never even touches the network.
66
70
  if (env[REEXEC_SENTINEL] || env.D2L_NO_UPDATE_CHECK || runningFromNpxCache)
67
71
  return null;
72
+ if (argv.includes("--automatic"))
73
+ return null; // stay on the server's sibling version
68
74
  const latest = await fetchLatestVersion(fetchImpl);
69
75
  if (!shouldReexec({ env, latest, installedVersion, runningFromNpxCache }))
70
76
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brightspace-mcp-server",
3
- "version": "3.7.5",
3
+ "version": "3.7.8",
4
4
  "mcpName": "io.github.rohanmuppa/brightspace",
5
5
  "description": "MCP server for Brightspace (D2L). Check grades, due dates, assignments, announcements, syllabus, rosters and more via Claude, ChatGPT, Cursor, Windsurf, or any MCP client.",
6
6
  "type": "module",