dsh-mcp-connector 0.2.95 → 0.2.96
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/CHANGELOG.md +7 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/docs/screenshots/01-market-overview.jpg +0 -0
- package/docs/screenshots/02-connector-detail.jpg +0 -0
- package/docs/screenshots/03-tool-discovery.jpg +0 -0
- package/docs/screenshots/04-json-import.jpg +0 -0
- package/docs/screenshots/05-unified-tool-search.png +0 -0
- package/docs/screenshots/06-tool-parameters.png +0 -0
- package/docs/screenshots/07-connection-diagnostics.png +0 -0
- package/docs/screenshots/08-ten-recommendations.jpg +0 -0
- package/docs/screenshots/README.md +1 -1
- package/docs/screenshots/assets.json +29 -29
- package/docs/screenshots/en/01-market-overview.jpg +0 -0
- package/docs/screenshots/en/02-connector-detail.jpg +0 -0
- package/docs/screenshots/en/03-tool-discovery.jpg +0 -0
- package/docs/screenshots/en/04-json-import.jpg +0 -0
- package/docs/screenshots/en/05-unified-tool-search.png +0 -0
- package/docs/screenshots/en/06-tool-parameters.png +0 -0
- package/docs/screenshots/en/07-connection-diagnostics.png +0 -0
- package/docs/screenshots/en/08-ten-recommendations.jpg +0 -0
- package/docs/screenshots/en/assets.json +29 -29
- package/docs/screenshots/en/demo.gif +0 -0
- package/docs/tutorials/FIRST-SUCCESS-SCENARIOS.md +1 -1
- package/lib/catalog.js +5 -2
- package/lib/index.js +68 -34
- package/lib/mcp-validation.js +37 -2
- package/lib/tools.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.96
|
|
4
|
+
|
|
5
|
+
- Honor catalog TTL on startup; use audited stale cache immediately and refresh in the background, renew freshness on HTTP 304, and cancel superseded/disposed refreshes (#219). First installation without a valid cache still uses the existing foreground fetch path.
|
|
6
|
+
- Expose exact connection keys and Workspace scope to the health-check tool; reject mismatched identifiers and prevent scoped checks from overwriting connector-wide health (#218).
|
|
7
|
+
- Finish initialize validation when the matching SSE response arrives instead of waiting for a persistent stream to close. Handle fragmented/multiline events, ignore unrelated responses, and preserve authentication failures (#218).
|
|
8
|
+
- Local synthetic regression reproduces the persistent-SSE timeout and verifies the fix. This does not establish the original reporter's root cause or replace Windows Desktop / business-call acceptance; #218 and #219 remain open pending review and reporter verification.
|
|
9
|
+
|
|
3
10
|
## 0.2.95
|
|
4
11
|
|
|
5
12
|
- Add a standalone Settings → MCP Connector page with the existing sidebar visibility switch and open-panel action, including hosts without a Plugins settings page (#216).
|
package/README.en.md
CHANGED
|
@@ -114,7 +114,7 @@ As of 2026-10-24, the public Registry publishes 112 connector descriptors. After
|
|
|
114
114
|
| Connection diagnostics and last-success cache | |
|
|
115
115
|
|  | |
|
|
116
116
|
|
|
117
|
-
<!-- generated:media -->English UI screenshots and GIF were captured from v0.2.
|
|
117
|
+
<!-- generated:media -->English UI screenshots and GIF were captured from v0.2.96 (2026-11-09), using the credential-free Mock harness. Provider content retains its original language. They demonstrate UI, not real business acceptance; counts are fixtures. See [asset provenance](docs/screenshots/README.md).<!-- /generated:media -->
|
|
118
118
|
|
|
119
119
|
## Installation
|
|
120
120
|
|
|
@@ -245,7 +245,7 @@ npm run dev:ui
|
|
|
245
245
|
|
|
246
246
|
Every Registry merge regenerates `catalog-stats.json`; an hourly workflow in this repository synchronizes the Chinese and English product copy plus a local stats snapshot. The static npm README updates with package releases, while the live badges above read the Registry directly and therefore stay current without another npm release.
|
|
247
247
|
|
|
248
|
-
<!-- generated:version -->The current public version is [`dsh-mcp-connector@0.2.
|
|
248
|
+
<!-- generated:version -->The current public version is [`dsh-mcp-connector@0.2.96`](https://www.npmjs.com/package/dsh-mcp-connector), with [GitHub Release v0.2.96](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.96).<!-- /generated:version -->
|
|
249
249
|
|
|
250
250
|
See [CHANGELOG.md](CHANGELOG.md) for version history and [docs/DESKTOP-E2E.md](docs/DESKTOP-E2E.md) for the Desktop release checklist.
|
|
251
251
|
|
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ Desktop 需要完全退出并重新启动应用;Web 需要停止原 `dsh web`
|
|
|
128
128
|
| 连接诊断与最后成功缓存 | |
|
|
129
129
|
|  | |
|
|
130
130
|
|
|
131
|
-
<!-- generated:media -->截图与 GIF 采集自 v0.2.
|
|
131
|
+
<!-- generated:media -->截图与 GIF 采集自 v0.2.96(2026-11-09)无凭据 Mock 页面,展示界面而非真实业务验收;市场数量是测试夹具。来源与更新方法见 [素材说明](docs/screenshots/README.md)。<!-- /generated:media -->
|
|
132
132
|
|
|
133
133
|
## 安装
|
|
134
134
|
|
|
@@ -252,7 +252,7 @@ npm run dev:ui
|
|
|
252
252
|
|
|
253
253
|
公共 Registry 每次合并后会生成 `catalog-stats.json`;本仓库的定时工作流每小时同步中英文介绍和统计快照。npm 页面中的静态正文随版本发布更新,上方动态统计徽标则直接读取 Registry,可在不发布新 npm 版本时保持实时数量一致。
|
|
254
254
|
|
|
255
|
-
<!-- generated:version -->当前公开版本为 [`dsh-mcp-connector@0.2.
|
|
255
|
+
<!-- generated:version -->当前公开版本为 [`dsh-mcp-connector@0.2.96`](https://www.npmjs.com/package/dsh-mcp-connector),对应 [GitHub Release v0.2.96](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.96)。<!-- /generated:version -->
|
|
256
256
|
|
|
257
257
|
版本能力与变更记录见 [CHANGELOG.md](CHANGELOG.md)。
|
|
258
258
|
Desktop 发版回归见 [docs/DESKTOP-E2E.md](docs/DESKTOP-E2E.md)。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 产品截图与演示的来源及更新
|
|
2
2
|
|
|
3
|
-
<!-- generated:media -->本组 8 张截图和 GIF 均从 v0.2.
|
|
3
|
+
<!-- generated:media -->本组 8 张截图和 GIF 均从 v0.2.96 于 2026-11-09 重新采集,未修改截图中的版本文字。<!-- /generated:media -->
|
|
4
4
|
|
|
5
5
|
前七张素材由真实产品 UI 的无凭据 Mock harness 渲染:1280×720 浏览器视口、800px 产品面板、桌面两列卡片。顶部保留“无凭据 Mock”标识;目录数、连接数与工具数是演示夹具,不代表生产统计或真实授权、业务验收。不会读取用户 profile、调用服务商或上传业务数据。
|
|
6
6
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"capture": {
|
|
4
4
|
"locale": "zh-CN",
|
|
5
|
-
"capturedOn": "2026-11-
|
|
6
|
-
"sourceVersion": "0.2.
|
|
5
|
+
"capturedOn": "2026-11-09",
|
|
6
|
+
"sourceVersion": "0.2.96",
|
|
7
7
|
"sourceFingerprint": "b788ef56910a9889473ba31cf85cb234f4b55ab49c1a47ca1e8e52d760b9ce0a",
|
|
8
8
|
"browserViewport": {
|
|
9
9
|
"width": 1280,
|
|
@@ -17,63 +17,63 @@
|
|
|
17
17
|
"screenshots": [
|
|
18
18
|
{
|
|
19
19
|
"path": "docs/screenshots/01-market-overview.jpg",
|
|
20
|
-
"sha256": "
|
|
20
|
+
"sha256": "401f41f9d3b80c9bb55571ac6fdd06ebda7bc95d847a1ef0ff41650a32328962",
|
|
21
21
|
"width": 1280,
|
|
22
22
|
"height": 720,
|
|
23
|
-
"capturedOn": "2026-11-
|
|
24
|
-
"sourceVersion": "0.2.
|
|
23
|
+
"capturedOn": "2026-11-09",
|
|
24
|
+
"sourceVersion": "0.2.96"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": "docs/screenshots/02-connector-detail.jpg",
|
|
28
|
-
"sha256": "
|
|
28
|
+
"sha256": "13dffa3de9fa0730131936e0206165b7d224871eb9254a613947dee809b756be",
|
|
29
29
|
"width": 1280,
|
|
30
30
|
"height": 720,
|
|
31
|
-
"capturedOn": "2026-11-
|
|
32
|
-
"sourceVersion": "0.2.
|
|
31
|
+
"capturedOn": "2026-11-09",
|
|
32
|
+
"sourceVersion": "0.2.96"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"path": "docs/screenshots/03-tool-discovery.jpg",
|
|
36
|
-
"sha256": "
|
|
36
|
+
"sha256": "17f51c4cdcb3372de05e0d8ebf5872cf7b95687f36934ff0f097a831dfccb7fe",
|
|
37
37
|
"width": 1280,
|
|
38
38
|
"height": 720,
|
|
39
|
-
"capturedOn": "2026-11-
|
|
40
|
-
"sourceVersion": "0.2.
|
|
39
|
+
"capturedOn": "2026-11-09",
|
|
40
|
+
"sourceVersion": "0.2.96"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"path": "docs/screenshots/04-json-import.jpg",
|
|
44
|
-
"sha256": "
|
|
44
|
+
"sha256": "9f887081dca4992d9bb5e053afdeaa18c2d9ab1e0ce83b5ca567d37dae3a8e44",
|
|
45
45
|
"width": 1280,
|
|
46
46
|
"height": 720,
|
|
47
|
-
"capturedOn": "2026-11-
|
|
48
|
-
"sourceVersion": "0.2.
|
|
47
|
+
"capturedOn": "2026-11-09",
|
|
48
|
+
"sourceVersion": "0.2.96"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"path": "docs/screenshots/05-unified-tool-search.png",
|
|
52
|
-
"sha256": "
|
|
52
|
+
"sha256": "ea75769105fca29572a29f376595605fe0b6ded1b89da092f06c4b63143c3b51",
|
|
53
53
|
"width": 1280,
|
|
54
54
|
"height": 720,
|
|
55
|
-
"capturedOn": "2026-11-
|
|
56
|
-
"sourceVersion": "0.2.
|
|
55
|
+
"capturedOn": "2026-11-09",
|
|
56
|
+
"sourceVersion": "0.2.96"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"path": "docs/screenshots/06-tool-parameters.png",
|
|
60
|
-
"sha256": "
|
|
60
|
+
"sha256": "84d1fc20248f7e070c2c33086550acb3372088d44018fb640dd3802664f7bfa7",
|
|
61
61
|
"width": 1280,
|
|
62
62
|
"height": 720,
|
|
63
|
-
"capturedOn": "2026-11-
|
|
64
|
-
"sourceVersion": "0.2.
|
|
63
|
+
"capturedOn": "2026-11-09",
|
|
64
|
+
"sourceVersion": "0.2.96"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"path": "docs/screenshots/07-connection-diagnostics.png",
|
|
68
|
-
"sha256": "
|
|
68
|
+
"sha256": "7310a9ad7bcd1cb509f76c87cec655f459220df21b25a7676c77f43af385ea88",
|
|
69
69
|
"width": 1280,
|
|
70
70
|
"height": 720,
|
|
71
|
-
"capturedOn": "2026-11-
|
|
72
|
-
"sourceVersion": "0.2.
|
|
71
|
+
"capturedOn": "2026-11-09",
|
|
72
|
+
"sourceVersion": "0.2.96"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"path": "docs/screenshots/08-ten-recommendations.jpg",
|
|
76
|
-
"sha256": "
|
|
76
|
+
"sha256": "ddd2736f35a62e5e8dd353c85fd7114c461000f8407721ec869474fd4dd18374",
|
|
77
77
|
"width": 1280,
|
|
78
78
|
"height": 1400,
|
|
79
79
|
"browserViewport": {
|
|
@@ -81,17 +81,17 @@
|
|
|
81
81
|
"height": 1400
|
|
82
82
|
},
|
|
83
83
|
"panelHeight": 1280,
|
|
84
|
-
"capturedOn": "2026-11-
|
|
85
|
-
"sourceVersion": "0.2.
|
|
84
|
+
"capturedOn": "2026-11-09",
|
|
85
|
+
"sourceVersion": "0.2.96"
|
|
86
86
|
}
|
|
87
87
|
],
|
|
88
88
|
"demo": {
|
|
89
89
|
"path": "docs/demo.gif",
|
|
90
|
-
"sha256": "
|
|
90
|
+
"sha256": "2c8d30b89271b98d1655bbaef36593f87bddb4d4e33ab8f925cff705e3bba9ff",
|
|
91
91
|
"width": 960,
|
|
92
92
|
"height": 540,
|
|
93
|
-
"capturedOn": "2026-11-
|
|
94
|
-
"sourceVersion": "0.2.
|
|
93
|
+
"capturedOn": "2026-11-09",
|
|
94
|
+
"sourceVersion": "0.2.96",
|
|
95
95
|
"durationSeconds": 36
|
|
96
96
|
}
|
|
97
97
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"capture": {
|
|
4
4
|
"locale": "en",
|
|
5
|
-
"capturedOn": "2026-11-
|
|
6
|
-
"sourceVersion": "0.2.
|
|
5
|
+
"capturedOn": "2026-11-09",
|
|
6
|
+
"sourceVersion": "0.2.96",
|
|
7
7
|
"sourceFingerprint": "b788ef56910a9889473ba31cf85cb234f4b55ab49c1a47ca1e8e52d760b9ce0a",
|
|
8
8
|
"browserViewport": {
|
|
9
9
|
"width": 1280,
|
|
@@ -17,63 +17,63 @@
|
|
|
17
17
|
"screenshots": [
|
|
18
18
|
{
|
|
19
19
|
"path": "docs/screenshots/en/01-market-overview.jpg",
|
|
20
|
-
"sha256": "
|
|
20
|
+
"sha256": "d4ac70c40e6fd04ff5a2738bea649073fe98285f697a4ac1c8498ad9d4485595",
|
|
21
21
|
"width": 1280,
|
|
22
22
|
"height": 720,
|
|
23
|
-
"capturedOn": "2026-11-
|
|
24
|
-
"sourceVersion": "0.2.
|
|
23
|
+
"capturedOn": "2026-11-09",
|
|
24
|
+
"sourceVersion": "0.2.96"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": "docs/screenshots/en/02-connector-detail.jpg",
|
|
28
|
-
"sha256": "
|
|
28
|
+
"sha256": "a3ece902b88d9d424c167fa7577c58f1785451531b29efee4854df78a8fc658e",
|
|
29
29
|
"width": 1280,
|
|
30
30
|
"height": 720,
|
|
31
|
-
"capturedOn": "2026-11-
|
|
32
|
-
"sourceVersion": "0.2.
|
|
31
|
+
"capturedOn": "2026-11-09",
|
|
32
|
+
"sourceVersion": "0.2.96"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"path": "docs/screenshots/en/03-tool-discovery.jpg",
|
|
36
|
-
"sha256": "
|
|
36
|
+
"sha256": "9857f2b4b485d218bc45bdea045e0d879087f55b154e1b491ed5b91a5fe3aeb0",
|
|
37
37
|
"width": 1280,
|
|
38
38
|
"height": 720,
|
|
39
|
-
"capturedOn": "2026-11-
|
|
40
|
-
"sourceVersion": "0.2.
|
|
39
|
+
"capturedOn": "2026-11-09",
|
|
40
|
+
"sourceVersion": "0.2.96"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"path": "docs/screenshots/en/04-json-import.jpg",
|
|
44
|
-
"sha256": "
|
|
44
|
+
"sha256": "6e2d57d2832421f38bc7ca23a34843da22c04df2450c116efe80d01c0d0d4219",
|
|
45
45
|
"width": 1280,
|
|
46
46
|
"height": 720,
|
|
47
|
-
"capturedOn": "2026-11-
|
|
48
|
-
"sourceVersion": "0.2.
|
|
47
|
+
"capturedOn": "2026-11-09",
|
|
48
|
+
"sourceVersion": "0.2.96"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"path": "docs/screenshots/en/05-unified-tool-search.png",
|
|
52
|
-
"sha256": "
|
|
52
|
+
"sha256": "a00aedb700c6fd257fcb3b28a98cf2e3aecfcd41354f02522bae004897bca5d0",
|
|
53
53
|
"width": 1280,
|
|
54
54
|
"height": 720,
|
|
55
|
-
"capturedOn": "2026-11-
|
|
56
|
-
"sourceVersion": "0.2.
|
|
55
|
+
"capturedOn": "2026-11-09",
|
|
56
|
+
"sourceVersion": "0.2.96"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"path": "docs/screenshots/en/06-tool-parameters.png",
|
|
60
|
-
"sha256": "
|
|
60
|
+
"sha256": "2cd229a11667c5382b0cb374c3d2b04444bd6d69d31a9f4f038b57e85b9bd76e",
|
|
61
61
|
"width": 1280,
|
|
62
62
|
"height": 720,
|
|
63
|
-
"capturedOn": "2026-11-
|
|
64
|
-
"sourceVersion": "0.2.
|
|
63
|
+
"capturedOn": "2026-11-09",
|
|
64
|
+
"sourceVersion": "0.2.96"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"path": "docs/screenshots/en/07-connection-diagnostics.png",
|
|
68
|
-
"sha256": "
|
|
68
|
+
"sha256": "4f2e79dfa93fcf7feec2122ca6e0789606f1527a8baab9aa2e5eb30911628fac",
|
|
69
69
|
"width": 1280,
|
|
70
70
|
"height": 720,
|
|
71
|
-
"capturedOn": "2026-11-
|
|
72
|
-
"sourceVersion": "0.2.
|
|
71
|
+
"capturedOn": "2026-11-09",
|
|
72
|
+
"sourceVersion": "0.2.96"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"path": "docs/screenshots/en/08-ten-recommendations.jpg",
|
|
76
|
-
"sha256": "
|
|
76
|
+
"sha256": "c360f618049ae2a68fe67a537bb1c77fd8cd9b98ddd13036e4ea4d8da1949f03",
|
|
77
77
|
"width": 1280,
|
|
78
78
|
"height": 1400,
|
|
79
79
|
"browserViewport": {
|
|
@@ -81,17 +81,17 @@
|
|
|
81
81
|
"height": 1400
|
|
82
82
|
},
|
|
83
83
|
"panelHeight": 1280,
|
|
84
|
-
"capturedOn": "2026-11-
|
|
85
|
-
"sourceVersion": "0.2.
|
|
84
|
+
"capturedOn": "2026-11-09",
|
|
85
|
+
"sourceVersion": "0.2.96"
|
|
86
86
|
}
|
|
87
87
|
],
|
|
88
88
|
"demo": {
|
|
89
89
|
"path": "docs/screenshots/en/demo.gif",
|
|
90
|
-
"sha256": "
|
|
90
|
+
"sha256": "93485fda6525bb7a4da6aa3691cf9a319dec8d2d1e0f3c6ae60984cc5a2bf939",
|
|
91
91
|
"width": 960,
|
|
92
92
|
"height": 540,
|
|
93
|
-
"capturedOn": "2026-11-
|
|
94
|
-
"sourceVersion": "0.2.
|
|
93
|
+
"capturedOn": "2026-11-09",
|
|
94
|
+
"sourceVersion": "0.2.96",
|
|
95
95
|
"durationSeconds": 36
|
|
96
96
|
}
|
|
97
97
|
}
|
|
Binary file
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
| 项目 | 验收要求 |
|
|
10
10
|
|---|---|
|
|
11
|
-
| 前提 | <!-- generated:version -->正式 `dsh-mcp-connector@0.2.
|
|
11
|
+
| 前提 | <!-- generated:version -->正式 `dsh-mcp-connector@0.2.96`<!-- /generated:version -->;当前 Workspace;企查查 OAuth 可用;测试账号具有目标企业数据权限 |
|
|
12
12
|
| 权限/管理员 | 账号权限、组织授权和可见字段由服务商控制;企业组织可能需要管理员开通,当前文档不能替代审批 |
|
|
13
13
|
| 费用 | 可能受套餐、次数或字段权限影响;MCP连接器无法确认本次费用,调用前在服务商侧核对 |
|
|
14
14
|
| 运行/数据去向 | 远程 MCP Server;企业名称、查询参数和调用结果经 DSH Host 发送到/返回自 `agent.qcc.com` |
|
package/lib/catalog.js
CHANGED
|
@@ -173,7 +173,8 @@ export async function readLimitedJson(response, maxBytes = MAX_CATALOG_BYTES, {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
/** 拉取远程 registry(HTTPS + TTL 缓存 + 可选 ETag) */
|
|
176
|
-
export async function fetchRemoteCatalog(catalogUrl, { requestTimeoutMs, etag, t = tZh } = {}) {
|
|
176
|
+
export async function fetchRemoteCatalog(catalogUrl, { requestTimeoutMs, etag, signal, t = tZh } = {}) {
|
|
177
|
+
signal?.throwIfAborted();
|
|
177
178
|
assertSafeUrl(catalogUrl);
|
|
178
179
|
// Node 20+ does not consistently enable environment proxies for global fetch.
|
|
179
180
|
// Scope the dispatcher to this request rather than changing the DSH Host's
|
|
@@ -188,7 +189,7 @@ export async function fetchRemoteCatalog(catalogUrl, { requestTimeoutMs, etag, t
|
|
|
188
189
|
if (etag) headers['If-None-Match'] = etag;
|
|
189
190
|
const response = await fetch(catalogUrl, {
|
|
190
191
|
headers,
|
|
191
|
-
signal: controller.signal,
|
|
192
|
+
signal: signal ? AbortSignal.any([signal, controller.signal]) : controller.signal,
|
|
192
193
|
...(dispatcher ? { dispatcher } : {}),
|
|
193
194
|
});
|
|
194
195
|
assertSafeUrl(response.url || catalogUrl);
|
|
@@ -219,10 +220,12 @@ export async function fetchRemoteCatalogWithFallback(catalogUrl, fallbackUrls =
|
|
|
219
220
|
const fetched = await fetchRemoteCatalog(urls[index], {
|
|
220
221
|
requestTimeoutMs: opts.requestTimeoutMs,
|
|
221
222
|
etag: index === 0 ? opts.etag : undefined,
|
|
223
|
+
signal: opts.signal,
|
|
222
224
|
t,
|
|
223
225
|
});
|
|
224
226
|
return index === 0 ? fetched : { ...fetched, etag: undefined };
|
|
225
227
|
} catch (error) {
|
|
228
|
+
opts.signal?.throwIfAborted();
|
|
226
229
|
lastError = error;
|
|
227
230
|
opts.onSourceError?.({ index, error });
|
|
228
231
|
}
|
package/lib/index.js
CHANGED
|
@@ -325,6 +325,35 @@ export async function apply(ctx, config) {
|
|
|
325
325
|
|
|
326
326
|
/* ───────────────────────── 目录加载 ───────────────────────── */
|
|
327
327
|
|
|
328
|
+
let catalogController;
|
|
329
|
+
let catalogBackgroundCache;
|
|
330
|
+
let catalogTimer;
|
|
331
|
+
let catalogDisposed = false;
|
|
332
|
+
let catalogWrite = Promise.resolve();
|
|
333
|
+
|
|
334
|
+
async function updateRemoteCatalog(cached) {
|
|
335
|
+
catalogController?.abort();
|
|
336
|
+
const controller = new AbortController();
|
|
337
|
+
catalogController = controller;
|
|
338
|
+
const fetched = await fetchRemoteCatalogWithFallback(config.catalogUrl, catalogFallbackUrls(), {
|
|
339
|
+
requestTimeoutMs: config.requestTimeoutMs,
|
|
340
|
+
etag: cached?.etag,
|
|
341
|
+
signal: controller.signal,
|
|
342
|
+
onSourceError: warnCatalogSourceFailure,
|
|
343
|
+
});
|
|
344
|
+
controller.signal.throwIfAborted();
|
|
345
|
+
if (catalogDisposed) return;
|
|
346
|
+
const connectors = fetched.notModified ? cached.connectors : fetched.connectors;
|
|
347
|
+
state.remoteConnectors = connectors;
|
|
348
|
+
await recomputeMerged();
|
|
349
|
+
// A 304 also renews the cache freshness timestamp.
|
|
350
|
+
catalogWrite = catalogWrite.then(async () => {
|
|
351
|
+
if (catalogDisposed || controller.signal.aborted) return;
|
|
352
|
+
await catalogStore.putRemote({ etag: fetched.notModified ? cached.etag : fetched.etag, connectors });
|
|
353
|
+
}).catch(() => {});
|
|
354
|
+
await catalogWrite;
|
|
355
|
+
}
|
|
356
|
+
|
|
328
357
|
async function recomputeMerged() {
|
|
329
358
|
const bundled = loadBundledCatalog();
|
|
330
359
|
const configConnectors = (config.connectors ?? []).map((raw) => auditDescriptor(normalizeConnectorDescriptor(raw)));
|
|
@@ -366,27 +395,24 @@ export async function apply(ctx, config) {
|
|
|
366
395
|
// 远程 registry(含缓存)
|
|
367
396
|
if (config.catalogUrl) {
|
|
368
397
|
const cached = await catalogStore.getRemote().catch(() => null);
|
|
398
|
+
let validCache;
|
|
369
399
|
try {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
requestTimeoutMs: config.requestTimeoutMs,
|
|
375
|
-
etag: cached?.etag,
|
|
376
|
-
onSourceError: warnCatalogSourceFailure,
|
|
377
|
-
},
|
|
378
|
-
);
|
|
379
|
-
if (fetched.notModified) {
|
|
380
|
-
state.remoteConnectors = cached?.connectors ?? [];
|
|
381
|
-
} else {
|
|
382
|
-
state.remoteConnectors = fetched.connectors;
|
|
383
|
-
if (config.persistSecrets || true) {
|
|
384
|
-
await catalogStore.putRemote({ etag: fetched.etag, connectors: fetched.connectors }).catch(() => {});
|
|
385
|
-
}
|
|
400
|
+
if (Array.isArray(cached?.connectors)) {
|
|
401
|
+
const connectors = cached.connectors.map(raw => auditDescriptor(normalizeConnectorDescriptor(auditRawDescriptor(raw))));
|
|
402
|
+
validCache = { ...cached, connectors };
|
|
403
|
+
state.remoteConnectors = connectors;
|
|
386
404
|
}
|
|
387
405
|
} catch (error) {
|
|
388
|
-
logger.warn(`
|
|
389
|
-
|
|
406
|
+
logger.warn(`skip invalid remote catalog cache: ${error.message}`);
|
|
407
|
+
}
|
|
408
|
+
if (validCache) {
|
|
409
|
+
const age = Date.now() - Number(validCache.updatedAt);
|
|
410
|
+
if (!(Number.isFinite(age) && age >= 0 && age < (config.catalogTtlMs ?? DEFAULT_CATALOG_TTL_MS))) {
|
|
411
|
+
catalogBackgroundCache = validCache;
|
|
412
|
+
}
|
|
413
|
+
} else {
|
|
414
|
+
try { await updateRemoteCatalog(); }
|
|
415
|
+
catch (error) { logger.warn(`catalog fetch failed (using bundled catalog): ${error.message}`); }
|
|
390
416
|
}
|
|
391
417
|
}
|
|
392
418
|
await recomputeMerged();
|
|
@@ -2550,20 +2576,25 @@ export async function apply(ctx, config) {
|
|
|
2550
2576
|
},
|
|
2551
2577
|
|
|
2552
2578
|
async healthCheck(connectorId, workspaceId, connectionKey) {
|
|
2553
|
-
|
|
2579
|
+
const scoped = Boolean(workspaceId || connectionKey);
|
|
2580
|
+
const candidates = scoped ? explorerRecords(workspaceId) : [...state.connections.values()];
|
|
2581
|
+
if (connectorId && !candidates.some(record => record.connectorId === String(connectorId))) {
|
|
2582
|
+
return { ok: false, message: t('连接不存在、已停用或当前工作区不可见') };
|
|
2583
|
+
}
|
|
2584
|
+
if (connectionKey && !candidates.some((record) => record.key === connectionKey && (!connectorId || record.connectorId === connectorId))) {
|
|
2554
2585
|
return { ok: false, message: t('连接不存在、已停用或当前工作区不可见') };
|
|
2555
2586
|
}
|
|
2556
2587
|
const targetIds = connectorId
|
|
2557
2588
|
? [String(connectorId)]
|
|
2558
|
-
: [...new Set(
|
|
2589
|
+
: [...new Set(candidates.filter(record => !connectionKey || record.key === connectionKey).map((record) => record.connectorId).filter(Boolean))];
|
|
2559
2590
|
const summaries = [];
|
|
2560
2591
|
for (const id of targetIds) {
|
|
2561
|
-
const records =
|
|
2592
|
+
const records = candidates.filter((record) => record.connectorId === id
|
|
2562
2593
|
&& (!connectionKey || record.key === connectionKey));
|
|
2563
2594
|
const enabledRecords = records.filter((record) => record.enabled !== false);
|
|
2564
2595
|
if (records.length === 0 || enabledRecords.length === 0) {
|
|
2565
2596
|
const summary = healthSummary(id, records, [], Date.now());
|
|
2566
|
-
state.health.set(id, summary);
|
|
2597
|
+
if (!scoped) state.health.set(id, summary);
|
|
2567
2598
|
summaries.push(summary);
|
|
2568
2599
|
continue;
|
|
2569
2600
|
}
|
|
@@ -2611,7 +2642,7 @@ export async function apply(ctx, config) {
|
|
|
2611
2642
|
});
|
|
2612
2643
|
checkedResults = validation.detail.results;
|
|
2613
2644
|
}
|
|
2614
|
-
const summary =
|
|
2645
|
+
const summary = scoped ? healthSummary(id, records, [...immediateResults, ...checkedResults], Date.now())
|
|
2615
2646
|
: cacheHealth(id, records, [...immediateResults, ...checkedResults]);
|
|
2616
2647
|
if (connectionKey && state.connections.get(connectionKey) === records[0]) {
|
|
2617
2648
|
connectionChecks.set(connectionKey, { record: records[0], summary, at: Date.now() });
|
|
@@ -3098,17 +3129,8 @@ export async function apply(ctx, config) {
|
|
|
3098
3129
|
return { ok: true, message: t(`市场已刷新,共 {count} 个连接器`, { count: visibleCount }) };
|
|
3099
3130
|
}
|
|
3100
3131
|
try {
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
catalogFallbackUrls(),
|
|
3104
|
-
{
|
|
3105
|
-
requestTimeoutMs: config.requestTimeoutMs,
|
|
3106
|
-
onSourceError: warnCatalogSourceFailure,
|
|
3107
|
-
},
|
|
3108
|
-
);
|
|
3109
|
-
state.remoteConnectors = fetched.connectors;
|
|
3110
|
-
await catalogStore.putRemote({ etag: fetched.etag, connectors: fetched.connectors }).catch(() => {});
|
|
3111
|
-
await recomputeMerged();
|
|
3132
|
+
clearTimeout(catalogTimer);
|
|
3133
|
+
await updateRemoteCatalog();
|
|
3112
3134
|
const visibleCount = listCatalog(state.merged, { publishedOnly: true }).length;
|
|
3113
3135
|
return { ok: true, message: t(`市场已刷新,共 {count} 个连接器`, { count: visibleCount }) };
|
|
3114
3136
|
} catch (error) {
|
|
@@ -3703,6 +3725,9 @@ export async function apply(ctx, config) {
|
|
|
3703
3725
|
}
|
|
3704
3726
|
|
|
3705
3727
|
ctx.effect(() => () => {
|
|
3728
|
+
catalogDisposed = true;
|
|
3729
|
+
clearTimeout(catalogTimer);
|
|
3730
|
+
catalogController?.abort();
|
|
3706
3731
|
connectionStatistics.dispose();
|
|
3707
3732
|
discoveryDisposed = true;
|
|
3708
3733
|
clearTimeout(discoveryTimer);
|
|
@@ -3716,6 +3741,15 @@ export async function apply(ctx, config) {
|
|
|
3716
3741
|
for (const g of state.grants.values()) if (g.timer) clearTimeout(g.timer);
|
|
3717
3742
|
});
|
|
3718
3743
|
|
|
3744
|
+
if (catalogBackgroundCache) {
|
|
3745
|
+
catalogTimer = setTimeout(() => {
|
|
3746
|
+
void updateRemoteCatalog(catalogBackgroundCache).catch(error => {
|
|
3747
|
+
if (!catalogDisposed && error.name !== 'AbortError') logger.warn(`catalog background refresh failed (using cache): ${error.message}`);
|
|
3748
|
+
});
|
|
3749
|
+
}, 0);
|
|
3750
|
+
catalogTimer.unref?.();
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3719
3753
|
logger.info(t('mcp-connector active(目录 {count} 个连接器,已连接 {connected} 条)', { count: state.merged.length, connected: state.connections.size }));
|
|
3720
3754
|
}
|
|
3721
3755
|
|
package/lib/mcp-validation.js
CHANGED
|
@@ -12,6 +12,42 @@ const tZh = createTranslator(DEFAULT_LOCALE);
|
|
|
12
12
|
|
|
13
13
|
const MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
14
14
|
|
|
15
|
+
// SSE may remain open after initialize. Consume complete events, not EOF,
|
|
16
|
+
// and ignore notifications / responses for another JSON-RPC request.
|
|
17
|
+
async function readInitializePayload(response, { t }) {
|
|
18
|
+
if (!(response.headers.get('content-type') ?? '').toLowerCase().includes('text/event-stream')) {
|
|
19
|
+
return parseMcpPayload(await readLimitedText(response, MAX_RESPONSE_BYTES, { t }));
|
|
20
|
+
}
|
|
21
|
+
if (!response.body) return undefined;
|
|
22
|
+
const reader = response.body.getReader();
|
|
23
|
+
const decoder = new TextDecoder();
|
|
24
|
+
let buffer = '';
|
|
25
|
+
let total = 0;
|
|
26
|
+
try {
|
|
27
|
+
for (;;) {
|
|
28
|
+
const { done, value } = await reader.read();
|
|
29
|
+
if (done) return undefined;
|
|
30
|
+
total += value.byteLength;
|
|
31
|
+
if (total > MAX_RESPONSE_BYTES) throw new Error(t('MCP 响应过大'));
|
|
32
|
+
buffer += decoder.decode(value, { stream: true });
|
|
33
|
+
let boundary;
|
|
34
|
+
while ((boundary = /\r\n\r\n|\n\n|\r\r/.exec(buffer))) {
|
|
35
|
+
const event = buffer.slice(0, boundary.index);
|
|
36
|
+
buffer = buffer.slice(boundary.index + boundary[0].length);
|
|
37
|
+
const data = event.split(/\r\n|\n|\r/).filter(line => line.startsWith('data:'))
|
|
38
|
+
.map(line => line.slice(5).replace(/^ /, '')).join('\n');
|
|
39
|
+
let payload;
|
|
40
|
+
try { payload = JSON.parse(data); } catch { continue; }
|
|
41
|
+
if (payload?.jsonrpc === '2.0' && payload.id === 1 && ('result' in payload || 'error' in payload)) return payload;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} finally {
|
|
45
|
+
// Cancellation must not await a server closing its persistent stream.
|
|
46
|
+
void reader.cancel().catch(() => {});
|
|
47
|
+
reader.releaseLock();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
15
51
|
async function readLimitedText(response, maxBytes = MAX_RESPONSE_BYTES, { t = tZh } = {}) {
|
|
16
52
|
const declared = Number(response.headers.get('content-length'));
|
|
17
53
|
if (Number.isFinite(declared) && declared > maxBytes) throw new Error(t('MCP 响应过大'));
|
|
@@ -180,8 +216,7 @@ export async function validateConnectionRecord(record, {
|
|
|
180
216
|
return failed(record, 'http', message, { httpStatus: response.status });
|
|
181
217
|
}
|
|
182
218
|
|
|
183
|
-
const
|
|
184
|
-
const payload = parseMcpPayload(text, response.headers.get('content-type') ?? '');
|
|
219
|
+
const payload = await readInitializePayload(response, { t });
|
|
185
220
|
if (!payload || payload.jsonrpc !== '2.0') {
|
|
186
221
|
return failed(record, 'protocol', t('目标地址可访问,但未返回有效的 MCP 初始化响应'));
|
|
187
222
|
}
|
package/lib/tools.js
CHANGED
|
@@ -412,13 +412,15 @@ export function registerTools(ctx, api, { compact = false, t = createTranslator(
|
|
|
412
412
|
type: 'object',
|
|
413
413
|
properties: {
|
|
414
414
|
connectorId: { type: 'string', description: t('连接器 id(可选)') },
|
|
415
|
+
workspaceId: { type: 'string', description: t('可选;只加载在该 Workspace 可见的已连接 Server') },
|
|
416
|
+
connectionKey: { type: 'string', description: t('可选;来自 status 的连接 key,限定手动、JSON 或目录安装的单条连接') },
|
|
415
417
|
},
|
|
416
418
|
additionalProperties: false,
|
|
417
419
|
},
|
|
418
420
|
output: healthOutput(t),
|
|
419
421
|
timeoutMs: 120_000,
|
|
420
422
|
async execute(args) {
|
|
421
|
-
return api.healthCheck(args?.connectorId);
|
|
423
|
+
return api.healthCheck(args?.connectorId, args?.workspaceId, args?.connectionKey);
|
|
422
424
|
},
|
|
423
425
|
});
|
|
424
426
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mcp-connector",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.96",
|
|
4
4
|
"description": "MCP Connector for DeepSeek Harness: a data marketplace connecting enterprise, financial, legal, patent and research data. Manage authorization, search tools and troubleshoot MCP connections. Supports OAuth, API keys and HTTP/stdio.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|