@szc-ft/mcp-szcd-client 0.11.6 → 0.12.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.
@@ -121,13 +121,13 @@ function showSuccessMessage(traeResult, claudeResult, qwenResult, qoderResult) {
121
121
 
122
122
  console.log("\n🔧 IDE/Agent Configuration:");
123
123
  console.log("\n For Claude Code (via CLI):");
124
- console.log(` claude mcp add --transport sse --scope user ${common.getMcpServerName()} ${common.getMcpServerUrl()}/sse`);
124
+ console.log(` claude mcp add --transport http --scope user ${common.getMcpServerName()} ${common.getMcpServerUrl()}/mcp`);
125
125
  console.log("\n For Trae CLI (via CLI):");
126
- console.log(` trae-cli mcp add-json ${common.getMcpServerName()} '{"type":"sse","url":"${common.getMcpServerUrl()}/sse"}'`);
126
+ console.log(` trae-cli mcp add-json ${common.getMcpServerName()} '{"type":"http","url":"${common.getMcpServerUrl()}/mcp"}'`);
127
127
  console.log("\n For Qwen Code (via CLI):");
128
- console.log(` qwen mcp add --transport sse --scope user ${common.getMcpServerName()} ${common.getMcpServerUrl()}/sse`);
128
+ console.log(` qwen mcp add --transport http --scope user ${common.getMcpServerName()} ${common.getMcpServerUrl()}/mcp`);
129
129
  console.log("\n For Qoder CLI (via CLI):");
130
- console.log(` qoder mcp add ${common.getMcpServerName()} -s user -- ${common.getMcpServerUrl()}/sse`);
130
+ console.log(` qoder mcp add ${common.getMcpServerName()} -s user -- ${common.getMcpServerUrl()}/mcp`);
131
131
 
132
132
  console.log("\n💡 Configuration Priority:");
133
133
  console.log(" 1. Environment variables (highest priority)");
@@ -26,6 +26,7 @@
26
26
  import fs from "node:fs";
27
27
  import path from "node:path";
28
28
  import os from "node:os";
29
+ import { execSync } from "node:child_process";
29
30
  import { syncMcpUrl as syncTraeCli } from "./lib/trae-cli.js";
30
31
  import { syncMcpUrl as syncTraeIde } from "./lib/trae-ide.js";
31
32
  import { syncMcpUrl as syncClaudeCode } from "./lib/claude-code.js";
@@ -70,6 +71,53 @@ function getMcpServerName() {
70
71
  return config.MCP_SERVER_NAME || DEFAULT_MCP_SERVER_NAME;
71
72
  }
72
73
 
74
+ // ==================== 更新源文件 ====================
75
+
76
+ /**
77
+ * 更新 agents/platforms.json 中的 MCP URL,然后重新构建 qwen-extension.json
78
+ * 这样 qwen 扩展的源文件和构建产物都保持一致
79
+ */
80
+ function updatePlatformsJson(targetUrl) {
81
+ // 从脚本位置推断包根目录
82
+ const scriptsDir = path.dirname(new URL(import.meta.url).pathname);
83
+ const packageRoot = path.dirname(scriptsDir);
84
+ const platformsPath = path.join(packageRoot, "agents", "platforms.json");
85
+
86
+ if (!fs.existsSync(platformsPath)) {
87
+ console.log("⏭️ Skipping platforms.json update: file not found");
88
+ return;
89
+ }
90
+
91
+ const mcpUrl = `${targetUrl}/mcp`;
92
+ const platforms = JSON.parse(fs.readFileSync(platformsPath, "utf8"));
93
+
94
+ if (!platforms.platforms || !platforms.platforms.qwen || !platforms.platforms.qwen.mcp) {
95
+ console.log("⏭️ Skipping platforms.json update: qwen.mcp not found");
96
+ return;
97
+ }
98
+
99
+ if (platforms.platforms.qwen.mcp.url === mcpUrl) {
100
+ console.log(`⏭️ platforms.json qwen.mcp already up-to-date: ${mcpUrl}`);
101
+ return;
102
+ }
103
+
104
+ platforms.platforms.qwen.mcp.url = mcpUrl;
105
+ fs.writeFileSync(platformsPath, JSON.stringify(platforms, null, 4) + "\n");
106
+ console.log(`✓ Updated platforms.json: qwen.mcp.url → ${mcpUrl}`);
107
+
108
+ // 重新构建 qwen-extension.json
109
+ const buildScript = path.join(packageRoot, "agents", "build.js");
110
+ if (fs.existsSync(buildScript)) {
111
+ try {
112
+ execSync(`node "${buildScript}"`, { stdio: "pipe", cwd: packageRoot });
113
+ console.log(`✓ Rebuilt qwen-extension.json from platforms.json`);
114
+ } catch (e) {
115
+ console.log(`⚠️ Failed to rebuild agents: ${e.message}`);
116
+ console.log(` Run manually: npm run build:agents`);
117
+ }
118
+ }
119
+ }
120
+
73
121
  // ==================== 确定目标 URL ====================
74
122
 
75
123
  function resolveTargetUrl(inputUrl) {
@@ -125,7 +173,10 @@ function main() {
125
173
  // 1. 更新 szcd 自身配置文件
126
174
  updateConfigFile(targetUrl);
127
175
 
128
- // 2. 委托各 lib 模块同步对应 IDE 配置
176
+ // 2. 更新源文件 platforms.json 中的 MCP URL 并重新构建
177
+ updatePlatformsJson(targetUrl);
178
+
179
+ // 3. 委托各 lib 模块同步对应 IDE 配置
129
180
  syncTraeCli(targetUrl, serverName);
130
181
  syncTraeIde(targetUrl, serverName);
131
182
  syncClaudeCode(targetUrl, serverName);