@szc-ft/mcp-szcd-client 0.11.1 → 0.11.2

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.
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: 管理CODING Issue工具的默认配置(baseUrl/projectId/account)
3
+ argument-hint: <get|set|clear> [--baseUrl=xxx] [--projectId=yyy] [--account=zzz]
4
+ ---
5
+
6
+ 请帮我管理 szcd MCP 的 CODING 默认配置。
7
+
8
+ **交互流程**:
9
+
10
+ 1. **向用户询问要执行的操作**,提供以下选项:
11
+ - "查看配置" → 执行 get
12
+ - "设置配置" → 执行 set(需进一步追问参数)
13
+ - "清除配置" → 执行 clear
14
+
15
+ 2. **根据用户选择执行**:
16
+
17
+ - **查看配置**:直接执行 `npx szcd-mcp-coding-config get`
18
+
19
+ - **设置配置**:逐项向用户询问以下参数,选项中提供当前值作为默认,用户也可自由输入新值:
20
+ - CODING_BASE_URL — CODING 基础地址,如 `http://e-kjr1wok.coding.smartcitysz.work`
21
+ - CODING_DEFAULT_PROJECT_ID — 默认项目 ID,如 `907`
22
+ - CODING_ACCOUNT — 默认账号(邮箱)
23
+ 收集完参数后执行:
24
+ ```bash
25
+ npx szcd-mcp-coding-config set --baseUrl="<baseUrl>" --projectId="<projectId>" --account="<account>"
26
+ ```
27
+
28
+ - **清除配置**:确认后执行 `npx szcd-mcp-coding-config clear`
29
+
30
+ 3. **命令回退**:如果 npx 不可用,依次尝试:
31
+ - `node $(npm root -g)/@szc-ft/mcp-szcd-client/scripts/update-coding-config.js <args>`
32
+ - `node /scity/zengzhijie/szcd/mcp/szcd-mcp-client/scripts/update-coding-config.js <args>`
33
+
34
+ **配置字段说明**:
35
+ - `CODING_BASE_URL` — CODING 基础地址
36
+ - `CODING_DEFAULT_PROJECT_ID` — 默认项目 ID
37
+ - `CODING_ACCOUNT` — 默认账号(邮箱)
38
+
39
+ 配置保存在 `~/.szcd-mcp-config.json` 中,设置后 `coding_fetch_issue` 工具可省略 `baseUrl` 和 `projectId` 参数。
40
+
41
+ 当前配置:
42
+ !`cat ~/.szcd-mcp-config.json 2>/dev/null | grep -E "CODING|MCP_SERVER" || echo "配置文件不存在或无 CODING 配置"`
@@ -5,21 +5,33 @@ argument-hint: <new-mcp-server-url>
5
5
 
6
6
  请帮我更新 szcd MCP 服务器地址。
7
7
 
8
- **使用方式**:
9
- - 输入 URL 参数(如 `$1`):用该 URL 更新配置文件并同步 IDE
10
- - 不输入 URL:用配置文件 `~/.szcd-mcp-config.json` 中已有的 MCP_SERVER_URL 同步 IDE 配置
8
+ **交互流程**:
11
9
 
12
- 执行以下命令:
10
+ 1. **向用户询问要执行的操作**,提供以下选项:
11
+ - "更新服务器地址" → 输入新 URL 并同步所有 IDE 配置
12
+ - "同步现有配置" → 用 `~/.szcd-mcp-config.json` 中已有的 MCP_SERVER_URL 重新同步 IDE 配置
13
+ - "查看当前配置" → 显示当前 MCP 服务器地址
13
14
 
14
- 1. 运行更新脚本:
15
- - 优先: `npx szcd-mcp-update-url "$1"`
16
- - 若 npx 不可用: `node $(npm root -g)/@szc-ft/mcp-szcd-component-helper/scripts/update-mcp-url.js "$1"`
17
- - 若全局安装也不可用: `node /scity/zengzhijie/szcd/mcp/szcd-component-helper/scripts/update-mcp-url.js "$1"`
15
+ 2. **根据用户选择执行**:
18
16
 
19
- 2. 如果脚本执行失败,请手动执行以下步骤:
20
- a. 编辑 `~/.szcd-mcp-config.json`,将 MCP_SERVER_URL 改为目标 URL
21
- b. 如果 trae-cli 可用:`trae-cli mcp remove szcd-component-helper && trae-cli mcp add-json szcd-component-helper '{"type":"sse","url":"<目标URL>/sse"}'`
22
- c. 如果 claude 可用:`claude mcp remove --scope user szcd-component-helper && claude mcp add --transport sse --scope user szcd-component-helper <目标URL>/sse`
17
+ - **更新服务器地址**:向用户询问新的 MCP 服务器 URL,可提供常用地址选项,用户也可自由输入。收集到 URL 后执行:
18
+ ```bash
19
+ npx szcd-mcp-update-url "<newUrl>"
20
+ ```
21
+
22
+ - **同步现有配置**:直接执行(不带参数):
23
+ ```bash
24
+ npx szcd-mcp-update-url
25
+ ```
26
+
27
+ - **查看当前配置**:显示 `~/.szcd-mcp-config.json` 中的 MCP_SERVER_URL
28
+
29
+ 3. **命令回退**:如果 npx 不可用,依次尝试:
30
+ - `node $(npm root -g)/@szc-ft/mcp-szcd-client/scripts/update-mcp-url.js "<newUrl>"`
31
+ - `node /scity/zengzhijie/szcd/mcp/szcd-mcp-client/scripts/update-mcp-url.js "<newUrl>"`
32
+ - 手动步骤:编辑 `~/.szcd-mcp-config.json`,再逐个 IDE 同步:
33
+ - trae-cli: `trae-cli mcp remove szcd-component-helper && trae-cli mcp add-json szcd-component-helper '{"type":"sse","url":"<URL>/sse"}'`
34
+ - claude: `claude mcp remove --scope user szcd-component-helper && claude mcp add --transport sse --scope user szcd-component-helper <URL>/sse`
23
35
 
24
36
  当前配置:
25
37
  !`cat ~/.szcd-mcp-config.json 2>/dev/null || echo "配置文件不存在"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@szc-ft/mcp-szcd-client",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "MCP client for szcd component library - connects to remote MCP server via SSE or stdio proxy",
5
5
  "keywords": [
6
6
  "mcp",
@@ -21,12 +21,14 @@
21
21
  "bin": {
22
22
  "szcd-mcp-proxy": "mcp-proxy.js",
23
23
  "szcd-mcp-setup": "scripts/postinstall.js",
24
- "szcd-mcp-update-url": "scripts/update-mcp-url.js"
24
+ "szcd-mcp-update-url": "scripts/update-mcp-url.js",
25
+ "szcd-mcp-coding-config": "scripts/update-coding-config.js"
25
26
  },
26
27
  "files": [
27
28
  "mcp-proxy.js",
28
29
  "scripts/postinstall.js",
29
30
  "scripts/update-mcp-url.js",
31
+ "scripts/update-coding-config.js",
30
32
  "scripts/lib/",
31
33
  "standard-skill/",
32
34
  "skill/",
@@ -0,0 +1,246 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * szcd-mcp-coding-config - 管理 CODING Issue 获取工具的默认配置
5
+ *
6
+ * 用法:
7
+ * npx szcd-mcp-coding-config get 查看当前 CODING 配置
8
+ * npx szcd-mcp-coding-config set --baseUrl=xxx 设置 CODING 基础地址
9
+ * npx szcd-mcp-coding-config set --projectId=xxx 设置默认项目 ID
10
+ * npx szcd-mcp-coding-config set --account=xxx 设置默认账号
11
+ * npx szcd-mcp-coding-config set --cookies=xxx 设置浏览器 Cookie
12
+ * npx szcd-mcp-coding-config set --password=xxx 设置密码
13
+ * npx szcd-mcp-coding-config set --baseUrl=xxx --projectId=yyy --cookies=zzz 批量设置
14
+ * npx szcd-mcp-coding-config clear 清除所有 CODING 配置
15
+ *
16
+ * 配置保存在 ~/.szcd-mcp-config.json 中,字段名:
17
+ * CODING_BASE_URL — CODING 基础地址
18
+ * CODING_DEFAULT_PROJECT_ID — 默认项目 ID
19
+ * CODING_ACCOUNT — 默认账号(邮箱)
20
+ * CODING_COOKIES — 浏览器 Cookie 字符串(敏感)
21
+ * CODING_PASSWORD — 密码(敏感)
22
+ */
23
+
24
+ import fs from "node:fs";
25
+ import path from "node:path";
26
+ import os from "node:os";
27
+
28
+ // ==================== 工具函数 ====================
29
+
30
+ function getHomeDir() {
31
+ if (os.platform() === "win32") {
32
+ return process.env.USERPROFILE || process.env.HOME || os.homedir();
33
+ }
34
+ return process.env.HOME || os.homedir();
35
+ }
36
+
37
+ function getConfigFilePath() {
38
+ return path.join(getHomeDir(), ".szcd-mcp-config.json");
39
+ }
40
+
41
+ function loadConfig() {
42
+ const configPath = getConfigFilePath();
43
+ try {
44
+ if (fs.existsSync(configPath)) {
45
+ return JSON.parse(fs.readFileSync(configPath, "utf8"));
46
+ }
47
+ } catch (error) {
48
+ console.error(`❌ Failed to read config: ${error.message}`);
49
+ }
50
+ return {};
51
+ }
52
+
53
+ function saveConfig(config) {
54
+ const configPath = getConfigFilePath();
55
+ try {
56
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
57
+ return true;
58
+ } catch (error) {
59
+ console.error(`❌ Failed to write config: ${error.message}`);
60
+ return false;
61
+ }
62
+ }
63
+
64
+ function maskValue(value) {
65
+ if (!value) return "(未设置)";
66
+ if (value.length <= 6) return "***";
67
+ return value.substring(0, 4) + "***";
68
+ }
69
+
70
+ function parseArgs(argv) {
71
+ const args = { action: null, baseUrl: null, projectId: null, account: null, cookies: null, password: null };
72
+ const positional = [];
73
+
74
+ for (let i = 2; i < argv.length; i++) {
75
+ const arg = argv[i];
76
+ if (arg.startsWith("--")) {
77
+ const eqIdx = arg.indexOf("=");
78
+ if (eqIdx !== -1) {
79
+ const key = arg.slice(2, eqIdx);
80
+ const value = arg.slice(eqIdx + 1);
81
+ if (key === "baseUrl" || key === "base-url") args.baseUrl = value;
82
+ if (key === "projectId" || key === "project-id") args.projectId = value;
83
+ if (key === "account") args.account = value;
84
+ if (key === "cookies") args.cookies = value;
85
+ if (key === "password") args.password = value;
86
+ }
87
+ } else {
88
+ positional.push(arg);
89
+ }
90
+ }
91
+
92
+ args.action = positional[0] || "get";
93
+ return args;
94
+ }
95
+
96
+ // ==================== 命令实现 ====================
97
+
98
+ function cmdGet() {
99
+ const config = loadConfig();
100
+
101
+ console.log(`\n📋 CODING 配置 (${getConfigFilePath()})\n`);
102
+ console.log(` CODING_BASE_URL : ${config.CODING_BASE_URL || "(未设置)"}`);
103
+ console.log(` CODING_DEFAULT_PROJECT_ID : ${config.CODING_DEFAULT_PROJECT_ID || "(未设置)"}`);
104
+ console.log(` CODING_ACCOUNT : ${config.CODING_ACCOUNT || "(未设置)"}`);
105
+ console.log(` CODING_COOKIES : ${maskValue(config.CODING_COOKIES)}`);
106
+ console.log(` CODING_PASSWORD : ${maskValue(config.CODING_PASSWORD)}`);
107
+ console.log(`\n💡 配置后,coding_fetch_issue 工具可省略所有参数直接获取 Issue。`);
108
+ console.log(` 用法: npx szcd-mcp-coding-config set --baseUrl=xxx --projectId=yyy --cookies=xxx\n`);
109
+ }
110
+
111
+ function cmdSet(baseUrl, projectId, account, cookies, password) {
112
+ const config = loadConfig();
113
+ let changed = false;
114
+
115
+ if (baseUrl) {
116
+ const old = config.CODING_BASE_URL || "(未设置)";
117
+ config.CODING_BASE_URL = baseUrl;
118
+ console.log(` CODING_BASE_URL : ${old} → ${baseUrl}`);
119
+ changed = true;
120
+ }
121
+ if (projectId) {
122
+ const old = config.CODING_DEFAULT_PROJECT_ID || "(未设置)";
123
+ config.CODING_DEFAULT_PROJECT_ID = projectId;
124
+ console.log(` CODING_DEFAULT_PROJECT_ID : ${old} → ${projectId}`);
125
+ changed = true;
126
+ }
127
+ if (account) {
128
+ const old = config.CODING_ACCOUNT || "(未设置)";
129
+ config.CODING_ACCOUNT = account;
130
+ console.log(` CODING_ACCOUNT : ${old} → ${account}`);
131
+ changed = true;
132
+ }
133
+ if (cookies) {
134
+ const old = maskValue(config.CODING_COOKIES);
135
+ config.CODING_COOKIES = cookies;
136
+ console.log(` CODING_COOKIES : ${old} → ${maskValue(cookies)}`);
137
+ changed = true;
138
+ }
139
+ if (password) {
140
+ const old = maskValue(config.CODING_PASSWORD);
141
+ config.CODING_PASSWORD = password;
142
+ console.log(` CODING_PASSWORD : ${old} → ${maskValue(password)}`);
143
+ changed = true;
144
+ }
145
+
146
+ if (!changed) {
147
+ console.log("\n⚠️ 未提供任何要设置的参数。用法:");
148
+ console.log(" npx szcd-mcp-coding-config set --baseUrl=xxx --projectId=yyy --account=zzz --cookies=xxx --password=yyy\n");
149
+ return false;
150
+ }
151
+
152
+ if (saveConfig(config)) {
153
+ console.log(`\n✅ 配置已保存。`);
154
+ console.log(` CODING_BASE_URL : ${config.CODING_BASE_URL || "(未设置)"}`);
155
+ console.log(` CODING_DEFAULT_PROJECT_ID : ${config.CODING_DEFAULT_PROJECT_ID || "(未设置)"}`);
156
+ console.log(` CODING_ACCOUNT : ${config.CODING_ACCOUNT || "(未设置)"}`);
157
+ console.log(` CODING_COOKIES : ${maskValue(config.CODING_COOKIES)}`);
158
+ console.log(` CODING_PASSWORD : ${maskValue(config.CODING_PASSWORD)}\n`);
159
+ return true;
160
+ }
161
+ console.log("\n❌ 保存配置失败。\n");
162
+ return false;
163
+ }
164
+
165
+ function cmdClear() {
166
+ const config = loadConfig();
167
+ const hadBaseUrl = !!config.CODING_BASE_URL;
168
+ const hadProjectId = !!config.CODING_DEFAULT_PROJECT_ID;
169
+ const hadAccount = !!config.CODING_ACCOUNT;
170
+ const hadCookies = !!config.CODING_COOKIES;
171
+ const hadPassword = !!config.CODING_PASSWORD;
172
+
173
+ if (!hadBaseUrl && !hadProjectId && !hadAccount && !hadCookies && !hadPassword) {
174
+ console.log("\n⏭️ 没有 CODING 配置需要清除。\n");
175
+ return false;
176
+ }
177
+
178
+ delete config.CODING_BASE_URL;
179
+ delete config.CODING_DEFAULT_PROJECT_ID;
180
+ delete config.CODING_ACCOUNT;
181
+ delete config.CODING_COOKIES;
182
+ delete config.CODING_PASSWORD;
183
+
184
+ if (saveConfig(config)) {
185
+ console.log("\n✅ 已清除 CODING 配置。\n");
186
+ return true;
187
+ }
188
+ console.log("\n❌ 清除配置失败。\n");
189
+ return false;
190
+ }
191
+
192
+ // ==================== 帮助信息 ====================
193
+
194
+ function printHelp() {
195
+ console.log(`
196
+ Usage: npx szcd-mcp-coding-config <command> [options]
197
+
198
+ Commands:
199
+ get 查看当前 CODING 配置
200
+ set [options] 设置 CODING 配置项
201
+ clear 清除所有 CODING 配置
202
+
203
+ Options for 'set':
204
+ --baseUrl=<url> CODING 基础地址,如 http://e-kjr1wok.coding.smartcitysz.work
205
+ --projectId=<id> 默认项目 ID,如 907
206
+ --account=<email> 默认账号(邮箱)
207
+ --cookies=<string> 浏览器 Cookie 字符串(敏感)
208
+ --password=<string> CODING 密码(敏感)
209
+
210
+ Examples:
211
+ npx szcd-mcp-coding-config get
212
+ npx szcd-mcp-coding-config set --baseUrl=http://e-kjr1wok.coding.smartcitysz.work --projectId=907
213
+ npx szcd-mcp-coding-config set --cookies="enterprise_domain=xxx; cf=xxx; XSRF-TOKEN=xxx"
214
+ npx szcd-mcp-coding-config set --baseUrl=xxx --projectId=yyy --cookies=zzz --password=www
215
+ npx szcd-mcp-coding-config clear
216
+
217
+ Config file: ~/.szcd-mcp-config.json
218
+ `);
219
+ }
220
+
221
+ // ==================== 主函数 ====================
222
+
223
+ function main() {
224
+ const args = parseArgs(process.argv);
225
+
226
+ if (args.action === "help" || args.action === "-h" || args.action === "--help") {
227
+ printHelp();
228
+ process.exit(0);
229
+ }
230
+
231
+ if (args.action === "get") {
232
+ cmdGet();
233
+ } else if (args.action === "set") {
234
+ const ok = cmdSet(args.baseUrl, args.projectId, args.account, args.cookies, args.password);
235
+ process.exit(ok ? 0 : 1);
236
+ } else if (args.action === "clear") {
237
+ const ok = cmdClear();
238
+ process.exit(ok ? 0 : 1);
239
+ } else {
240
+ console.error(`❌ Unknown command: ${args.action}`);
241
+ printHelp();
242
+ process.exit(1);
243
+ }
244
+ }
245
+
246
+ main();