huaweicloud-devkit 2.0.1-next.1 → 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.1",
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.1",
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.1",
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.1",
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.1",
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.1",
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",
@@ -69,6 +69,10 @@ function planningWarnings(args) {
69
69
  }
70
70
  const REQUIRED_PARAMS = {
71
71
  'ECS CreateServers': ['server.flavorRef', 'server.imageRef', 'server.nics.1.subnet_id'],
72
+ // KooCLI rejects a CreatePostPaidServers call that omits server.vpcid
73
+ // with "The following parameters are required: server.vpcid" (live
74
+ // evidence 2026-11-27), so the plan warns before the child ever runs.
75
+ 'ECS CreatePostPaidServers': ['server.flavorRef', 'server.imageRef', 'server.nics.1.subnet_id', 'server.vpcid'],
72
76
  'VPC CreateVpc': ['vpc.cidr'],
73
77
  'VPC CreateSubnet': ['subnet.vpc_id', 'subnet.cidr'],
74
78
  'VPC CreateSecurityGroupRule': [
@@ -87,6 +91,7 @@ const PARAM_VALUE_HINTS = {
87
91
  'server.flavorRef': 'Run `hcloud ECS ListFlavors --cli-region=<r>` to find valid flavors',
88
92
  'server.imageRef': 'Run `hcloud IMS ListImages --cli-region=<r> --__imagetype=gold` to find image IDs',
89
93
  'server.nics.1.subnet_id': 'Run `hcloud VPC ListSubnets --cli-region=<r>` to find subnet IDs',
94
+ 'server.vpcid': 'Run `hcloud VPC ListVpcs --cli-region=<r>` to find VPC IDs (KooCLI rejects CreatePostPaidServers without it)',
90
95
  'subnet.vpc_id': 'Run `hcloud VPC ListVpcs --cli-region=<r>` to find VPC IDs',
91
96
  func_name: 'Function name must be unique within project',
92
97
  runtime: 'Run `hcloud FunctionGraph ListRuntimes` to see available runtimes',
@@ -45259,6 +45259,16 @@ function classifyHcloudArgs(args, options = {}) {
45259
45259
  reason: "The command appears to retrieve a secret value. Use a runtime secret reference pattern instead."
45260
45260
  };
45261
45261
  }
45262
+ if (options.rawCommand === void 0 && (normalizedArgs.includes(DRYRUN_GLOBAL_TOKEN) || DRY_RUN_PREFLIGHT_OPERATIONS.has(`${service.toLowerCase()} ${operation.toLowerCase()}`) && normalizedArgs.includes(DRY_RUN_EXACT_TOKEN) && !normalizedArgs.some((arg) => arg.startsWith("--cli-jsonInput")))) {
45263
+ return applyCommandRiskRules({
45264
+ decision: "allow",
45265
+ risk: "preflight",
45266
+ reason: "Documented dry-run preflight: the CLI prints the request without executing, or the service validates it and creates nothing, so no confirmation is required.",
45267
+ service,
45268
+ operation,
45269
+ args: normalizedArgs
45270
+ }, normalizedArgs, options);
45271
+ }
45262
45272
  const readOnly = hasReadPrefix(operation, policy);
45263
45273
  const executionOps = /(^|\.)(Invoke|SyncInvoke|AsyncInvoke|Send|Trigger|Execute|Start|Reboot|Restart|Stop|Publish|Deploy)/i;
45264
45274
  const isExecution = executionOps.test(operation) && !readOnly;
@@ -45346,6 +45356,7 @@ function assertAllowed(result) {
45346
45356
  }
45347
45357
  return result;
45348
45358
  }
45359
+ var DRYRUN_GLOBAL_TOKEN, DRY_RUN_PREFLIGHT_OPERATIONS, DRY_RUN_EXACT_TOKEN;
45349
45360
  var init_classify_hcloud = __esm({
45350
45361
  "plugins/huaweicloud-core/dist.new/safety/classify-hcloud.js"() {
45351
45362
  "use strict";
@@ -45358,6 +45369,9 @@ var init_classify_hcloud = __esm({
45358
45369
  init_tokens();
45359
45370
  init_unwrap();
45360
45371
  init_vocabulary();
45372
+ DRYRUN_GLOBAL_TOKEN = "--dryrun";
45373
+ DRY_RUN_PREFLIGHT_OPERATIONS = /* @__PURE__ */ new Set(["ecs createservers", "ecs createpostpaidservers"]);
45374
+ DRY_RUN_EXACT_TOKEN = "--dry_run=true";
45361
45375
  }
45362
45376
  });
45363
45377
 
@@ -59362,6 +59376,10 @@ var init_hcloud_plan = __esm({
59362
59376
  init_hcloud_triage();
59363
59377
  REQUIRED_PARAMS = {
59364
59378
  "ECS CreateServers": ["server.flavorRef", "server.imageRef", "server.nics.1.subnet_id"],
59379
+ // KooCLI rejects a CreatePostPaidServers call that omits server.vpcid
59380
+ // with "The following parameters are required: server.vpcid" (live
59381
+ // evidence 2026-11-27), so the plan warns before the child ever runs.
59382
+ "ECS CreatePostPaidServers": ["server.flavorRef", "server.imageRef", "server.nics.1.subnet_id", "server.vpcid"],
59365
59383
  "VPC CreateVpc": ["vpc.cidr"],
59366
59384
  "VPC CreateSubnet": ["subnet.vpc_id", "subnet.cidr"],
59367
59385
  "VPC CreateSecurityGroupRule": [
@@ -59380,6 +59398,7 @@ var init_hcloud_plan = __esm({
59380
59398
  "server.flavorRef": "Run `hcloud ECS ListFlavors --cli-region=<r>` to find valid flavors",
59381
59399
  "server.imageRef": "Run `hcloud IMS ListImages --cli-region=<r> --__imagetype=gold` to find image IDs",
59382
59400
  "server.nics.1.subnet_id": "Run `hcloud VPC ListSubnets --cli-region=<r>` to find subnet IDs",
59401
+ "server.vpcid": "Run `hcloud VPC ListVpcs --cli-region=<r>` to find VPC IDs (KooCLI rejects CreatePostPaidServers without it)",
59383
59402
  "subnet.vpc_id": "Run `hcloud VPC ListVpcs --cli-region=<r>` to find VPC IDs",
59384
59403
  func_name: "Function name must be unique within project",
59385
59404
  runtime: "Run `hcloud FunctionGraph ListRuntimes` to see available runtimes",
@@ -67758,13 +67777,35 @@ var mcp_server_remote_exports = {};
67758
67777
  __export(mcp_server_remote_exports, {
67759
67778
  DEFAULT_HOST: () => DEFAULT_HOST,
67760
67779
  DEFAULT_PORT: () => DEFAULT_PORT,
67761
- startRemoteServer: () => startRemoteServer
67780
+ startRemoteServer: () => startRemoteServer,
67781
+ verifyAuthPassword: () => verifyAuthPassword
67762
67782
  });
67763
67783
  import { createServer } from "node:http";
67784
+ import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
67785
+ import { readFileSync as readFileSync36 } from "node:fs";
67764
67786
  import { format } from "node:util";
67765
- 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
+ }
67766
67807
  const server = createServer((req, res) => {
67767
- void handleRemoteRequest(req, res);
67808
+ void handleRemoteRequest(req, res, authPassword);
67768
67809
  });
67769
67810
  await new Promise((resolvePromise, rejectPromise) => {
67770
67811
  server.once("error", rejectPromise);
@@ -67781,16 +67822,29 @@ async function startRemoteServer({ port = DEFAULT_PORT, host = DEFAULT_HOST } =
67781
67822
  close: () => new Promise((resolvePromise) => server.close(() => resolvePromise()))
67782
67823
  };
67783
67824
  }
67784
- async function handleRemoteRequest(req, res) {
67825
+ async function handleRemoteRequest(req, res, authPassword) {
67785
67826
  res.setHeader("Access-Control-Allow-Origin", "*");
67786
67827
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
67787
- 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");
67788
67829
  res.setHeader("Access-Control-Expose-Headers", "MCP-Protocol-Version, Mcp-Session-Id");
67789
67830
  if (req.method === "OPTIONS") {
67790
67831
  res.writeHead(204);
67791
67832
  res.end();
67792
67833
  return;
67793
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
+ }
67794
67848
  if (req.method !== "POST") {
67795
67849
  res.writeHead(405, { Allow: "POST, OPTIONS" });
67796
67850
  res.end();
@@ -68084,7 +68138,7 @@ init_update_check();
68084
68138
  init_hcloud_probe();
68085
68139
  init_koocli_paths();
68086
68140
  import { spawn as spawn4 } from "node:child_process";
68087
- 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";
68088
68142
  import { dirname as dirname28, join as join49 } from "node:path";
68089
68143
  import { fileURLToPath as fileURLToPath11 } from "node:url";
68090
68144
  var __dirname9 = dirname28(fileURLToPath11(import.meta.url));
@@ -68105,7 +68159,7 @@ function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
68105
68159
  mkdirSync17(dirname28(lockPath), { recursive: true });
68106
68160
  let replace = false;
68107
68161
  try {
68108
- replace = lockIsStale(String(readFileSync36(lockPath, "utf8")));
68162
+ replace = lockIsStale(String(readFileSync37(lockPath, "utf8")));
68109
68163
  } catch {
68110
68164
  }
68111
68165
  if (replace) {
@@ -68128,7 +68182,7 @@ function acquireInstallLock(lockPath = kooCliInstallLockPath()) {
68128
68182
  function releaseInstallLock(lockPath = kooCliInstallLockPath(), ownedTs) {
68129
68183
  try {
68130
68184
  if (ownedTs !== void 0) {
68131
- const body = String(readFileSync36(lockPath, "utf8")).trim();
68185
+ const body = String(readFileSync37(lockPath, "utf8")).trim();
68132
68186
  if (body !== String(ownedTs))
68133
68187
  return;
68134
68188
  }
@@ -68165,7 +68219,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
68165
68219
  }
68166
68220
  try {
68167
68221
  if (existsSync38(failureMarkerPath())) {
68168
- const ts = Number(String(readFileSync36(failureMarkerPath(), "utf8")).trim());
68222
+ const ts = Number(String(readFileSync37(failureMarkerPath(), "utf8")).trim());
68169
68223
  if (Number.isFinite(ts) && Date.now() - ts < INSTALL_FAILURE_COOLDOWN_MS) {
68170
68224
  return { launched: false, reason: "cooldown after an unsuccessful install attempt" };
68171
68225
  }
@@ -68178,7 +68232,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
68178
68232
  }
68179
68233
  let ownedTs;
68180
68234
  try {
68181
- ownedTs = Number(String(readFileSync36(kooCliInstallLockPath(), "utf8")).trim());
68235
+ ownedTs = Number(String(readFileSync37(kooCliInstallLockPath(), "utf8")).trim());
68182
68236
  if (!Number.isFinite(ownedTs))
68183
68237
  ownedTs = void 0;
68184
68238
  } catch {
@@ -68243,6 +68297,9 @@ var portIdx = process.argv.indexOf("--port");
68243
68297
  var remotePort = portIdx > -1 ? Number(process.argv[portIdx + 1]) : DEFAULT_PORT;
68244
68298
  var hostIdx = process.argv.indexOf("--host");
68245
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;
68246
68303
  var projectDirIdx = process.argv.indexOf("--codearts-project-dir");
68247
68304
  if (projectDirIdx > -1 && process.argv[projectDirIdx + 1]) {
68248
68305
  process.env.CODEARTS_PROJECT_DIR = process.argv[projectDirIdx + 1];
@@ -68281,7 +68338,7 @@ if (transport === "remote") {
68281
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");
68282
68339
  }
68283
68340
  const { startRemoteServer: startRemoteServer2 } = await Promise.resolve().then(() => (init_mcp_server_remote(), mcp_server_remote_exports));
68284
- startRemoteServer2({ port: remotePort, host: remoteHost }).catch((error62) => {
68341
+ startRemoteServer2({ port: remotePort, host: remoteHost, authPasswordFile }).catch((error62) => {
68285
68342
  process.stderr.write(`Failed to start MCP remote server: ${error62 instanceof Error ? error62.message : String(error62)}
68286
68343
  `);
68287
68344
  process.exit(1);