huaweicloud-devkit 2.0.1-next.2 → 2.0.1-next.3

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
@@ -285,7 +285,30 @@ It listens on `127.0.0.1:9528` by default. Then connect with a remote config (op
285
285
  }
286
286
  ```
287
287
 
288
- > Use `--port <port>` if 9528 is taken and update `url` accordingly; add `--host 0.0.0.0` for LAN access. The remote server has no built-in auth — do not expose it anonymously to the public internet.
288
+ > Use `--port <port>` if 9528 is taken and update `url` accordingly; add `--host 0.0.0.0` for LAN access. The remote server is unauthenticated unless you pass `--auth-password-file <file>` — do not expose it anonymously to the public internet.
289
+
290
+ ### Server Mode (systemd, Linux)
291
+
292
+ Runs the MCP server as a pair of hardened systemd services with a dedicated OS user and generated auth password — for unattended/ops environments.
293
+
294
+ ```bash
295
+ sudo npx --yes huaweicloud-devkit install-server # defaults: /opt/kunpeng, business 8088, tool 7088, user devkit
296
+ sudo npx --yes huaweicloud-devkit install-server --install-path /opt/kunpeng --port 8088 --tool-port 7088 --user devkit
297
+ sudo npx --yes huaweicloud-devkit uninstall-server # add --remove-user to delete the service user
298
+ ```
299
+
300
+ What it provisions:
301
+
302
+ - Dedicated system user (default `devkit`, nologin shell) that runs both services
303
+ - `huaweicloud-devkit.service` (business port, default 8088) and `huaweicloud-devkit-tool.service` (tool port, default 7088)
304
+ - Generated auth password at `<install-path>/devkit/server/.auth-password` (0600, owned by the service user); every RPC requires `Authorization: Bearer <password>` or `x-devkit-password: <password>` — `GET /health` stays open for probes
305
+ - Self-contained runtime under `<install-path>/devkit/app` (Node.js 22.19+ is auto-provisioned when missing)
306
+ - Idempotent: re-running refreshes services; add `--rotate-password` to regenerate the password
307
+ - Side effect: re-runs and password rotation restart both services (brief downtime window); the previous password stops working as soon as the restart completes
308
+
309
+ Firewall rules are never changed by the installer. When firewalld is detected the install output prints the exact `--add-port` commands to run yourself; other distros: open the two ports per your firewall tool.
310
+
311
+ Note: the remote transport has no session for interactive confirmations, so write operations fall back to token approval — on the server, confirm write commands with `npx huaweicloud-devkit approve <token>`.
289
312
 
290
313
  ### Install KooCLI
291
314
 
package/README.zh-CN.md CHANGED
@@ -279,7 +279,30 @@ npx --yes huaweicloud-devkit-mcp --transport remote
279
279
  }
280
280
  ```
281
281
 
282
- > 端口被占用时用 `--port <端口>` 换端口,`url` 同步修改;需要局域网访问时加 `--host 0.0.0.0`。remote 服务器不内置鉴权,请勿匿名暴露到公网。
282
+ > 端口被占用时用 `--port <端口>` 换端口,`url` 同步修改;需要局域网访问时加 `--host 0.0.0.0`。remote 服务器默认不内置鉴权,须加 `--auth-password-file <文件>` 才启用密码校验——请勿匿名暴露到公网。
283
+
284
+ ### 服务器模式(systemd,Linux)
285
+
286
+ 以一对加固的 systemd 服务运行 MCP server:专用 OS 用户 + 自动生成的鉴权密码,适合无人值守/运维环境。
287
+
288
+ ```bash
289
+ sudo npx --yes huaweicloud-devkit install-server # 默认:/opt/kunpeng,业务端口 8088,工具端口 7088,用户 devkit
290
+ sudo npx --yes huaweicloud-devkit install-server --install-path /opt/kunpeng --port 8088 --tool-port 7088 --user devkit
291
+ sudo npx --yes huaweicloud-devkit uninstall-server # 追加 --remove-user 可删除服务用户
292
+ ```
293
+
294
+ 它会创建:
295
+
296
+ - 专用系统用户(默认 `devkit`,nologin shell),两个服务均以该用户运行
297
+ - `huaweicloud-devkit.service`(业务端口,默认 8088)与 `huaweicloud-devkit-tool.service`(工具端口,默认 7088)
298
+ - 自动生成的鉴权密码 `<install-path>/devkit/server/.auth-password`(0600,属主为服务用户);所有 RPC 需携带 `Authorization: Bearer <密码>` 或 `x-devkit-password: <密码>` —— `GET /health` 保持开放供探活
299
+ - 自包含运行时 `<install-path>/devkit/app`(缺 Node.js 22.19+ 时自动下载)
300
+ - 幂等可重跑;追加 `--rotate-password` 可重新生成密码
301
+ - 重跑或轮换密码会使两个服务各重启一次(短暂停机窗口);重启完成后旧密码立即失效
302
+
303
+ 装机不会改动任何防火墙规则:检测到 firewalld 在运行时,安装输出会原样打印 `--add-port` 命令由你自己执行;其他发行版请按各自防火墙工具放行两个端口。
304
+
305
+ 注意:remote 传输没有会话可承载交互确认,写操作自动回退令牌审批——在服务器上用 `npx huaweicloud-devkit approve <token>` 确认写命令。
283
306
 
284
307
  ### 安装 KooCLI
285
308
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
3
  "mcpName": "io.github.huaweicloud/huaweicloud-devkit",
4
- "version": "2.0.1-next.2",
4
+ "version": "2.0.1-next.3",
5
5
  "kooCliVersion": "7.3.12",
6
6
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
7
7
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "mcpServers": "./.mcp.json",
18
18
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
19
- "version": "2.0.1-next.2",
19
+ "version": "2.0.1-next.3",
20
20
  "author": {
21
21
  "name": "HuaweiCloud Mate",
22
22
  "url": "https://github.com/huaweicloud"
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "mcpServers": "./.mcp.json",
21
21
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
22
- "version": "2.0.1-next.2",
22
+ "version": "2.0.1-next.3",
23
23
  "author": {
24
24
  "name": "HuaweiCloud Mate",
25
25
  "url": "https://github.com/huaweicloud"
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "mcpServers": "./.mcp.json",
18
18
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
19
- "version": "2.0.1-next.2",
19
+ "version": "2.0.1-next.3",
20
20
  "author": {
21
21
  "name": "HuaweiCloud Mate",
22
22
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "2.0.1-next.2",
3
+ "version": "2.0.1-next.3",
4
4
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
5
5
  "author": {
6
6
  "name": "HuaweiCloud Mate",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "2.0.1-next.2",
3
+ "version": "2.0.1-next.3",
4
4
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
5
5
  "author": {
6
6
  "name": "HuaweiCloud Mate",
@@ -67777,13 +67777,35 @@ var mcp_server_remote_exports = {};
67777
67777
  __export(mcp_server_remote_exports, {
67778
67778
  DEFAULT_HOST: () => DEFAULT_HOST,
67779
67779
  DEFAULT_PORT: () => DEFAULT_PORT,
67780
- startRemoteServer: () => startRemoteServer
67780
+ startRemoteServer: () => startRemoteServer,
67781
+ verifyAuthPassword: () => verifyAuthPassword
67781
67782
  });
67782
67783
  import { createServer } from "node:http";
67784
+ import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
67785
+ import { readFileSync as readFileSync36 } from "node:fs";
67783
67786
  import { format } from "node:util";
67784
- async function startRemoteServer({ port = DEFAULT_PORT, host = DEFAULT_HOST } = {}) {
67787
+ function constantTimeEquals(actual, expected) {
67788
+ const actualBytes = Buffer.from(actual, "utf8");
67789
+ const expectedBytes = Buffer.from(expected, "utf8");
67790
+ return actualBytes.length === expectedBytes.length && timingSafeEqual2(actualBytes, expectedBytes);
67791
+ }
67792
+ function verifyAuthPassword(headers, expected) {
67793
+ if (!expected)
67794
+ return true;
67795
+ const auth = String(headers.authorization ?? "").trim();
67796
+ const bearer = auth.startsWith("Bearer ") ? auth.slice(7).trim() : "";
67797
+ if (bearer && constantTimeEquals(bearer, expected))
67798
+ return true;
67799
+ const direct = String(headers["x-devkit-password"] ?? "").trim();
67800
+ return direct.length > 0 && constantTimeEquals(direct, expected);
67801
+ }
67802
+ async function startRemoteServer({ port = DEFAULT_PORT, host = DEFAULT_HOST, authPasswordFile: authPasswordFile2 } = {}) {
67803
+ let authPassword = "";
67804
+ if (authPasswordFile2) {
67805
+ authPassword = readFileSync36(authPasswordFile2, "utf8").trim();
67806
+ }
67785
67807
  const server = createServer((req, res) => {
67786
- void handleRemoteRequest(req, res);
67808
+ void handleRemoteRequest(req, res, authPassword);
67787
67809
  });
67788
67810
  await new Promise((resolvePromise, rejectPromise) => {
67789
67811
  server.once("error", rejectPromise);
@@ -67800,16 +67822,29 @@ async function startRemoteServer({ port = DEFAULT_PORT, host = DEFAULT_HOST } =
67800
67822
  close: () => new Promise((resolvePromise) => server.close(() => resolvePromise()))
67801
67823
  };
67802
67824
  }
67803
- async function handleRemoteRequest(req, res) {
67825
+ async function handleRemoteRequest(req, res, authPassword) {
67804
67826
  res.setHeader("Access-Control-Allow-Origin", "*");
67805
67827
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
67806
- res.setHeader("Access-Control-Allow-Headers", "Content-Type, MCP-Protocol-Version, Mcp-Session-Id, Accept, Authorization");
67828
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type, MCP-Protocol-Version, Mcp-Session-Id, Accept, Authorization, X-DevKit-Password");
67807
67829
  res.setHeader("Access-Control-Expose-Headers", "MCP-Protocol-Version, Mcp-Session-Id");
67808
67830
  if (req.method === "OPTIONS") {
67809
67831
  res.writeHead(204);
67810
67832
  res.end();
67811
67833
  return;
67812
67834
  }
67835
+ if (req.method === "GET" && (req.url ?? "").split("?")[0] === "/health") {
67836
+ res.writeHead(200, { "Content-Type": "application/json" });
67837
+ res.end(JSON.stringify({ ok: true }));
67838
+ return;
67839
+ }
67840
+ if (authPassword && !verifyAuthPassword(req.headers, authPassword)) {
67841
+ res.writeHead(401, {
67842
+ "Content-Type": "application/json",
67843
+ "WWW-Authenticate": 'Bearer realm="huaweicloud-devkit-mcp"'
67844
+ });
67845
+ res.end(JSON.stringify({ error: "Unauthorized", hint: "send Authorization: Bearer <password> or x-devkit-password" }));
67846
+ return;
67847
+ }
67813
67848
  if (req.method !== "POST") {
67814
67849
  res.writeHead(405, { Allow: "POST, OPTIONS" });
67815
67850
  res.end();
@@ -68103,7 +68138,7 @@ init_update_check();
68103
68138
  init_hcloud_probe();
68104
68139
  init_koocli_paths();
68105
68140
  import { spawn as spawn4 } from "node:child_process";
68106
- import { appendFileSync as appendFileSync5, closeSync as closeSync2, existsSync as existsSync38, mkdirSync as mkdirSync17, openSync as openSync2, readFileSync as readFileSync36, rmSync as rmSync11, statSync as statSync11, writeFileSync as writeFileSync17 } from "node:fs";
68141
+ import { appendFileSync as appendFileSync5, closeSync as closeSync2, existsSync as existsSync38, mkdirSync as mkdirSync17, openSync as openSync2, readFileSync as readFileSync37, rmSync as rmSync11, statSync as statSync11, writeFileSync as writeFileSync17 } from "node:fs";
68107
68142
  import { dirname as dirname28, join as join49 } from "node:path";
68108
68143
  import { fileURLToPath as fileURLToPath11 } from "node:url";
68109
68144
  var __dirname9 = dirname28(fileURLToPath11(import.meta.url));
@@ -68124,7 +68159,7 @@ function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
68124
68159
  mkdirSync17(dirname28(lockPath), { recursive: true });
68125
68160
  let replace = false;
68126
68161
  try {
68127
- replace = lockIsStale(String(readFileSync36(lockPath, "utf8")));
68162
+ replace = lockIsStale(String(readFileSync37(lockPath, "utf8")));
68128
68163
  } catch {
68129
68164
  }
68130
68165
  if (replace) {
@@ -68147,7 +68182,7 @@ function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
68147
68182
  function releaseInstallLock(lockPath = kooCliInstallLockPath(), ownedTs) {
68148
68183
  try {
68149
68184
  if (ownedTs !== void 0) {
68150
- const body = String(readFileSync36(lockPath, "utf8")).trim();
68185
+ const body = String(readFileSync37(lockPath, "utf8")).trim();
68151
68186
  if (body !== String(ownedTs))
68152
68187
  return;
68153
68188
  }
@@ -68184,7 +68219,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
68184
68219
  }
68185
68220
  try {
68186
68221
  if (existsSync38(failureMarkerPath())) {
68187
- const ts = Number(String(readFileSync36(failureMarkerPath(), "utf8")).trim());
68222
+ const ts = Number(String(readFileSync37(failureMarkerPath(), "utf8")).trim());
68188
68223
  if (Number.isFinite(ts) && Date.now() - ts < INSTALL_FAILURE_COOLDOWN_MS) {
68189
68224
  return { launched: false, reason: "cooldown after an unsuccessful install attempt" };
68190
68225
  }
@@ -68197,7 +68232,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
68197
68232
  }
68198
68233
  let ownedTs;
68199
68234
  try {
68200
- ownedTs = Number(String(readFileSync36(kooCliInstallLockPath(), "utf8")).trim());
68235
+ ownedTs = Number(String(readFileSync37(kooCliInstallLockPath(), "utf8")).trim());
68201
68236
  if (!Number.isFinite(ownedTs))
68202
68237
  ownedTs = void 0;
68203
68238
  } catch {
@@ -68262,6 +68297,9 @@ var portIdx = process.argv.indexOf("--port");
68262
68297
  var remotePort = portIdx > -1 ? Number(process.argv[portIdx + 1]) : DEFAULT_PORT;
68263
68298
  var hostIdx = process.argv.indexOf("--host");
68264
68299
  var remoteHost = hostIdx > -1 && process.argv[hostIdx + 1] ? process.argv[hostIdx + 1] : DEFAULT_HOST;
68300
+ var authFileIdx = process.argv.indexOf("--auth-password-file");
68301
+ var authFileArg = authFileIdx > -1 ? process.argv[authFileIdx + 1] : void 0;
68302
+ var authPasswordFile = authFileArg ? resolve10(authFileArg) : void 0;
68265
68303
  var projectDirIdx = process.argv.indexOf("--codearts-project-dir");
68266
68304
  if (projectDirIdx > -1 && process.argv[projectDirIdx + 1]) {
68267
68305
  process.env.CODEARTS_PROJECT_DIR = process.argv[projectDirIdx + 1];
@@ -68300,7 +68338,7 @@ if (transport === "remote") {
68300
68338
  process.stderr.write("DEVKIT_APPROVAL_MODE=ask is not supported on the remote transport (no session to run the confirmation in); falling back to token approval.\n");
68301
68339
  }
68302
68340
  const { startRemoteServer: startRemoteServer2 } = await Promise.resolve().then(() => (init_mcp_server_remote(), mcp_server_remote_exports));
68303
- startRemoteServer2({ port: remotePort, host: remoteHost }).catch((error62) => {
68341
+ startRemoteServer2({ port: remotePort, host: remoteHost, authPasswordFile }).catch((error62) => {
68304
68342
  process.stderr.write(`Failed to start MCP remote server: ${error62 instanceof Error ? error62.message : String(error62)}
68305
68343
  `);
68306
68344
  process.exit(1);