bluelamp 6.3.5 → 6.3.6
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/lib/mcp-server/index.cjs +42 -13
- package/package.json +1 -1
package/lib/mcp-server/index.cjs
CHANGED
|
@@ -707,12 +707,32 @@ class BlueLampServer {
|
|
|
707
707
|
|
|
708
708
|
// アクティブな子プロセスから設定を取得(activateExternal 時に保存済み)
|
|
709
709
|
const child = this.childManager.children.get(service_id);
|
|
710
|
-
const
|
|
710
|
+
const cachedService = child?.service;
|
|
711
711
|
|
|
712
|
-
if (!
|
|
712
|
+
if (!cachedService) {
|
|
713
713
|
return { content: [{ type: 'text', text: `❌ "${service_id}" は現在アクティブではありません。activate_service で有効化してください。` }], isError: true };
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
+
// restart の主用途は「コード更新 / env 更新の反映」。
|
|
717
|
+
// cached service.env は activate 時の snapshot のため、save_mcp_env で
|
|
718
|
+
// 更新した env が反映されない。getGatewayConfig で latest env を fetch して
|
|
719
|
+
// refresh する(command/args 等は変わらないので cached を維持)。
|
|
720
|
+
let service = cachedService;
|
|
721
|
+
if (TOKEN) {
|
|
722
|
+
try {
|
|
723
|
+
const cfg = await getGatewayConfig(TOKEN);
|
|
724
|
+
if (cfg.success) {
|
|
725
|
+
const latest = (cfg.data?.services || []).find(s => s.mcpId === service_id);
|
|
726
|
+
if (latest && latest.env) {
|
|
727
|
+
service = { ...cachedService, env: latest.env };
|
|
728
|
+
log(`[restart] "${service_id}" env refreshed from server (keys=${Object.keys(latest.env).join(',') || 'none'})`);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
} catch (err) {
|
|
732
|
+
log(`[restart] env refresh failed (using cached): ${err.message}`);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
716
736
|
// 1. 既存プロセスを停止
|
|
717
737
|
this.childManager.deactivate(service_id);
|
|
718
738
|
log(`[restart] "${service_id}" stopped`);
|
|
@@ -883,20 +903,29 @@ class BlueLampServer {
|
|
|
883
903
|
// サーバーにインストール登録(ユーザーの UserMcpInstallation に追加)
|
|
884
904
|
// cloud_proxy 判定のために先に登録しておく(hostingType 取得目的も兼ねる)
|
|
885
905
|
if (TOKEN) {
|
|
886
|
-
|
|
906
|
+
// 既存の alwaysOn 状態と hostingType を 1 回の getGatewayConfig で先取り。
|
|
907
|
+
// installMcpService の第 2 引数で alwaysOn を強制 false 上書きすると、
|
|
908
|
+
// 次回起動時に autoActivate されなくなる(既存ユーザーが「アップデート」目的で
|
|
909
|
+
// install_from_store を呼んだだけで alwaysOn が解除される回帰)。
|
|
910
|
+
let preserveAlwaysOn = false;
|
|
911
|
+
try {
|
|
912
|
+
const cfgPre = await getGatewayConfig(TOKEN);
|
|
913
|
+
if (cfgPre.success) {
|
|
914
|
+
const existing = (cfgPre.data?.services || []).find(s => s.mcpId === mcp_id);
|
|
915
|
+
if (existing) {
|
|
916
|
+
preserveAlwaysOn = existing.alwaysOn === true;
|
|
917
|
+
if (!hostingType) hostingType = existing.hostingType;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
} catch (_) {
|
|
921
|
+
// fallback: alwaysOn=false(新規扱い)
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
const installResult = await installMcpService(mcp_id, preserveAlwaysOn, TOKEN);
|
|
887
925
|
if (!installResult.success) {
|
|
888
926
|
return { content: [{ type: 'text', text: `❌ サーバー登録失敗: ${installResult.error || 'Unknown'}` }], isError: true };
|
|
889
927
|
}
|
|
890
|
-
log(`[install_from_store] Server sync OK: ${mcp_id}`);
|
|
891
|
-
|
|
892
|
-
// hostingType が packageSource に無かった場合、gateway-config から取得
|
|
893
|
-
if (!hostingType) {
|
|
894
|
-
const cfg = await getGatewayConfig(TOKEN);
|
|
895
|
-
if (cfg.success) {
|
|
896
|
-
const svc = (cfg.data?.services || []).find(s => s.mcpId === mcp_id);
|
|
897
|
-
if (svc) hostingType = svc.hostingType;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
928
|
+
log(`[install_from_store] Server sync OK: ${mcp_id} (alwaysOn=${preserveAlwaysOn})`);
|
|
900
929
|
}
|
|
901
930
|
|
|
902
931
|
// cloud_proxy は子プロセス不要 → ローカル展開スキップ(ゲートウェイがプロキシ転送)
|