fit-lms-mcp 2.2.0 → 2.2.1

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.
package/README.md CHANGED
@@ -13,7 +13,7 @@ Requires **Node.js 22 or later**. Node.js 24 LTS is recommended. CI tests Node.j
13
13
  Run the interactive setup assistant directly with `npx`:
14
14
 
15
15
  ```bash
16
- npx fit-lms-mcp setup
16
+ npx -y fit-lms-mcp@latest setup
17
17
  ```
18
18
 
19
19
  Or, from a local workspace:
@@ -28,9 +28,15 @@ The interactive setup assistant will:
28
28
  1. Prompt for your LMS student ID and password (safely masked).
29
29
  2. Test the connection against HANU LMS immediately.
30
30
  3. Save your configuration securely with `0600` permissions to `~/.fit-lms-mcp/.env` when run via `npx`, or the workspace `.env` when run from the package root.
31
- 4. Offer to register the MCP server with detected AI clients (**Claude Code**, **OpenCode**, **Codex**, or **Antigravity**). For Codex, use the manual configuration below.
31
+ 4. Offer to register the MCP server with detected AI clients (**Claude Code**, **OpenCode**, **Codex**, or **Antigravity**). Automatic registration for Codex requires the `codex` CLI on your PATH.
32
32
 
33
- After running setup, you can use the MCP server directly in your AI client with `npx -y fit-lms-mcp`.
33
+ After running setup, restart your AI client. The npm configuration uses `npx -y fit-lms-mcp@latest` so npm resolves the latest stable release whenever the client starts the MCP server.
34
+
35
+ ### Updating an existing installation
36
+
37
+ If your client already uses `fit-lms-mcp@latest`, restart it to pick up a new release. For an older `npx` entry, change the package argument to `fit-lms-mcp@latest` and restart the client. You can keep using the credentials saved by setup.
38
+
39
+ If you installed the package globally, run `npm install -g fit-lms-mcp@latest` and restart your client.
34
40
 
35
41
  ---
36
42
 
@@ -70,7 +76,7 @@ The following examples use the credentials saved by the `npx` setup flow.
70
76
  Register via CLI:
71
77
 
72
78
  ```bash
73
- claude mcp add fit-lms -- npx -y fit-lms-mcp
79
+ claude mcp add fit-lms -- npx -y fit-lms-mcp@latest
74
80
  ```
75
81
 
76
82
  Or add to `~/.claude.json`:
@@ -80,7 +86,7 @@ Or add to `~/.claude.json`:
80
86
  "mcpServers": {
81
87
  "fit-lms": {
82
88
  "command": "npx",
83
- "args": ["-y", "fit-lms-mcp"]
89
+ "args": ["-y", "fit-lms-mcp@latest"]
84
90
  }
85
91
  }
86
92
  }
@@ -95,7 +101,7 @@ Add to `~/.config/opencode/opencode.jsonc` (or project `opencode.json`):
95
101
  "mcp": {
96
102
  "fit-lms": {
97
103
  "type": "local",
98
- "command": ["npx", "-y", "fit-lms-mcp"],
104
+ "command": ["npx", "-y", "fit-lms-mcp@latest"],
99
105
  "enabled": true,
100
106
  "timeout": 60000
101
107
  }
@@ -108,7 +114,7 @@ Add to `~/.config/opencode/opencode.jsonc` (or project `opencode.json`):
108
114
  Register via CLI:
109
115
 
110
116
  ```bash
111
- codex mcp add fit-lms -- npx -y fit-lms-mcp
117
+ codex mcp add fit-lms -- npx -y fit-lms-mcp@latest
112
118
  ```
113
119
 
114
120
  Or add to `~/.codex/config.toml`:
@@ -116,10 +122,10 @@ Or add to `~/.codex/config.toml`:
116
122
  ```toml
117
123
  [mcp_servers.fit-lms]
118
124
  command = "npx"
119
- args = ["-y", "fit-lms-mcp"]
125
+ args = ["-y", "fit-lms-mcp@latest"]
120
126
  ```
121
127
 
122
- See the [Codex MCP documentation](https://developers.openai.com/codex/mcp/). The setup assistant currently writes a JSON configuration for Codex; use the CLI command or TOML configuration above instead.
128
+ See the [Codex MCP documentation](https://developers.openai.com/codex/mcp/).
123
129
 
124
130
  ### 4. Antigravity
125
131
 
@@ -130,7 +136,7 @@ Add to `~/.gemini/config/mcp_config.json`:
130
136
  "mcpServers": {
131
137
  "fit-lms": {
132
138
  "command": "npx",
133
- "args": ["-y", "fit-lms-mcp"]
139
+ "args": ["-y", "fit-lms-mcp@latest"]
134
140
  }
135
141
  }
136
142
  }
@@ -145,7 +151,7 @@ Add to `~/.cursor/mcp.json` or `.cursor/mcp.json` in your project:
145
151
  "mcpServers": {
146
152
  "fit-lms": {
147
153
  "command": "npx",
148
- "args": ["-y", "fit-lms-mcp"]
154
+ "args": ["-y", "fit-lms-mcp@latest"]
149
155
  }
150
156
  }
151
157
  }
@@ -160,7 +166,7 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
160
166
  "mcpServers": {
161
167
  "fit-lms": {
162
168
  "command": "npx",
163
- "args": ["-y", "fit-lms-mcp"]
169
+ "args": ["-y", "fit-lms-mcp@latest"]
164
170
  }
165
171
  }
166
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fit-lms-mcp",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Model Context Protocol (MCP) server for HANU Faculty of Information Technology (FIT) Moodle LMS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/scripts/setup.mjs CHANGED
@@ -5,7 +5,7 @@ import path from "node:path";
5
5
  import os from "node:os";
6
6
  import readline from "node:readline";
7
7
  import { fileURLToPath } from "node:url";
8
- import { execSync } from "node:child_process";
8
+ import childProcess, { execSync } from "node:child_process";
9
9
 
10
10
  export function serializeEnvValue(val) {
11
11
  const str = String(val ?? "");
@@ -148,6 +148,20 @@ export function updateJsonConfigFile(configPath, serverConfig, key = "mcpServers
148
148
  }
149
149
  }
150
150
 
151
+ function registerCodexMcp({ command, args }) {
152
+ const options = { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] };
153
+ try {
154
+ const servers = JSON.parse(childProcess.execFileSync("codex", ["mcp", "list", "--json"], options));
155
+ const hasFitLms = servers.some(server => server.name === "fit-lms");
156
+ const hasLegacyLms = servers.some(server => server.name === "hanu-lms");
157
+ const name = !hasFitLms && hasLegacyLms ? "hanu-lms" : "fit-lms";
158
+ childProcess.execFileSync("codex", ["mcp", "add", name, "--", command, ...args], options);
159
+ return true;
160
+ } catch {
161
+ return false;
162
+ }
163
+ }
164
+
151
165
  export function askText(question) {
152
166
  return new Promise((resolve) => {
153
167
  const rl = readline.createInterface({
@@ -366,22 +380,17 @@ export async function runSetup() {
366
380
  }
367
381
  : {
368
382
  command: "npx",
369
- args: ["-y", "fit-lms-mcp"],
383
+ args: ["-y", "fit-lms-mcp@latest"],
370
384
  };
371
385
 
372
- const openCodeConfig = isLocalDev
373
- ? {
374
- type: "local",
375
- command: [nodePath, `--env-file=${envPath}`, distIndexPath],
376
- enabled: true,
377
- timeout: 60000,
378
- }
379
- : {
380
- type: "local",
381
- command: ["npx", "-y", "fit-lms-mcp"],
382
- enabled: true,
383
- timeout: 60000,
384
- };
386
+ const mcpCommand = [mcpServerConfig.command, ...mcpServerConfig.args];
387
+ const openCodeConfig = {
388
+ type: "local",
389
+ command: mcpCommand,
390
+ enabled: true,
391
+ timeout: 60000,
392
+ };
393
+ const codexConfigPath = path.join(process.env.CODEX_HOME || path.join(os.homedir(), ".codex"), "config.toml");
385
394
 
386
395
  // 7. Auto-detect and configure: Claude Code, OpenCode, Codex, Antigravity
387
396
  console.log("\n-------------------------------------------------");
@@ -413,18 +422,9 @@ export async function runSetup() {
413
422
  },
414
423
  {
415
424
  name: "Codex",
416
- detect: () => {
417
- const dir = path.join(os.homedir(), ".codex");
418
- const altDir = path.join(os.homedir(), ".config/codex");
419
- return fs.existsSync(dir) || fs.existsSync(altDir);
420
- },
421
- getConfigPath: () => {
422
- const dir = path.join(os.homedir(), ".codex");
423
- if (fs.existsSync(path.join(dir, "mcp.json"))) return path.join(dir, "mcp.json");
424
- return path.join(dir, "config.json");
425
- },
426
- key: "mcpServers",
427
- getConfig: () => mcpServerConfig,
425
+ detect: () => fs.existsSync(path.dirname(codexConfigPath)) || fs.existsSync(path.join(os.homedir(), ".config/codex")),
426
+ getConfigPath: () => codexConfigPath,
427
+ register: () => registerCodexMcp(mcpServerConfig),
428
428
  },
429
429
  {
430
430
  name: "Antigravity",
@@ -445,7 +445,9 @@ export async function runSetup() {
445
445
  const targetPath = client.getConfigPath();
446
446
  const answer = await ask(`Phát hiện ${client.name} (${targetPath}).\n 👉 Tự động đăng ký MCP vào ${client.name}? (Y/n): `);
447
447
  if (!answer || answer.toLowerCase() === "y") {
448
- const ok = updateJsonConfigFile(targetPath, client.getConfig(), client.key);
448
+ const ok = client.register
449
+ ? client.register()
450
+ : updateJsonConfigFile(targetPath, client.getConfig(), client.key);
449
451
  if (ok) {
450
452
  console.log(` ✅ Đã đăng ký thành công vào: ${targetPath}\n`);
451
453
  } else {
@@ -464,9 +466,7 @@ export async function runSetup() {
464
466
  console.log(" Cấu hình MCP cho các AI Client (Copy thủ công)");
465
467
  console.log("=================================================\n");
466
468
 
467
- const cliExample = isLocalDev
468
- ? `claude mcp add fit-lms -- ${nodePath} --env-file=${envPath} ${distIndexPath}`
469
- : `claude mcp add fit-lms -- npx -y fit-lms-mcp`;
469
+ const cliExample = `claude mcp add fit-lms -- ${mcpCommand.join(" ")}`;
470
470
 
471
471
  console.log("1. Claude Code:");
472
472
  console.log(` Lệnh CLI: ${cliExample}`);
@@ -476,8 +476,10 @@ export async function runSetup() {
476
476
  console.log("\n2. OpenCode (~/.config/opencode/opencode.jsonc):");
477
477
  console.log(JSON.stringify({ mcp: { "fit-lms": openCodeConfig } }, null, 2));
478
478
 
479
- console.log("\n3. Codex (~/.codex/config.json):");
480
- console.log(JSON.stringify({ mcpServers: { "fit-lms": mcpServerConfig } }, null, 2));
479
+ console.log(`\n3. Codex (${codexConfigPath}):`);
480
+ console.log("[mcp_servers.fit-lms]");
481
+ console.log(`command = ${JSON.stringify(mcpServerConfig.command)}`);
482
+ console.log(`args = ${JSON.stringify(mcpServerConfig.args)}`);
481
483
 
482
484
  console.log("\n4. Antigravity (~/.gemini/config/mcp_config.json):");
483
485
  console.log(JSON.stringify({ mcpServers: { "fit-lms": mcpServerConfig } }, null, 2));