@szc-ft/mcp-szcd-client 0.11.5 → 0.12.0
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 +143 -0
- package/agents/build.js +331 -0
- package/agents/platforms.json +47 -0
- package/agents/qwen-extension/agents/szcd-component-expert.md +165 -0
- package/agents/src/szcd-component-expert.md +352 -0
- package/agents/src/tools.json +112 -0
- package/agents/szcd-component-expert.md +25 -19
- package/agents/szcd-component-expert.qoder.md +226 -0
- package/agents/szcd-component-expert.trae.md +113 -93
- package/commands/szcd-mcp-url.md +2 -2
- package/package.json +8 -5
- package/scripts/lib/claude-code.js +30 -30
- package/scripts/lib/qoder.js +43 -32
- package/scripts/lib/qwen-code.js +14 -14
- package/scripts/lib/trae-cli.js +22 -22
- package/scripts/lib/trae-ide.js +12 -12
- package/scripts/postinstall.js +4 -4
- package/skill/SKILL.md +288 -358
|
@@ -41,7 +41,7 @@ function getClaudeCodeConfigPath() {
|
|
|
41
41
|
|
|
42
42
|
function syncClaudeCodeConfig(deps) {
|
|
43
43
|
const configPath = getClaudeCodeConfigPath();
|
|
44
|
-
const
|
|
44
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
45
45
|
const serverName = deps.getMcpServerName();
|
|
46
46
|
|
|
47
47
|
let config = {};
|
|
@@ -54,36 +54,36 @@ function syncClaudeCodeConfig(deps) {
|
|
|
54
54
|
if (!config.mcpServers) config.mcpServers = {};
|
|
55
55
|
|
|
56
56
|
const current = config.mcpServers[serverName];
|
|
57
|
-
if (current && current.type === "
|
|
58
|
-
console.log(`✓ Claude Code ~/.claude.json already up-to-date: ${
|
|
57
|
+
if (current && current.type === "http" && current.url === mcpUrl) {
|
|
58
|
+
console.log(`✓ Claude Code ~/.claude.json already up-to-date: ${mcpUrl}`);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
config.mcpServers[serverName] = {
|
|
63
|
-
type: "
|
|
64
|
-
url:
|
|
63
|
+
type: "http",
|
|
64
|
+
url: mcpUrl,
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
68
|
-
console.log(`✓ Updated Claude Code ~/.claude.json: ${
|
|
68
|
+
console.log(`✓ Updated Claude Code ~/.claude.json: ${mcpUrl}`);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// ==================== CLI 命令同步 ====================
|
|
72
72
|
|
|
73
73
|
function createClaudeCodeUserConfig(deps) {
|
|
74
74
|
if (deps.isCommandAvailable("claude")) {
|
|
75
|
-
const
|
|
75
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
76
76
|
const serverName = deps.getMcpServerName();
|
|
77
77
|
|
|
78
|
-
const result = deps.safeExecSync(`claude mcp add --transport
|
|
78
|
+
const result = deps.safeExecSync(`claude mcp add --transport http --scope user ${serverName} ${mcpUrl}`);
|
|
79
79
|
if (result === true) {
|
|
80
|
-
console.log(`✓ Claude Code user MCP server added via CLI: ${serverName} (${
|
|
80
|
+
console.log(`✓ Claude Code user MCP server added via CLI: ${serverName} (${mcpUrl})`);
|
|
81
81
|
} else if (result === "already_exists") {
|
|
82
|
-
console.log(`✓ Claude Code user MCP server already configured: ${serverName} (${
|
|
82
|
+
console.log(`✓ Claude Code user MCP server already configured: ${serverName} (${mcpUrl})`);
|
|
83
83
|
} else {
|
|
84
84
|
if (deps.safeExecSync(`claude mcp remove --scope user ${serverName} 2>/dev/null`) &&
|
|
85
|
-
deps.safeExecSync(`claude mcp add --transport
|
|
86
|
-
console.log(`✓ Claude Code user MCP server updated via CLI: ${serverName} (${
|
|
85
|
+
deps.safeExecSync(`claude mcp add --transport http --scope user ${serverName} ${mcpUrl}`)) {
|
|
86
|
+
console.log(`✓ Claude Code user MCP server updated via CLI: ${serverName} (${mcpUrl})`);
|
|
87
87
|
} else {
|
|
88
88
|
console.warn(`⚠️ Failed to configure Claude Code MCP server via CLI (config file will be updated directly)`);
|
|
89
89
|
}
|
|
@@ -101,27 +101,27 @@ function createClaudeCodeProjectConfig(deps) {
|
|
|
101
101
|
return false;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
const
|
|
104
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
105
105
|
const serverName = deps.getMcpServerName();
|
|
106
106
|
|
|
107
|
-
const result = deps.safeExecSync(`claude mcp add --transport
|
|
107
|
+
const result = deps.safeExecSync(`claude mcp add --transport http --scope project ${serverName} ${mcpUrl}`);
|
|
108
108
|
if (result === true) {
|
|
109
|
-
console.log(`✓ Claude Code project MCP server added via CLI: ${serverName} (${
|
|
109
|
+
console.log(`✓ Claude Code project MCP server added via CLI: ${serverName} (${mcpUrl})`);
|
|
110
110
|
return true;
|
|
111
111
|
}
|
|
112
112
|
if (result === "already_exists") {
|
|
113
|
-
console.log(`✓ Claude Code project MCP server already configured: ${serverName} (${
|
|
113
|
+
console.log(`✓ Claude Code project MCP server already configured: ${serverName} (${mcpUrl})`);
|
|
114
114
|
return true;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
if (deps.safeExecSync(`claude mcp remove --scope project ${serverName} 2>/dev/null`) &&
|
|
118
|
-
deps.safeExecSync(`claude mcp add --transport
|
|
119
|
-
console.log(`✓ Claude Code project MCP server updated via CLI: ${serverName} (${
|
|
118
|
+
deps.safeExecSync(`claude mcp add --transport http --scope project ${serverName} ${mcpUrl}`)) {
|
|
119
|
+
console.log(`✓ Claude Code project MCP server updated via CLI: ${serverName} (${mcpUrl})`);
|
|
120
120
|
return true;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
console.warn(`⚠️ Failed to configure Claude Code project MCP server, please configure manually:`);
|
|
124
|
-
console.warn(` claude mcp add --transport
|
|
124
|
+
console.warn(` claude mcp add --transport http --scope project ${serverName} ${mcpUrl}`);
|
|
125
125
|
return false;
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -167,8 +167,8 @@ function copyAgentToClaudeCode(deps, isProjectLevel = false) {
|
|
|
167
167
|
claudeAgentsDir = getClaudeCodeAgentsDirectory();
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
// Claude Code 只复制不含 .trae. 的 .md 文件(原生格式)
|
|
171
|
-
const agentFiles = fs.readdirSync(agentsSourceDir).filter(f => f.endsWith(".md") && !f.includes(".trae."));
|
|
170
|
+
// Claude Code 只复制不含 .trae. 和 .qoder. 的 .md 文件(原生格式)
|
|
171
|
+
const agentFiles = fs.readdirSync(agentsSourceDir).filter(f => f.endsWith(".md") && !f.includes(".trae.") && !f.includes(".qoder."));
|
|
172
172
|
let copied = 0;
|
|
173
173
|
|
|
174
174
|
for (const agentFile of agentFiles) {
|
|
@@ -263,14 +263,14 @@ function safeExecSync(command) {
|
|
|
263
263
|
* @param {string} serverName - MCP 服务器名称
|
|
264
264
|
*/
|
|
265
265
|
export function syncMcpUrl(targetUrl, serverName) {
|
|
266
|
-
const
|
|
266
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
267
267
|
|
|
268
268
|
// 1. CLI 命令同步
|
|
269
269
|
if (isCommandAvailable("claude")) {
|
|
270
270
|
safeExecSync(`claude mcp remove --scope user ${serverName} 2>/dev/null`);
|
|
271
|
-
const result = safeExecSync(`claude mcp add --transport
|
|
271
|
+
const result = safeExecSync(`claude mcp add --transport http --scope user ${serverName} ${mcpUrl}`);
|
|
272
272
|
if (result === true || result === "already_exists") {
|
|
273
|
-
console.log(`✓ Claude Code CLI synced: ${
|
|
273
|
+
console.log(`✓ Claude Code CLI synced: ${mcpUrl}`);
|
|
274
274
|
} else {
|
|
275
275
|
console.warn(`⚠️ Claude Code CLI sync failed (~/.claude.json will be updated directly)`);
|
|
276
276
|
}
|
|
@@ -287,7 +287,7 @@ export function syncMcpUrl(targetUrl, serverName) {
|
|
|
287
287
|
*/
|
|
288
288
|
function syncClaudeCodeConfigDirect(targetUrl, serverName) {
|
|
289
289
|
const configPath = getClaudeCodeConfigPath();
|
|
290
|
-
const
|
|
290
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
291
291
|
|
|
292
292
|
let config = {};
|
|
293
293
|
if (fs.existsSync(configPath)) {
|
|
@@ -299,18 +299,18 @@ function syncClaudeCodeConfigDirect(targetUrl, serverName) {
|
|
|
299
299
|
if (!config.mcpServers) config.mcpServers = {};
|
|
300
300
|
|
|
301
301
|
const current = config.mcpServers[serverName];
|
|
302
|
-
if (current && current.type === "
|
|
303
|
-
console.log(`⏭️ Claude Code ~/.claude.json already up-to-date: ${
|
|
302
|
+
if (current && current.type === "http" && current.url === mcpUrl) {
|
|
303
|
+
console.log(`⏭️ Claude Code ~/.claude.json already up-to-date: ${mcpUrl}`);
|
|
304
304
|
return;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
config.mcpServers[serverName] = {
|
|
308
|
-
type: "
|
|
309
|
-
url:
|
|
308
|
+
type: "http",
|
|
309
|
+
url: mcpUrl,
|
|
310
310
|
};
|
|
311
311
|
|
|
312
312
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
313
|
-
console.log(`✓ Updated Claude Code ~/.claude.json: ${
|
|
313
|
+
console.log(`✓ Updated Claude Code ~/.claude.json: ${mcpUrl}`);
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
// ==================== 导出 ====================
|
package/scripts/lib/qoder.js
CHANGED
|
@@ -105,15 +105,15 @@ function addMcpViaCLI(deps, scope = "user") {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
const serverName = deps.getMcpServerName();
|
|
108
|
-
const
|
|
108
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
109
109
|
const scopeFlag = scope === "project" ? "-s project" : "-s user";
|
|
110
110
|
|
|
111
111
|
const result = deps.safeExecSync(
|
|
112
|
-
`qoder mcp add ${serverName} ${scopeFlag} -- ${
|
|
112
|
+
`qoder mcp add ${serverName} ${scopeFlag} -- ${mcpUrl}`,
|
|
113
113
|
);
|
|
114
114
|
|
|
115
115
|
if (result === true) {
|
|
116
|
-
console.log(`✓ Qoder CLI MCP server added (${scope}): ${serverName} (${
|
|
116
|
+
console.log(`✓ Qoder CLI MCP server added (${scope}): ${serverName} (${mcpUrl})`);
|
|
117
117
|
return true;
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -125,9 +125,9 @@ function addMcpViaCLI(deps, scope = "user") {
|
|
|
125
125
|
// 尝试先移除再添加
|
|
126
126
|
if (
|
|
127
127
|
deps.safeExecSync(`qoder mcp remove ${serverName} ${scopeFlag} 2>/dev/null`) &&
|
|
128
|
-
deps.safeExecSync(`qoder mcp add ${serverName} ${scopeFlag} -- ${
|
|
128
|
+
deps.safeExecSync(`qoder mcp add ${serverName} ${scopeFlag} -- ${mcpUrl}`)
|
|
129
129
|
) {
|
|
130
|
-
console.log(`✓ Qoder CLI MCP server updated (${scope}): ${serverName} (${
|
|
130
|
+
console.log(`✓ Qoder CLI MCP server updated (${scope}): ${serverName} (${mcpUrl})`);
|
|
131
131
|
return true;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -142,27 +142,27 @@ function addMcpViaCLI(deps, scope = "user") {
|
|
|
142
142
|
function syncQoderSettings(deps) {
|
|
143
143
|
const settingsPath = getQoderSettingsPath();
|
|
144
144
|
const serverName = deps.getMcpServerName();
|
|
145
|
-
const
|
|
145
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
146
146
|
|
|
147
147
|
let settings = readJsonFile(settingsPath);
|
|
148
148
|
|
|
149
149
|
if (!settings.mcpServers) settings.mcpServers = {};
|
|
150
150
|
|
|
151
151
|
const desiredConfig = {
|
|
152
|
-
type: "
|
|
153
|
-
url:
|
|
152
|
+
type: "http",
|
|
153
|
+
url: mcpUrl,
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
const current = settings.mcpServers[serverName];
|
|
157
|
-
if (current && current.type === "
|
|
158
|
-
console.log(`✓ Qoder ~/.qoder/settings.json already up-to-date: ${serverName} (${
|
|
157
|
+
if (current && current.type === "http" && current.url === mcpUrl) {
|
|
158
|
+
console.log(`✓ Qoder ~/.qoder/settings.json already up-to-date: ${serverName} (${mcpUrl})`);
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
settings.mcpServers[serverName] = desiredConfig;
|
|
163
163
|
|
|
164
164
|
writeJsonFile(settingsPath, settings);
|
|
165
|
-
console.log(`✓ Updated Qoder ~/.qoder/settings.json: ${serverName} (${
|
|
165
|
+
console.log(`✓ Updated Qoder ~/.qoder/settings.json: ${serverName} (${mcpUrl})`);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// ==================== Skill 复制 ====================
|
|
@@ -207,22 +207,33 @@ function copyAgentsToQoder(deps, isProjectLevel = false) {
|
|
|
207
207
|
qoderAgentsDir = getQoderAgentsDirectory();
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
// Qoder
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
);
|
|
210
|
+
// Qoder 优先选择 .qoder.md 文件,复制时去掉 .qoder 后缀
|
|
211
|
+
// 例如: szcd-component-expert.qoder.md → szcd-component-expert.md
|
|
212
|
+
const allFiles = fs.readdirSync(agentsSourceDir).filter((f) => f.endsWith(".md"));
|
|
213
|
+
const qoderFiles = allFiles.filter((f) => f.includes(".qoder."));
|
|
214
|
+
const fallbackFiles = allFiles.filter((f) => !f.includes(".trae.") && !f.includes(".qoder."));
|
|
215
|
+
|
|
216
|
+
// 优先 .qoder.md,无则回退不含 .trae. 的 .md
|
|
217
|
+
const selectedFiles = qoderFiles.length > 0 ? qoderFiles : fallbackFiles;
|
|
218
|
+
|
|
219
|
+
// 构建文件映射:去除 .qoder 后缀
|
|
220
|
+
const fileMap = new Map();
|
|
221
|
+
for (const f of selectedFiles) {
|
|
222
|
+
const destName = f.replace(".qoder.", ".");
|
|
223
|
+
fileMap.set(f, destName);
|
|
224
|
+
}
|
|
214
225
|
|
|
215
226
|
let copied = 0;
|
|
216
|
-
for (const
|
|
217
|
-
const sourcePath = path.join(agentsSourceDir,
|
|
218
|
-
const destPath = path.join(qoderAgentsDir,
|
|
227
|
+
for (const [srcFile, destFile] of fileMap) {
|
|
228
|
+
const sourcePath = path.join(agentsSourceDir, srcFile);
|
|
229
|
+
const destPath = path.join(qoderAgentsDir, destFile);
|
|
219
230
|
|
|
220
231
|
try {
|
|
221
232
|
deps.ensureDirectory(qoderAgentsDir);
|
|
222
233
|
deps.copyFile(sourcePath, destPath);
|
|
223
234
|
copied++;
|
|
224
235
|
} catch (error) {
|
|
225
|
-
console.log(`⚠️ Failed to copy agent ${
|
|
236
|
+
console.log(`⚠️ Failed to copy agent ${srcFile}: ${error.message}`);
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
239
|
|
|
@@ -328,7 +339,7 @@ function copyAgentsMdToQoder(deps, isProjectLevel = false) {
|
|
|
328
339
|
|
|
329
340
|
function setupQoderProjectConfig(deps) {
|
|
330
341
|
const serverName = deps.getMcpServerName();
|
|
331
|
-
const
|
|
342
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
332
343
|
|
|
333
344
|
// 优先 CLI
|
|
334
345
|
if (addMcpViaCLI(deps, "project")) {
|
|
@@ -348,12 +359,12 @@ function setupQoderProjectConfig(deps) {
|
|
|
348
359
|
if (!settings.mcpServers) settings.mcpServers = {};
|
|
349
360
|
|
|
350
361
|
settings.mcpServers[serverName] = {
|
|
351
|
-
type: "
|
|
352
|
-
url:
|
|
362
|
+
type: "http",
|
|
363
|
+
url: mcpUrl,
|
|
353
364
|
};
|
|
354
365
|
|
|
355
366
|
writeJsonFile(projectSettingsPath, settings);
|
|
356
|
-
console.log(`✓ Updated Qoder project .qoder/settings.json: ${serverName} (${
|
|
367
|
+
console.log(`✓ Updated Qoder project .qoder/settings.json: ${serverName} (${mcpUrl})`);
|
|
357
368
|
return true;
|
|
358
369
|
}
|
|
359
370
|
|
|
@@ -391,16 +402,16 @@ function safeExecSync(command) {
|
|
|
391
402
|
* @param {string} serverName - MCP 服务器名称
|
|
392
403
|
*/
|
|
393
404
|
export function syncMcpUrl(targetUrl, serverName) {
|
|
394
|
-
const
|
|
405
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
395
406
|
|
|
396
407
|
// 1. CLI 命令同步
|
|
397
408
|
if (isCommandAvailable("qoder")) {
|
|
398
409
|
safeExecSync(`qoder mcp remove ${serverName} -s user 2>/dev/null`);
|
|
399
410
|
const result = safeExecSync(
|
|
400
|
-
`qoder mcp add ${serverName} -s user -- ${
|
|
411
|
+
`qoder mcp add ${serverName} -s user -- ${mcpUrl}`,
|
|
401
412
|
);
|
|
402
413
|
if (result === true || result === "already_exists") {
|
|
403
|
-
console.log(`✓ Qoder CLI synced: ${serverName} (${
|
|
414
|
+
console.log(`✓ Qoder CLI synced: ${serverName} (${mcpUrl})`);
|
|
404
415
|
} else {
|
|
405
416
|
console.warn(`⚠️ Qoder CLI sync failed (settings.json will be updated directly)`);
|
|
406
417
|
}
|
|
@@ -417,25 +428,25 @@ export function syncMcpUrl(targetUrl, serverName) {
|
|
|
417
428
|
*/
|
|
418
429
|
function syncQoderSettingsDirect(targetUrl, serverName) {
|
|
419
430
|
const settingsPath = getQoderSettingsPath();
|
|
420
|
-
const
|
|
431
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
421
432
|
|
|
422
433
|
let settings = readJsonFile(settingsPath);
|
|
423
434
|
|
|
424
435
|
if (!settings.mcpServers) settings.mcpServers = {};
|
|
425
436
|
|
|
426
437
|
const current = settings.mcpServers[serverName];
|
|
427
|
-
if (current && current.type === "
|
|
428
|
-
console.log(`⏭️ Qoder ~/.qoder/settings.json already up-to-date: ${serverName} (${
|
|
438
|
+
if (current && current.type === "http" && current.url === mcpUrl) {
|
|
439
|
+
console.log(`⏭️ Qoder ~/.qoder/settings.json already up-to-date: ${serverName} (${mcpUrl})`);
|
|
429
440
|
return;
|
|
430
441
|
}
|
|
431
442
|
|
|
432
443
|
settings.mcpServers[serverName] = {
|
|
433
|
-
type: "
|
|
434
|
-
url:
|
|
444
|
+
type: "http",
|
|
445
|
+
url: mcpUrl,
|
|
435
446
|
};
|
|
436
447
|
|
|
437
448
|
writeJsonFile(settingsPath, settings);
|
|
438
|
-
console.log(`✓ Updated Qoder ~/.qoder/settings.json: ${serverName} (${
|
|
449
|
+
console.log(`✓ Updated Qoder ~/.qoder/settings.json: ${serverName} (${mcpUrl})`);
|
|
439
450
|
}
|
|
440
451
|
|
|
441
452
|
// ==================== 导出 ====================
|
package/scripts/lib/qwen-code.js
CHANGED
|
@@ -270,16 +270,16 @@ function safeExecSync(command) {
|
|
|
270
270
|
* @param {string} serverName - MCP 服务器名称
|
|
271
271
|
*/
|
|
272
272
|
export function syncMcpUrl(targetUrl, serverName) {
|
|
273
|
-
const
|
|
273
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
274
274
|
|
|
275
275
|
// 1. CLI 命令同步
|
|
276
276
|
if (isCommandAvailable("qwen")) {
|
|
277
277
|
safeExecSync(`qwen mcp remove --scope user ${serverName} 2>/dev/null`);
|
|
278
278
|
const result = safeExecSync(
|
|
279
|
-
`qwen mcp add --transport
|
|
279
|
+
`qwen mcp add --transport http --scope user ${serverName} ${mcpUrl}`,
|
|
280
280
|
);
|
|
281
281
|
if (result === true || result === "already_exists") {
|
|
282
|
-
console.log(`✓ Qwen Code CLI synced: ${
|
|
282
|
+
console.log(`✓ Qwen Code CLI synced: ${mcpUrl}`);
|
|
283
283
|
} else {
|
|
284
284
|
console.warn(`⚠️ Qwen Code CLI sync failed (settings.json will be updated directly)`);
|
|
285
285
|
}
|
|
@@ -312,15 +312,15 @@ function syncExtensionConfig(targetUrl, serverName) {
|
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
const
|
|
316
|
-
if (manifest.mcpServers[serverName].url ===
|
|
317
|
-
console.log(`⏭️ Extension qwen-extension.json already up-to-date: ${
|
|
315
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
316
|
+
if (manifest.mcpServers[serverName].url === mcpUrl) {
|
|
317
|
+
console.log(`⏭️ Extension qwen-extension.json already up-to-date: ${mcpUrl}`);
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
manifest.mcpServers[serverName].url =
|
|
321
|
+
manifest.mcpServers[serverName].url = mcpUrl;
|
|
322
322
|
writeJsonFile(manifestPath, manifest);
|
|
323
|
-
console.log(`✓ Updated extension qwen-extension.json: ${
|
|
323
|
+
console.log(`✓ Updated extension qwen-extension.json: ${mcpUrl}`);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
/**
|
|
@@ -328,7 +328,7 @@ function syncExtensionConfig(targetUrl, serverName) {
|
|
|
328
328
|
*/
|
|
329
329
|
function syncQwenCodeSettingsDirect(targetUrl, serverName) {
|
|
330
330
|
const settingsPath = getQwenCodeSettingsPath();
|
|
331
|
-
const
|
|
331
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
332
332
|
|
|
333
333
|
let settings = {};
|
|
334
334
|
if (fs.existsSync(settingsPath)) {
|
|
@@ -340,21 +340,21 @@ function syncQwenCodeSettingsDirect(targetUrl, serverName) {
|
|
|
340
340
|
if (!settings.mcpServers) settings.mcpServers = {};
|
|
341
341
|
|
|
342
342
|
const current = settings.mcpServers[serverName];
|
|
343
|
-
if (current && current.type === "
|
|
344
|
-
console.log(`⏭️ Qwen Code ~/.qwen/settings.json already up-to-date: ${
|
|
343
|
+
if (current && current.type === "http" && current.url === mcpUrl) {
|
|
344
|
+
console.log(`⏭️ Qwen Code ~/.qwen/settings.json already up-to-date: ${mcpUrl}`);
|
|
345
345
|
return;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
settings.mcpServers[serverName] = {
|
|
349
|
-
type: "
|
|
350
|
-
url:
|
|
349
|
+
type: "http",
|
|
350
|
+
url: mcpUrl,
|
|
351
351
|
timeout: 30000,
|
|
352
352
|
};
|
|
353
353
|
|
|
354
354
|
const dir = path.dirname(settingsPath);
|
|
355
355
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
356
356
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
|
|
357
|
-
console.log(`✓ Updated Qwen Code ~/.qwen/settings.json: ${
|
|
357
|
+
console.log(`✓ Updated Qwen Code ~/.qwen/settings.json: ${mcpUrl}`);
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// ==================== 导出 ====================
|
package/scripts/lib/trae-cli.js
CHANGED
|
@@ -77,13 +77,13 @@ function parseYamlMcpServers(content) {
|
|
|
77
77
|
|
|
78
78
|
export function syncTraeCliYaml(deps) {
|
|
79
79
|
const yamlPath = getTraeCliYamlPath();
|
|
80
|
-
const
|
|
80
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
81
81
|
const serverName = deps.getMcpServerName();
|
|
82
82
|
|
|
83
83
|
if (!fs.existsSync(yamlPath)) {
|
|
84
84
|
const dir = path.dirname(yamlPath);
|
|
85
85
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
86
|
-
const content = `mcp_servers:\n - name: ${serverName}\n url: ${
|
|
86
|
+
const content = `mcp_servers:\n - name: ${serverName}\n url: ${mcpUrl}\n type: http\n`;
|
|
87
87
|
fs.writeFileSync(yamlPath, content);
|
|
88
88
|
console.log(`✓ Created Trae CLI YAML: ${yamlPath}`);
|
|
89
89
|
return;
|
|
@@ -93,21 +93,21 @@ export function syncTraeCliYaml(deps) {
|
|
|
93
93
|
const { servers } = parseYamlMcpServers(content);
|
|
94
94
|
|
|
95
95
|
const existing = servers.find(s => s.name === serverName);
|
|
96
|
-
if (existing && existing.url ===
|
|
97
|
-
console.log(`✓ Trae CLI YAML already up-to-date: ${
|
|
96
|
+
if (existing && existing.url === mcpUrl) {
|
|
97
|
+
console.log(`✓ Trae CLI YAML already up-to-date: ${mcpUrl}`);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
if (existing) {
|
|
102
102
|
const newRaw = existing.raw.map(l =>
|
|
103
|
-
l.replace(/^(\s+url\s*:\s*).*/, `$1${
|
|
103
|
+
l.replace(/^(\s+url\s*:\s*).*/, `$1${mcpUrl}`)
|
|
104
104
|
);
|
|
105
105
|
const oldBlock = existing.raw.join("\n");
|
|
106
106
|
const newBlock = newRaw.join("\n");
|
|
107
107
|
content = content.replace(oldBlock, newBlock);
|
|
108
|
-
console.log(`✓ Updated Trae CLI YAML: ${existing.url} → ${
|
|
108
|
+
console.log(`✓ Updated Trae CLI YAML: ${existing.url} → ${mcpUrl}`);
|
|
109
109
|
} else {
|
|
110
|
-
const entry = ` - name: ${serverName}\n url: ${
|
|
110
|
+
const entry = ` - name: ${serverName}\n url: ${mcpUrl}\n type: http\n`;
|
|
111
111
|
if (/^mcp_servers\s*:\s*\[\]\s*$/m.test(content)) {
|
|
112
112
|
content = content.replace(/^mcp_servers\s*:\s*\[\]\s*$/m, `mcp_servers:\n${entry}`);
|
|
113
113
|
} else if (/^mcp_servers\s*:\s*$/m.test(content)) {
|
|
@@ -117,7 +117,7 @@ export function syncTraeCliYaml(deps) {
|
|
|
117
117
|
} else {
|
|
118
118
|
content = content.trimEnd() + `\n\nmcp_servers:\n${entry}`;
|
|
119
119
|
}
|
|
120
|
-
console.log(`✓ Added to Trae CLI YAML: ${
|
|
120
|
+
console.log(`✓ Added to Trae CLI YAML: ${mcpUrl}`);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
fs.writeFileSync(yamlPath, content);
|
|
@@ -127,13 +127,13 @@ export function syncTraeCliYaml(deps) {
|
|
|
127
127
|
|
|
128
128
|
export function createTraeCliConfig(deps) {
|
|
129
129
|
if (deps.isCommandAvailable("trae-cli")) {
|
|
130
|
-
const
|
|
130
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
131
131
|
const serverName = deps.getMcpServerName();
|
|
132
|
-
const jsonConfig = `{"type":"
|
|
132
|
+
const jsonConfig = `{"type":"http","url":"${mcpUrl}"}`;
|
|
133
133
|
deps.safeExecSync(`trae-cli mcp remove ${serverName} 2>/dev/null`);
|
|
134
134
|
const result = deps.safeExecSync(`trae-cli mcp add-json ${serverName} '${jsonConfig}'`);
|
|
135
135
|
if (result === true || result === "already_exists") {
|
|
136
|
-
console.log(`✓ Trae CLI command synced: ${
|
|
136
|
+
console.log(`✓ Trae CLI command synced: ${mcpUrl}`);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
syncTraeCliYaml(deps);
|
|
@@ -200,15 +200,15 @@ export function installTraeCliSlashCommand(deps) {
|
|
|
200
200
|
* @param {string} serverName - MCP 服务器名称
|
|
201
201
|
*/
|
|
202
202
|
export function syncMcpUrl(targetUrl, serverName) {
|
|
203
|
-
const
|
|
203
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
204
204
|
|
|
205
205
|
// 1. CLI 命令同步
|
|
206
206
|
if (isCommandAvailable("trae-cli")) {
|
|
207
|
-
const jsonConfig = `{"type":"
|
|
207
|
+
const jsonConfig = `{"type":"http","url":"${mcpUrl}"}`;
|
|
208
208
|
safeExecSync(`trae-cli mcp remove ${serverName} 2>/dev/null`);
|
|
209
209
|
const result = safeExecSync(`trae-cli mcp add-json ${serverName} '${jsonConfig}'`);
|
|
210
210
|
if (result === true || result === "already_exists") {
|
|
211
|
-
console.log(`✓ Trae CLI command synced: ${
|
|
211
|
+
console.log(`✓ Trae CLI command synced: ${mcpUrl}`);
|
|
212
212
|
} else {
|
|
213
213
|
console.warn(`⚠️ trae-cli command sync failed (YAML file will be updated directly)`);
|
|
214
214
|
}
|
|
@@ -251,12 +251,12 @@ function safeExecSync(command) {
|
|
|
251
251
|
*/
|
|
252
252
|
function syncTraeCliYamlDirect(targetUrl, serverName) {
|
|
253
253
|
const yamlPath = getTraeCliYamlPath();
|
|
254
|
-
const
|
|
254
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
255
255
|
|
|
256
256
|
if (!fs.existsSync(yamlPath)) {
|
|
257
257
|
const dir = path.dirname(yamlPath);
|
|
258
258
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
259
|
-
const content = `mcp_servers:\n - name: ${serverName}\n url: ${
|
|
259
|
+
const content = `mcp_servers:\n - name: ${serverName}\n url: ${mcpUrl}\n type: http\n`;
|
|
260
260
|
fs.writeFileSync(yamlPath, content);
|
|
261
261
|
console.log(`✓ Created Trae CLI YAML: ${yamlPath}`);
|
|
262
262
|
return;
|
|
@@ -266,21 +266,21 @@ function syncTraeCliYamlDirect(targetUrl, serverName) {
|
|
|
266
266
|
const { servers } = parseYamlMcpServers(content);
|
|
267
267
|
|
|
268
268
|
const existing = servers.find(s => s.name === serverName);
|
|
269
|
-
if (existing && existing.url ===
|
|
270
|
-
console.log(`⏭️ Trae CLI YAML already up-to-date: ${
|
|
269
|
+
if (existing && existing.url === mcpUrl) {
|
|
270
|
+
console.log(`⏭️ Trae CLI YAML already up-to-date: ${mcpUrl}`);
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
if (existing) {
|
|
275
275
|
const newRaw = existing.raw.map(l =>
|
|
276
|
-
l.replace(/^(\s+url\s*:\s*).*/, `$1${
|
|
276
|
+
l.replace(/^(\s+url\s*:\s*).*/, `$1${mcpUrl}`)
|
|
277
277
|
);
|
|
278
278
|
const oldBlock = existing.raw.join("\n");
|
|
279
279
|
const newBlock = newRaw.join("\n");
|
|
280
280
|
content = content.replace(oldBlock, newBlock);
|
|
281
|
-
console.log(`✓ Updated Trae CLI YAML: ${existing.url} → ${
|
|
281
|
+
console.log(`✓ Updated Trae CLI YAML: ${existing.url} → ${mcpUrl}`);
|
|
282
282
|
} else {
|
|
283
|
-
const entry = ` - name: ${serverName}\n url: ${
|
|
283
|
+
const entry = ` - name: ${serverName}\n url: ${mcpUrl}\n type: http\n`;
|
|
284
284
|
if (/^mcp_servers\s*:\s*\[\]\s*$/m.test(content)) {
|
|
285
285
|
content = content.replace(/^mcp_servers\s*:\s*\[\]\s*$/m, `mcp_servers:\n${entry}`);
|
|
286
286
|
} else if (/^mcp_servers\s*:\s*$/m.test(content)) {
|
|
@@ -290,7 +290,7 @@ function syncTraeCliYamlDirect(targetUrl, serverName) {
|
|
|
290
290
|
} else {
|
|
291
291
|
content = content.trimEnd() + `\n\nmcp_servers:\n${entry}`;
|
|
292
292
|
}
|
|
293
|
-
console.log(`✓ Added to Trae CLI YAML: ${
|
|
293
|
+
console.log(`✓ Added to Trae CLI YAML: ${mcpUrl}`);
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
fs.writeFileSync(yamlPath, content);
|
package/scripts/lib/trae-ide.js
CHANGED
|
@@ -60,7 +60,7 @@ function getTraeProjectDirectory(deps) {
|
|
|
60
60
|
|
|
61
61
|
export function syncTraeCnMcpJson(deps) {
|
|
62
62
|
const mcpJsonPath = getTraeIdeMcpJsonPath();
|
|
63
|
-
const
|
|
63
|
+
const mcpUrl = `${deps.getMcpServerUrl()}/mcp`;
|
|
64
64
|
const serverName = deps.getMcpServerName();
|
|
65
65
|
|
|
66
66
|
let config = {};
|
|
@@ -73,20 +73,20 @@ export function syncTraeCnMcpJson(deps) {
|
|
|
73
73
|
if (!config.mcpServers) config.mcpServers = {};
|
|
74
74
|
|
|
75
75
|
const current = config.mcpServers[serverName];
|
|
76
|
-
if (current && current.url ===
|
|
77
|
-
console.log(`✓ Trae CN mcp.json already up-to-date: ${
|
|
76
|
+
if (current && current.url === mcpUrl && current.type === "http") {
|
|
77
|
+
console.log(`✓ Trae CN mcp.json already up-to-date: ${mcpUrl}`);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
config.mcpServers[serverName] = {
|
|
82
|
-
type: "
|
|
83
|
-
url:
|
|
82
|
+
type: "http",
|
|
83
|
+
url: mcpUrl,
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
const dir = path.dirname(mcpJsonPath);
|
|
87
87
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
88
88
|
fs.writeFileSync(mcpJsonPath, JSON.stringify(config, null, 2));
|
|
89
|
-
console.log(`✓ Updated Trae CN mcp.json: ${
|
|
89
|
+
console.log(`✓ Updated Trae CN mcp.json: ${mcpUrl}`);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
export function createTraeIdeConfig(deps) {
|
|
@@ -102,7 +102,7 @@ export function createTraeIdeConfig(deps) {
|
|
|
102
102
|
*/
|
|
103
103
|
export function syncMcpUrl(targetUrl, serverName) {
|
|
104
104
|
const mcpJsonPath = getTraeIdeMcpJsonPath();
|
|
105
|
-
const
|
|
105
|
+
const mcpUrl = `${targetUrl}/mcp`;
|
|
106
106
|
|
|
107
107
|
let config = {};
|
|
108
108
|
if (fs.existsSync(mcpJsonPath)) {
|
|
@@ -114,20 +114,20 @@ export function syncMcpUrl(targetUrl, serverName) {
|
|
|
114
114
|
if (!config.mcpServers) config.mcpServers = {};
|
|
115
115
|
|
|
116
116
|
const current = config.mcpServers[serverName];
|
|
117
|
-
if (current && current.url ===
|
|
118
|
-
console.log(`⏭️ Trae CN mcp.json already up-to-date: ${
|
|
117
|
+
if (current && current.url === mcpUrl && current.type === "http") {
|
|
118
|
+
console.log(`⏭️ Trae CN mcp.json already up-to-date: ${mcpUrl}`);
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
config.mcpServers[serverName] = {
|
|
123
|
-
type: "
|
|
124
|
-
url:
|
|
123
|
+
type: "http",
|
|
124
|
+
url: mcpUrl,
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
const dir = path.dirname(mcpJsonPath);
|
|
128
128
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
129
129
|
fs.writeFileSync(mcpJsonPath, JSON.stringify(config, null, 2));
|
|
130
|
-
console.log(`✓ Updated Trae CN mcp.json: ${
|
|
130
|
+
console.log(`✓ Updated Trae CN mcp.json: ${mcpUrl}`);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// ==================== Skill 复制 ====================
|
package/scripts/postinstall.js
CHANGED
|
@@ -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
|
|
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":"
|
|
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
|
|
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()}/
|
|
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)");
|