dsh-mcp-connector 0.2.98 → 0.2.100
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 +14 -0
- package/README.en.md +7 -2
- package/README.md +7 -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 +20 -20
- 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 +20 -20
- package/docs/screenshots/en/demo.gif +0 -0
- package/docs/tutorials/FIRST-SUCCESS-SCENARIOS.md +1 -1
- package/lib/diagnostics.js +4 -1
- package/lib/index.js +66 -17
- package/lib/mcp-http.js +27 -3
- package/lib/mcp-sse.js +48 -0
- package/lib/mcp-validation.js +5 -28
- package/package.json +2 -2
- package/ui/index.html +13 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.100
|
|
4
|
+
|
|
5
|
+
- Publish the npm download trend chart in the package README, sharing the maintained chart with GitHub and the connector registry.
|
|
6
|
+
- Clearly distinguish npm downloads from unique users, successful installations and individual connector connections.
|
|
7
|
+
- Refresh bilingual product screenshots and generated documentation for this release.
|
|
8
|
+
|
|
9
|
+
## 0.2.99
|
|
10
|
+
|
|
11
|
+
- Finish tool discovery when a streamable-HTTP server keeps the SSE response open after initialize or tools/list, instead of waiting for EOF and reporting a timeout (#218).
|
|
12
|
+
- Ignore notifications and unrelated request ids while consuming SSE events; preserve authentication error classification.
|
|
13
|
+
- Share a line-based SSE reader between connection validation and tool discovery, including mixed LF/CRLF/CR endings and UTF-8 fragments (#218).
|
|
14
|
+
- Keep handshake health separate from tool-discovery failures. Preserve per-connection checks, show discovery diagnostics independently, and retain real handshake/authentication failures (#218).
|
|
15
|
+
- Maintainer revalidation passed for #218 and the previously released catalog TTL, background refresh and source-isolation fixes for #219. Both issues remain open for tracking.
|
|
16
|
+
|
|
3
17
|
## 0.2.98
|
|
4
18
|
|
|
5
19
|
- Replace the hidden first-use question mark with a bilingual Quick start action and a zero-connection guidance card that leads directly to recommended connectors or the existing read-only getting-started flow.
|
package/README.en.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# MCP Connector: a Specialist Data Marketplace for DeepSeek Harness
|
|
2
2
|
|
|
3
|
+
<!-- npm-download-trend:start -->
|
|
4
|
+
[](https://github.com/duhu2000/dsh-mcp-connector/blob/main/docs/metrics/npm-downloads.json)
|
|
5
|
+
npm downloads include upgrades, repeat installs and automation; they are not unique users or successful installs. The chart shows its UTC cutoff. [Install](#get-started) · [First successful connection](https://github.com/duhu2000/dsh-mcp-connector/blob/main/docs/tutorials/FIRST-SUCCESS-SCENARIOS.md)
|
|
6
|
+
<!-- npm-download-trend:end -->
|
|
7
|
+
|
|
3
8
|
> MCP Connector for DeepSeek Harness: a data marketplace connecting specialist providers and open data sources. Browse 100+ connectors, manage authorization, search tools and troubleshoot MCP connections.
|
|
4
9
|
|
|
5
10
|
Connect MCP servers from a continuously updated catalog. Search tools across enabled connections in the current scope, inspect readable parameters, source metadata, and the last successful cache time, then check a connection or rediscover its tools when discovery fails. Supports OAuth 2.0 PKCE, API keys, Streamable HTTP/stdio, and `mcpServers` JSON import.
|
|
@@ -114,7 +119,7 @@ As of 2026-10-24, the public Registry publishes 112 connector descriptors. After
|
|
|
114
119
|
| Connection diagnostics and last-success cache | |
|
|
115
120
|
|  | |
|
|
116
121
|
|
|
117
|
-
<!-- generated:media -->English UI screenshots and GIF were captured from v0.2.
|
|
122
|
+
<!-- generated:media -->English UI screenshots and GIF were captured from v0.2.100 (2026-11-10), 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
123
|
|
|
119
124
|
## Installation
|
|
120
125
|
|
|
@@ -245,7 +250,7 @@ npm run dev:ui
|
|
|
245
250
|
|
|
246
251
|
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
252
|
|
|
248
|
-
<!-- generated:version -->The current public version is [`dsh-mcp-connector@0.2.
|
|
253
|
+
<!-- generated:version -->The current public version is [`dsh-mcp-connector@0.2.100`](https://www.npmjs.com/package/dsh-mcp-connector), with [GitHub Release v0.2.100](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.100).<!-- /generated:version -->
|
|
249
254
|
|
|
250
255
|
See [CHANGELOG.md](CHANGELOG.md) for version history and [docs/DESKTOP-E2E.md](docs/DESKTOP-E2E.md) for the Desktop release checklist.
|
|
251
256
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# MCP连接器:DeepSeek Harness 的专业数据源市场
|
|
2
2
|
|
|
3
|
+
<!-- npm-download-trend:start -->
|
|
4
|
+
[](https://github.com/duhu2000/dsh-mcp-connector/blob/main/docs/metrics/npm-downloads.json)
|
|
5
|
+
npm 下载次数包含升级、重复安装及自动化下载,不等于独立用户数或成功安装数;数据截止日期见图中 UTC 标注。[安装使用](#开始使用) · [首次成功教程](docs/tutorials/FIRST-SUCCESS-SCENARIOS.md)
|
|
6
|
+
<!-- npm-download-trend:end -->
|
|
7
|
+
|
|
3
8
|
> DeepSeek Harness 的 MCP 数据市场:汇聚各类垂直领域数据厂商与开放数据源,通过超百个 MCP连接器接入 MCP Server,统一授权、查找工具与连接排障。
|
|
4
9
|
|
|
5
10
|
从持续更新的连接器目录接入 MCP Server;跨当前范围内已启用连接查找工具,查看易读参数、来源和最后成功缓存时间,并在发现异常时检查连接或重新发现工具。支持 OAuth 2.0 PKCE、API Key、Streamable HTTP/stdio 与 `mcpServers` JSON 导入。
|
|
@@ -128,7 +133,7 @@ Desktop 需要完全退出并重新启动应用;Web 需要停止原 `dsh web`
|
|
|
128
133
|
| 连接诊断与最后成功缓存 | |
|
|
129
134
|
|  | |
|
|
130
135
|
|
|
131
|
-
<!-- generated:media -->截图与 GIF 采集自 v0.2.
|
|
136
|
+
<!-- generated:media -->截图与 GIF 采集自 v0.2.100(2026-11-10)无凭据 Mock 页面,展示界面而非真实业务验收;市场数量是测试夹具。来源与更新方法见 [素材说明](docs/screenshots/README.md)。<!-- /generated:media -->
|
|
132
137
|
|
|
133
138
|
## 安装
|
|
134
139
|
|
|
@@ -252,7 +257,7 @@ npm run dev:ui
|
|
|
252
257
|
|
|
253
258
|
公共 Registry 每次合并后会生成 `catalog-stats.json`;本仓库的定时工作流每小时同步中英文介绍和统计快照。npm 页面中的静态正文随版本发布更新,上方动态统计徽标则直接读取 Registry,可在不发布新 npm 版本时保持实时数量一致。
|
|
254
259
|
|
|
255
|
-
<!-- generated:version -->当前公开版本为 [`dsh-mcp-connector@0.2.
|
|
260
|
+
<!-- generated:version -->当前公开版本为 [`dsh-mcp-connector@0.2.100`](https://www.npmjs.com/package/dsh-mcp-connector),对应 [GitHub Release v0.2.100](https://github.com/duhu2000/dsh-mcp-connector/releases/tag/v0.2.100)。<!-- /generated:version -->
|
|
256
261
|
|
|
257
262
|
版本能力与变更记录见 [CHANGELOG.md](CHANGELOG.md)。
|
|
258
263
|
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.100 于 2026-11-10 重新采集,未修改截图中的版本文字。<!-- /generated:media -->
|
|
4
4
|
|
|
5
5
|
前七张素材由真实产品 UI 的无凭据 Mock harness 渲染:1280×720 浏览器视口、800px 产品面板、桌面两列卡片。顶部保留“无凭据 Mock”标识;目录数、连接数与工具数是演示夹具,不代表生产统计或真实授权、业务验收。不会读取用户 profile、调用服务商或上传业务数据。
|
|
6
6
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"capture": {
|
|
4
4
|
"locale": "zh-CN",
|
|
5
5
|
"capturedOn": "2026-11-10",
|
|
6
|
-
"sourceVersion": "0.2.
|
|
7
|
-
"sourceFingerprint": "
|
|
6
|
+
"sourceVersion": "0.2.100",
|
|
7
|
+
"sourceFingerprint": "b36089cc721fa8b15a923c1e5bcf0003fc74da608710c046a5444301b6d324ae",
|
|
8
8
|
"browserViewport": {
|
|
9
9
|
"width": 1280,
|
|
10
10
|
"height": 720
|
|
@@ -17,63 +17,63 @@
|
|
|
17
17
|
"screenshots": [
|
|
18
18
|
{
|
|
19
19
|
"path": "docs/screenshots/01-market-overview.jpg",
|
|
20
|
-
"sha256": "
|
|
20
|
+
"sha256": "9c35d2fea6cc1e3999b3da8bcab051f681e00ca49996d513ca9e0adfb1baa0a3",
|
|
21
21
|
"width": 1280,
|
|
22
22
|
"height": 720,
|
|
23
23
|
"capturedOn": "2026-11-10",
|
|
24
|
-
"sourceVersion": "0.2.
|
|
24
|
+
"sourceVersion": "0.2.100"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": "docs/screenshots/02-connector-detail.jpg",
|
|
28
|
-
"sha256": "
|
|
28
|
+
"sha256": "349ec1eae9297dab97ac18bc3c7c15324ecbd28db40d35f5cb6625e08441a7ca",
|
|
29
29
|
"width": 1280,
|
|
30
30
|
"height": 720,
|
|
31
31
|
"capturedOn": "2026-11-10",
|
|
32
|
-
"sourceVersion": "0.2.
|
|
32
|
+
"sourceVersion": "0.2.100"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"path": "docs/screenshots/03-tool-discovery.jpg",
|
|
36
|
-
"sha256": "
|
|
36
|
+
"sha256": "534163ec02993382909a97f4b6d741e364319c232ceb6411601aa0c08ff335ef",
|
|
37
37
|
"width": 1280,
|
|
38
38
|
"height": 720,
|
|
39
39
|
"capturedOn": "2026-11-10",
|
|
40
|
-
"sourceVersion": "0.2.
|
|
40
|
+
"sourceVersion": "0.2.100"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"path": "docs/screenshots/04-json-import.jpg",
|
|
44
|
-
"sha256": "
|
|
44
|
+
"sha256": "38fe82951e2106b97fc1ad8fe668e77de4d6f2f7a05ae9f5817b01407e7cfd39",
|
|
45
45
|
"width": 1280,
|
|
46
46
|
"height": 720,
|
|
47
47
|
"capturedOn": "2026-11-10",
|
|
48
|
-
"sourceVersion": "0.2.
|
|
48
|
+
"sourceVersion": "0.2.100"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"path": "docs/screenshots/05-unified-tool-search.png",
|
|
52
|
-
"sha256": "
|
|
52
|
+
"sha256": "61291fe467b4833261ea308471e6408909fae326b1f882e253ea4ca04d4ae3c7",
|
|
53
53
|
"width": 1280,
|
|
54
54
|
"height": 720,
|
|
55
55
|
"capturedOn": "2026-11-10",
|
|
56
|
-
"sourceVersion": "0.2.
|
|
56
|
+
"sourceVersion": "0.2.100"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"path": "docs/screenshots/06-tool-parameters.png",
|
|
60
|
-
"sha256": "
|
|
60
|
+
"sha256": "3ab71d64760fe511f3784356ab3bbc073ddf4ab6d9f8d83f0138388423c5668f",
|
|
61
61
|
"width": 1280,
|
|
62
62
|
"height": 720,
|
|
63
63
|
"capturedOn": "2026-11-10",
|
|
64
|
-
"sourceVersion": "0.2.
|
|
64
|
+
"sourceVersion": "0.2.100"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"path": "docs/screenshots/07-connection-diagnostics.png",
|
|
68
|
-
"sha256": "
|
|
68
|
+
"sha256": "904ba7c4521e8c711e6ad00c2b743cbc075778996c003f57bfcebe0cbeeeea65",
|
|
69
69
|
"width": 1280,
|
|
70
70
|
"height": 720,
|
|
71
71
|
"capturedOn": "2026-11-10",
|
|
72
|
-
"sourceVersion": "0.2.
|
|
72
|
+
"sourceVersion": "0.2.100"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"path": "docs/screenshots/08-ten-recommendations.jpg",
|
|
76
|
-
"sha256": "
|
|
76
|
+
"sha256": "6720b6fccd233acdc3a49da9ba6cb657514b9d0c13303cfc04c95bccc586f7c3",
|
|
77
77
|
"width": 1280,
|
|
78
78
|
"height": 1400,
|
|
79
79
|
"browserViewport": {
|
|
@@ -82,16 +82,16 @@
|
|
|
82
82
|
},
|
|
83
83
|
"panelHeight": 1280,
|
|
84
84
|
"capturedOn": "2026-11-10",
|
|
85
|
-
"sourceVersion": "0.2.
|
|
85
|
+
"sourceVersion": "0.2.100"
|
|
86
86
|
}
|
|
87
87
|
],
|
|
88
88
|
"demo": {
|
|
89
89
|
"path": "docs/demo.gif",
|
|
90
|
-
"sha256": "
|
|
90
|
+
"sha256": "23cbfb71e70fca23d2d4d02eaefb9d2c4cec0129d686de46e12ca70423c80e41",
|
|
91
91
|
"width": 960,
|
|
92
92
|
"height": 540,
|
|
93
93
|
"capturedOn": "2026-11-10",
|
|
94
|
-
"sourceVersion": "0.2.
|
|
94
|
+
"sourceVersion": "0.2.100",
|
|
95
95
|
"durationSeconds": 36
|
|
96
96
|
}
|
|
97
97
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"capture": {
|
|
4
4
|
"locale": "en",
|
|
5
5
|
"capturedOn": "2026-11-10",
|
|
6
|
-
"sourceVersion": "0.2.
|
|
7
|
-
"sourceFingerprint": "
|
|
6
|
+
"sourceVersion": "0.2.100",
|
|
7
|
+
"sourceFingerprint": "b36089cc721fa8b15a923c1e5bcf0003fc74da608710c046a5444301b6d324ae",
|
|
8
8
|
"browserViewport": {
|
|
9
9
|
"width": 1280,
|
|
10
10
|
"height": 720
|
|
@@ -17,63 +17,63 @@
|
|
|
17
17
|
"screenshots": [
|
|
18
18
|
{
|
|
19
19
|
"path": "docs/screenshots/en/01-market-overview.jpg",
|
|
20
|
-
"sha256": "
|
|
20
|
+
"sha256": "d787ce6f86ef01f01a4d40b28fb4e1343fbe1deb483812950ea80a2fc3b71104",
|
|
21
21
|
"width": 1280,
|
|
22
22
|
"height": 720,
|
|
23
23
|
"capturedOn": "2026-11-10",
|
|
24
|
-
"sourceVersion": "0.2.
|
|
24
|
+
"sourceVersion": "0.2.100"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"path": "docs/screenshots/en/02-connector-detail.jpg",
|
|
28
|
-
"sha256": "
|
|
28
|
+
"sha256": "ab9d7a78e4560c992abbdc19ddcf044575aeaf44ca3c92ad1219040f1cbb2a89",
|
|
29
29
|
"width": 1280,
|
|
30
30
|
"height": 720,
|
|
31
31
|
"capturedOn": "2026-11-10",
|
|
32
|
-
"sourceVersion": "0.2.
|
|
32
|
+
"sourceVersion": "0.2.100"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"path": "docs/screenshots/en/03-tool-discovery.jpg",
|
|
36
|
-
"sha256": "
|
|
36
|
+
"sha256": "39d17e23623f0ef3a9a7a5d67ddfc8abd44b8a6ed9dcdb0b62c25f822aa70e72",
|
|
37
37
|
"width": 1280,
|
|
38
38
|
"height": 720,
|
|
39
39
|
"capturedOn": "2026-11-10",
|
|
40
|
-
"sourceVersion": "0.2.
|
|
40
|
+
"sourceVersion": "0.2.100"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"path": "docs/screenshots/en/04-json-import.jpg",
|
|
44
|
-
"sha256": "
|
|
44
|
+
"sha256": "2c8fb3ebb3660fffedfa98889ac7ca3285d8262eb15b4436f443b2dcaadbd237",
|
|
45
45
|
"width": 1280,
|
|
46
46
|
"height": 720,
|
|
47
47
|
"capturedOn": "2026-11-10",
|
|
48
|
-
"sourceVersion": "0.2.
|
|
48
|
+
"sourceVersion": "0.2.100"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"path": "docs/screenshots/en/05-unified-tool-search.png",
|
|
52
|
-
"sha256": "
|
|
52
|
+
"sha256": "17dc26926d694e30c548781c5a5f2554e13de71016942bd3f9e6593a5aa5d3e8",
|
|
53
53
|
"width": 1280,
|
|
54
54
|
"height": 720,
|
|
55
55
|
"capturedOn": "2026-11-10",
|
|
56
|
-
"sourceVersion": "0.2.
|
|
56
|
+
"sourceVersion": "0.2.100"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"path": "docs/screenshots/en/06-tool-parameters.png",
|
|
60
|
-
"sha256": "
|
|
60
|
+
"sha256": "4d273950025b97220494b1d36d776aacf50b49d5ccbcbf3d9bbb231391d398d8",
|
|
61
61
|
"width": 1280,
|
|
62
62
|
"height": 720,
|
|
63
63
|
"capturedOn": "2026-11-10",
|
|
64
|
-
"sourceVersion": "0.2.
|
|
64
|
+
"sourceVersion": "0.2.100"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"path": "docs/screenshots/en/07-connection-diagnostics.png",
|
|
68
|
-
"sha256": "
|
|
68
|
+
"sha256": "71005865e7efd85a6e25bf91027c1c892cab2520c10b4084f54a832e16c331c3",
|
|
69
69
|
"width": 1280,
|
|
70
70
|
"height": 720,
|
|
71
71
|
"capturedOn": "2026-11-10",
|
|
72
|
-
"sourceVersion": "0.2.
|
|
72
|
+
"sourceVersion": "0.2.100"
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"path": "docs/screenshots/en/08-ten-recommendations.jpg",
|
|
76
|
-
"sha256": "
|
|
76
|
+
"sha256": "64febfcd61be46cb6f12513516b3826bd2cc1a73afe17e8b2fcd0c3b336c584b",
|
|
77
77
|
"width": 1280,
|
|
78
78
|
"height": 1400,
|
|
79
79
|
"browserViewport": {
|
|
@@ -82,16 +82,16 @@
|
|
|
82
82
|
},
|
|
83
83
|
"panelHeight": 1280,
|
|
84
84
|
"capturedOn": "2026-11-10",
|
|
85
|
-
"sourceVersion": "0.2.
|
|
85
|
+
"sourceVersion": "0.2.100"
|
|
86
86
|
}
|
|
87
87
|
],
|
|
88
88
|
"demo": {
|
|
89
89
|
"path": "docs/screenshots/en/demo.gif",
|
|
90
|
-
"sha256": "
|
|
90
|
+
"sha256": "488f44d7014f209128beed418d388ced396348d1404bcf9328d89dca0de07a4f",
|
|
91
91
|
"width": 960,
|
|
92
92
|
"height": 540,
|
|
93
93
|
"capturedOn": "2026-11-10",
|
|
94
|
-
"sourceVersion": "0.2.
|
|
94
|
+
"sourceVersion": "0.2.100",
|
|
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.100`<!-- /generated:version -->;当前 Workspace;企查查 OAuth 可用;测试账号具有目标企业数据权限 |
|
|
12
12
|
| 权限/管理员 | 账号权限、组织授权和可见字段由服务商控制;企业组织可能需要管理员开通,当前文档不能替代审批 |
|
|
13
13
|
| 费用 | 可能受套餐、次数或字段权限影响;MCP连接器无法确认本次费用,调用前在服务商侧核对 |
|
|
14
14
|
| 运行/数据去向 | 远程 MCP Server;企业名称、查询参数和调用结果经 DSH Host 发送到/返回自 `agent.qcc.com` |
|
package/lib/diagnostics.js
CHANGED
|
@@ -52,6 +52,7 @@ const FAILURE_GUIDANCE = Object.freeze({
|
|
|
52
52
|
'host-tools-pending': ['host-observation', '查看 Host 日志并重新检查;可用性确认前保持未知'],
|
|
53
53
|
'host-status-unavailable': ['host-observation', '升级或重启 DSH Host,待注册状态可见后重新检查'],
|
|
54
54
|
'host-status-error': ['host-observation', '查看 Host 日志并重新检查工具注册状态'],
|
|
55
|
+
'not-checked': ['host-observation', '运行健康检查以确认连接状态'],
|
|
55
56
|
'tool-list': ['tool-discovery', '检查 Server 工具权限和服务状态后重试'],
|
|
56
57
|
});
|
|
57
58
|
|
|
@@ -144,7 +145,9 @@ function resultDiagnostic(t, result, checkedAt, previous) {
|
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
const code = result.code || result.kind || 'network';
|
|
147
|
-
const [
|
|
148
|
+
const [defaultStage, defaultAction] = FAILURE_GUIDANCE[code] || FAILURE_GUIDANCE.network;
|
|
149
|
+
const stage = result.stage || defaultStage;
|
|
150
|
+
const action = stage === 'tool-discovery' ? FAILURE_GUIDANCE['tool-list'][1] : defaultAction;
|
|
148
151
|
return {
|
|
149
152
|
state: failureState(result.kind),
|
|
150
153
|
stage,
|
package/lib/index.js
CHANGED
|
@@ -1233,12 +1233,8 @@ export async function apply(ctx, config) {
|
|
|
1233
1233
|
const plan = discoveryPlans.get(record.key);
|
|
1234
1234
|
const currentPlan = plan?.record === record ? plan : null;
|
|
1235
1235
|
const check = connectionChecks.get(record.key);
|
|
1236
|
-
const diagnostic = check?.record === record
|
|
1237
|
-
|
|
1238
|
-
: server ? buildHealthSummary({ connectorId: record.connectorId, records: [record], results: [{
|
|
1239
|
-
ok: server.ok || server.unknown, kind: server.unknown ? 'managed' : server.ok ? 'connected' : server.errorKind || 'network',
|
|
1240
|
-
code: server.diagnosticCode, serverName: record.serverName, serverKey: record.serverKey, message: server.error,
|
|
1241
|
-
}], checkedAt: view.at }).diagnostic : null;
|
|
1236
|
+
const diagnostic = check?.record === record ? check.summary.diagnostic : null;
|
|
1237
|
+
const discoveryDiagnostic = server ? discoveryHealth(record.connectorId, [record], [server], view.at).diagnostic : null;
|
|
1242
1238
|
const status = !server ? 'pending' : server.unknown ? 'unknown' : server.ok ? 'success' : 'failed';
|
|
1243
1239
|
return {
|
|
1244
1240
|
connectionKey: record.key, connectionName: record.name, connectorId: record.connectorId,
|
|
@@ -1247,7 +1243,7 @@ export async function apply(ctx, config) {
|
|
|
1247
1243
|
checkedAt: view?.record === record ? view.at : null,
|
|
1248
1244
|
observedAt: cache?.observedAt || null, stale: cache?.stale || false,
|
|
1249
1245
|
toolCount: cache?.entry.tools.length || 0, cacheTruncated: cache?.entry.truncated === true,
|
|
1250
|
-
diagnostic, nextDiscoveryAt: currentPlan?.nextAt ?? null,
|
|
1246
|
+
diagnostic, discoveryDiagnostic, nextDiscoveryAt: currentPlan?.nextAt ?? null,
|
|
1251
1247
|
retryReason: currentPlan?.reason || null,
|
|
1252
1248
|
};
|
|
1253
1249
|
}
|
|
@@ -1307,10 +1303,52 @@ export async function apply(ctx, config) {
|
|
|
1307
1303
|
return cached ?? healthSummary(connectorId, records, [], null);
|
|
1308
1304
|
}
|
|
1309
1305
|
|
|
1306
|
+
function observedHealth(connectorId, records, previous = state.health.get(connectorId) ?? null) {
|
|
1307
|
+
const enabled = records.filter((record) => record.enabled !== false);
|
|
1308
|
+
const checks = enabled.map((record) => {
|
|
1309
|
+
const check = connectionChecks.get(record.key);
|
|
1310
|
+
return check?.record === record ? check : null;
|
|
1311
|
+
});
|
|
1312
|
+
return buildHealthSummary({
|
|
1313
|
+
connectorId, records, previous,
|
|
1314
|
+
checkedAt: checks.some(Boolean) ? Math.max(...checks.filter(Boolean).map((check) => check.at)) : null,
|
|
1315
|
+
results: enabled.map((record, index) => grantFailure(record) ?? checks[index]?.summary.results[0] ?? {
|
|
1316
|
+
ok: true, kind: 'managed', code: 'not-checked', serverKey: record.serverKey, serverName: record.serverName,
|
|
1317
|
+
message: t('已保存配置,但本进程尚未观察到可用性检查结果'),
|
|
1318
|
+
}),
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
function discoveryHealth(connectorId, records, servers, checkedAt = Date.now()) {
|
|
1323
|
+
return buildHealthSummary({ connectorId, records, checkedAt, results: servers.map((server) => ({
|
|
1324
|
+
ok: server.ok || server.unknown, kind: server.unknown ? 'managed' : server.ok ? 'connected' : server.errorKind ?? 'network',
|
|
1325
|
+
serverKey: server.serverKey, serverName: server.serverName, code: server.diagnosticCode,
|
|
1326
|
+
stage: server.errorStage === 'tool-discovery' || server.ok ? 'tool-discovery' : undefined, message: server.error,
|
|
1327
|
+
})) });
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1310
1330
|
function cacheHealth(connectorId, records, results) {
|
|
1311
|
-
const
|
|
1312
|
-
state.health.
|
|
1313
|
-
|
|
1331
|
+
const now = Date.now();
|
|
1332
|
+
const previous = state.health.get(connectorId) ?? null;
|
|
1333
|
+
for (const record of records) {
|
|
1334
|
+
if (state.connections.get(record.key) !== record || record.enabled === false) continue;
|
|
1335
|
+
const result = results.find((item) => item.serverName === record.serverName)
|
|
1336
|
+
?? results.find((item) => item.serverKey === record.serverKey);
|
|
1337
|
+
if (!result) continue;
|
|
1338
|
+
const at = result.checkedAt ?? now;
|
|
1339
|
+
const prior = connectionChecks.get(record.key);
|
|
1340
|
+
// With millisecond clocks, a tied discovery observation must also yield to
|
|
1341
|
+
// an explicit check already recorded while tools/list was in flight.
|
|
1342
|
+
if (prior?.record === record && (prior.at > at || (prior.at === at && result.checkedAt !== undefined))) continue;
|
|
1343
|
+
const summary = buildHealthSummary({
|
|
1344
|
+
connectorId, records: [record], results: [result], checkedAt: at,
|
|
1345
|
+
previous: prior?.record === record ? prior.summary : previous,
|
|
1346
|
+
});
|
|
1347
|
+
connectionChecks.set(record.key, { record, summary, at });
|
|
1348
|
+
}
|
|
1349
|
+
// Scoped checks merge only their records; other connections keep their own observations.
|
|
1350
|
+
state.health.set(connectorId, observedHealth(connectorId, [...state.connections.values()].filter((record) => record.connectorId === connectorId), previous));
|
|
1351
|
+
return observedHealth(connectorId, records, previous);
|
|
1314
1352
|
}
|
|
1315
1353
|
|
|
1316
1354
|
function resolveCredentialValues(connector, params = {}) {
|
|
@@ -2514,7 +2552,10 @@ export async function apply(ctx, config) {
|
|
|
2514
2552
|
async status({ workspaceId } = {}) {
|
|
2515
2553
|
const items = [];
|
|
2516
2554
|
for (const [key, record] of state.connections) {
|
|
2517
|
-
const
|
|
2555
|
+
const check = connectionChecks.get(key);
|
|
2556
|
+
const failure = grantFailure(record);
|
|
2557
|
+
const health = failure ? healthSummary(record.connectorId, [record], [failure])
|
|
2558
|
+
: check?.record === record ? check.summary : record.connectorId ? connectorHealth(record.connectorId) : null;
|
|
2518
2559
|
const recordHealth = health?.results?.find((result) => result.serverKey === record.serverKey || result.serverName === record.serverName);
|
|
2519
2560
|
const diagnostic = diagnosticForRecord(health, recordHealth);
|
|
2520
2561
|
let grantInfo = null;
|
|
@@ -2643,10 +2684,8 @@ export async function apply(ctx, config) {
|
|
|
2643
2684
|
});
|
|
2644
2685
|
checkedResults = validation.detail.results;
|
|
2645
2686
|
}
|
|
2646
|
-
const summary =
|
|
2647
|
-
: cacheHealth(id, records, [...immediateResults, ...checkedResults]);
|
|
2687
|
+
const summary = cacheHealth(id, records, [...immediateResults, ...checkedResults]);
|
|
2648
2688
|
if (connectionKey && state.connections.get(connectionKey) === records[0]) {
|
|
2649
|
-
connectionChecks.set(connectionKey, { record: records[0], summary, at: Date.now() });
|
|
2650
2689
|
const outcome = [...immediateResults, ...checkedResults][0];
|
|
2651
2690
|
if (outcome && !outcome.ok) {
|
|
2652
2691
|
const prior = discoveryPlans.get(connectionKey);
|
|
@@ -3308,6 +3347,7 @@ export async function apply(ctx, config) {
|
|
|
3308
3347
|
unknown: !current || current.unknown === true,
|
|
3309
3348
|
pending: current?.pending === true || (!current && !cached),
|
|
3310
3349
|
error: current?.error || (!cached && !current ? t('正在后台发现工具,请稍候') : undefined),
|
|
3350
|
+
errorKind: current?.errorKind, errorStage: current?.errorStage, diagnosticCode: current?.diagnosticCode,
|
|
3311
3351
|
policy: serverPolicy(record),
|
|
3312
3352
|
...(cached ? { cacheObservedAt: cached.observedAt, cacheAgeMs: cached.cacheAgeMs, stale: cached.stale } : {}),
|
|
3313
3353
|
tools: (cached?.entry.tools || []).map((tool) => decorateToolPolicy(record, {
|
|
@@ -3315,9 +3355,12 @@ export async function apply(ctx, config) {
|
|
|
3315
3355
|
})),
|
|
3316
3356
|
};
|
|
3317
3357
|
});
|
|
3358
|
+
const health = observedHealth(connectorId, records);
|
|
3318
3359
|
return { ok: servers.some((server) => server.ok), message: t('最近工具发现状态'), detail: {
|
|
3319
3360
|
connectorId, servers, totalTools: servers.reduce((sum, server) => sum + server.tools.length, 0),
|
|
3320
3361
|
source: 'last-success-cache',
|
|
3362
|
+
connectionState: health.connectionState, diagnostic: health.diagnostic,
|
|
3363
|
+
discoveryDiagnostic: discoveryHealth(connectorId, records, servers).diagnostic,
|
|
3321
3364
|
} };
|
|
3322
3365
|
}
|
|
3323
3366
|
if (!records.length) {
|
|
@@ -3419,6 +3462,7 @@ export async function apply(ctx, config) {
|
|
|
3419
3462
|
serverKey: record.serverKey || record.name,
|
|
3420
3463
|
serverName: record.serverName,
|
|
3421
3464
|
ok: true,
|
|
3465
|
+
connectionCheckedAt: listed.connectionCheckedAt,
|
|
3422
3466
|
policy: serverPolicy(record),
|
|
3423
3467
|
tools: listed.tools.map((t) => decorateToolPolicy(record, {
|
|
3424
3468
|
name: t.name,
|
|
@@ -3447,6 +3491,8 @@ export async function apply(ctx, config) {
|
|
|
3447
3491
|
ok: false,
|
|
3448
3492
|
error: error.message,
|
|
3449
3493
|
errorKind: error.kind,
|
|
3494
|
+
errorStage: error.stage,
|
|
3495
|
+
connectionCheckedAt: error.connectionCheckedAt,
|
|
3450
3496
|
retryAfterMs: error.retryAfterMs,
|
|
3451
3497
|
policy: serverPolicy(record),
|
|
3452
3498
|
...cachedFields,
|
|
@@ -3454,7 +3500,8 @@ export async function apply(ctx, config) {
|
|
|
3454
3500
|
continue;
|
|
3455
3501
|
}
|
|
3456
3502
|
const classified = classifyConnectionError(error);
|
|
3457
|
-
servers.push({ serverKey: record.serverKey || record.name, serverName: record.serverName, ok: false, error: classified.message, errorKind: classified.kind,
|
|
3503
|
+
servers.push({ serverKey: record.serverKey || record.name, serverName: record.serverName, ok: false, error: classified.message, errorKind: classified.kind,
|
|
3504
|
+
errorStage: error.stage, connectionCheckedAt: error.connectionCheckedAt, policy: serverPolicy(record), ...cachedFields });
|
|
3458
3505
|
}
|
|
3459
3506
|
}
|
|
3460
3507
|
|
|
@@ -3475,8 +3522,8 @@ export async function apply(ctx, config) {
|
|
|
3475
3522
|
const failedServers = servers.length - availableServers - unknownServers;
|
|
3476
3523
|
const pendingManagedServers = unknownServers;
|
|
3477
3524
|
const cachedServers = servers.filter((server) => server.cached).length;
|
|
3478
|
-
const health = cacheHealth(connectorId, records, servers.map((server) => server.ok
|
|
3479
|
-
? { ok: true, kind: 'connected', serverKey: server.serverKey, serverName: server.serverName }
|
|
3525
|
+
const health = cacheHealth(connectorId, records, servers.map((server) => server.ok || server.connectionCheckedAt !== undefined
|
|
3526
|
+
? { ok: true, kind: 'connected', serverKey: server.serverKey, serverName: server.serverName, checkedAt: server.connectionCheckedAt }
|
|
3480
3527
|
: server.unknown
|
|
3481
3528
|
? {
|
|
3482
3529
|
ok: true,
|
|
@@ -3487,6 +3534,7 @@ export async function apply(ctx, config) {
|
|
|
3487
3534
|
message: server.error,
|
|
3488
3535
|
}
|
|
3489
3536
|
: { ok: false, kind: server.errorKind ?? 'network', serverKey: server.serverKey, serverName: server.serverName, message: server.error }));
|
|
3537
|
+
const discovery = discoveryHealth(connectorId, records, servers);
|
|
3490
3538
|
const failureSummary = servers.filter((server) => !server.ok && !server.unknown).slice(0, 3)
|
|
3491
3539
|
.map((server) => `${server.serverName || server.serverKey}${t(':')}${server.error}`).join(t(';'));
|
|
3492
3540
|
const unknownSummary = servers.filter((server) => server.unknown).slice(0, 3)
|
|
@@ -3518,6 +3566,7 @@ export async function apply(ctx, config) {
|
|
|
3518
3566
|
connectionState: health.connectionState,
|
|
3519
3567
|
lastSuccessfulAt: health.lastSuccessfulAt,
|
|
3520
3568
|
diagnostic: health.diagnostic,
|
|
3569
|
+
discoveryDiagnostic: discovery.diagnostic,
|
|
3521
3570
|
governance: {
|
|
3522
3571
|
revision: governancePolicies.snapshot().revision,
|
|
3523
3572
|
connectionPolicy: directPolicyEffect('connection', connectorId),
|
package/lib/mcp-http.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { MCP_PROTOCOL_VERSION } from './constants.js';
|
|
9
9
|
import { authHeaders } from './mcp-provision.js';
|
|
10
10
|
import { parseRetryAfter } from './discovery-policy.js';
|
|
11
|
+
import { readSseResponse } from './mcp-sse.js';
|
|
11
12
|
import { DEFAULT_LOCALE, createTranslator } from './i18n/index.js';
|
|
12
13
|
|
|
13
14
|
/** 缺省译文:中文(既有调用点与测试无需改动)。 */
|
|
@@ -95,6 +96,20 @@ function requestHeaders(record, grants, { sessionId, protocolVersion } = {}) {
|
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
// A streamable-HTTP response may stay open after the matching JSON-RPC reply
|
|
100
|
+
// (persistent SSE). Consume complete events until that reply arrives instead of
|
|
101
|
+
// waiting for EOF, and ignore notifications / unrelated request ids.
|
|
102
|
+
async function readResponsePayload(response, { id, t = tZh } = {}) {
|
|
103
|
+
const contentType = (response.headers.get('content-type') ?? '').toLowerCase();
|
|
104
|
+
if (id === undefined || !contentType.includes('text/event-stream')) {
|
|
105
|
+
const text = await readLimitedText(response, MAX_RESPONSE_BYTES, { t });
|
|
106
|
+
return { text, payload: parseMcpPayload(text, contentType) };
|
|
107
|
+
}
|
|
108
|
+
return readSseResponse(response, {
|
|
109
|
+
id, maxBytes: MAX_RESPONSE_BYTES, tooLarge: () => new McpHttpError(t('MCP 响应过大')),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
98
113
|
async function post(record, payload, { grants, sessionId, protocolVersion, signal, fetchImpl, t = tZh }) {
|
|
99
114
|
const response = await fetchImpl(record.url, {
|
|
100
115
|
method: 'POST',
|
|
@@ -103,8 +118,7 @@ async function post(record, payload, { grants, sessionId, protocolVersion, signa
|
|
|
103
118
|
signal,
|
|
104
119
|
redirect: 'follow',
|
|
105
120
|
});
|
|
106
|
-
const text = await
|
|
107
|
-
const parsed = parseMcpPayload(text, response.headers.get('content-type') ?? '');
|
|
121
|
+
const { text, payload: parsed } = await readResponsePayload(response, { id: payload?.id, t });
|
|
108
122
|
return { response, text, payload: parsed };
|
|
109
123
|
}
|
|
110
124
|
|
|
@@ -134,6 +148,8 @@ async function listMcpToolsOnce(record, {
|
|
|
134
148
|
const timer = setTimeout(() => controller.abort(new Error('timeout')), timeoutMs);
|
|
135
149
|
let sessionId = '';
|
|
136
150
|
let protocolVersion = MCP_PROTOCOL_VERSION;
|
|
151
|
+
let stage = 'mcp-initialize';
|
|
152
|
+
let connectionCheckedAt;
|
|
137
153
|
try {
|
|
138
154
|
const initialized = await post(record, {
|
|
139
155
|
jsonrpc: '2.0',
|
|
@@ -163,6 +179,8 @@ async function listMcpToolsOnce(record, {
|
|
|
163
179
|
throw responseError(notification.response, notification.payload, notification.text, { t });
|
|
164
180
|
}
|
|
165
181
|
|
|
182
|
+
connectionCheckedAt = Date.now();
|
|
183
|
+
stage = 'tool-discovery';
|
|
166
184
|
const tools = [];
|
|
167
185
|
const seenCursors = new Set();
|
|
168
186
|
let cursor;
|
|
@@ -185,7 +203,7 @@ async function listMcpToolsOnce(record, {
|
|
|
185
203
|
|
|
186
204
|
const nextCursor = listed.payload?.result?.nextCursor;
|
|
187
205
|
if (typeof nextCursor !== 'string' || nextCursor.length === 0) {
|
|
188
|
-
return { tools, protocolVersion, sessionful: Boolean(sessionId), pages: page + 1 };
|
|
206
|
+
return { tools, protocolVersion, sessionful: Boolean(sessionId), pages: page + 1, connectionCheckedAt };
|
|
189
207
|
}
|
|
190
208
|
if (seenCursors.has(nextCursor)) {
|
|
191
209
|
throw new McpHttpError(t('MCP tools/list 返回了重复分页游标'));
|
|
@@ -194,6 +212,12 @@ async function listMcpToolsOnce(record, {
|
|
|
194
212
|
cursor = nextCursor;
|
|
195
213
|
}
|
|
196
214
|
throw new McpHttpError(t('MCP tools/list 分页超过安全上限({maxPages} 页)', { maxPages: MAX_TOOL_PAGES }));
|
|
215
|
+
} catch (error) {
|
|
216
|
+
// Keep transport errors and their causes intact for retry/error classification.
|
|
217
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
218
|
+
failure.stage = stage;
|
|
219
|
+
failure.connectionCheckedAt = connectionCheckedAt;
|
|
220
|
+
throw failure;
|
|
197
221
|
} finally {
|
|
198
222
|
clearTimeout(timer);
|
|
199
223
|
await closeSession(record, { grants, sessionId, protocolVersion, fetchImpl });
|
package/lib/mcp-sse.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** Read the first complete SSE event matching a JSON-RPC request, without waiting for EOF. */
|
|
2
|
+
export async function readSseResponse(response, { id, maxBytes, tooLarge }) {
|
|
3
|
+
if (!response.body) return { text: '', payload: undefined };
|
|
4
|
+
const reader = response.body.getReader();
|
|
5
|
+
const decoder = new TextDecoder();
|
|
6
|
+
let line = '';
|
|
7
|
+
let data = [];
|
|
8
|
+
let skipLF = false;
|
|
9
|
+
let total = 0;
|
|
10
|
+
try {
|
|
11
|
+
for (;;) {
|
|
12
|
+
const { done, value } = await reader.read();
|
|
13
|
+
// EOF does not dispatch an event lacking its final blank line.
|
|
14
|
+
if (done) return { text: '', payload: undefined };
|
|
15
|
+
total += value.byteLength;
|
|
16
|
+
if (total > maxBytes) throw tooLarge();
|
|
17
|
+
const text = decoder.decode(value, { stream: true });
|
|
18
|
+
if (!text) continue;
|
|
19
|
+
let start = skipLF && text.startsWith('\n') ? 1 : 0;
|
|
20
|
+
skipLF = text.endsWith('\r');
|
|
21
|
+
const endings = /\r\n|\r|\n/g;
|
|
22
|
+
endings.lastIndex = start;
|
|
23
|
+
let ending;
|
|
24
|
+
while ((ending = endings.exec(text))) {
|
|
25
|
+
line += text.slice(start, ending.index);
|
|
26
|
+
start = endings.lastIndex;
|
|
27
|
+
if (line === '') {
|
|
28
|
+
const event = data.join('\n');
|
|
29
|
+
data = [];
|
|
30
|
+
let payload;
|
|
31
|
+
try { payload = JSON.parse(event); } catch { continue; }
|
|
32
|
+
if (payload?.jsonrpc === '2.0' && payload.id === id && ('result' in payload || 'error' in payload)) {
|
|
33
|
+
return { text: event, payload };
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
if (line === 'data') data.push('');
|
|
37
|
+
else if (line.startsWith('data:')) data.push(line.slice(5).replace(/^ /, ''));
|
|
38
|
+
line = '';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
line += text.slice(start);
|
|
42
|
+
}
|
|
43
|
+
} finally {
|
|
44
|
+
// A server or stream adapter may never resolve cancellation; do not await it.
|
|
45
|
+
void reader.cancel().catch(() => {});
|
|
46
|
+
reader.releaseLock();
|
|
47
|
+
}
|
|
48
|
+
}
|
package/lib/mcp-validation.js
CHANGED
|
@@ -6,6 +6,7 @@ import { MCP_PROTOCOL_VERSION } from './constants.js';
|
|
|
6
6
|
import { DEFAULT_LOCALE, createTranslator } from './i18n/index.js';
|
|
7
7
|
import { authHeaders } from './mcp-provision.js';
|
|
8
8
|
import { parseRetryAfter } from './discovery-policy.js';
|
|
9
|
+
import { readSseResponse } from './mcp-sse.js';
|
|
9
10
|
|
|
10
11
|
/** 缺省译文:中文(既有调用点与测试无需改动)。 */
|
|
11
12
|
const tZh = createTranslator(DEFAULT_LOCALE);
|
|
@@ -18,34 +19,10 @@ async function readInitializePayload(response, { t }) {
|
|
|
18
19
|
if (!(response.headers.get('content-type') ?? '').toLowerCase().includes('text/event-stream')) {
|
|
19
20
|
return parseMcpPayload(await readLimitedText(response, MAX_RESPONSE_BYTES, { t }));
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
}
|
|
22
|
+
const { payload } = await readSseResponse(response, {
|
|
23
|
+
id: 1, maxBytes: MAX_RESPONSE_BYTES, tooLarge: () => new Error(t('MCP 响应过大')),
|
|
24
|
+
});
|
|
25
|
+
return payload;
|
|
49
26
|
}
|
|
50
27
|
|
|
51
28
|
async function readLimitedText(response, maxBytes = MAX_RESPONSE_BYTES, { t = tZh } = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mcp-connector",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.100",
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"scripts": {
|
|
51
51
|
"test": "node --test",
|
|
52
|
-
"lint": "node --check lib/discovery-policy.js && node --check lib/index.js && node --check lib/web.js && node --check lib/client.js && node --check lib/settings.js && node --check lib/version-status.js && node --check lib/schema.js && node --check lib/catalog.js && node --check lib/prompts.js && node --check lib/probe.js && node --check lib/diagnostics.js && node --check lib/connection-backup.js && node --check lib/shareable-connection-template.js && node --check lib/connection-editor.js && node --check lib/connection-scopes.js && node --check lib/governance.js && node --check lib/session-injection.js && node --check lib/tool-catalog-cache.js && node --check lib/status-events.js && node --check lib/mcp-validation.js && node --check lib/mcp-http.js && node --check lib/migration.js && node --check lib/stores.js && node --check lib/grant-journal.js && node --check lib/oauth.js && node --check lib/grant-lifecycle.js && node --check lib/callback-server.js && node --check lib/mcp-provision.js && node --check lib/stdio-startup-guard.js && node --check lib/cli-providers.js && node --check lib/util.js && node --check lib/constants.js && node --check lib/tools.js && node --check lib/connectors/oauth-connector.js && node --check lib/connectors/manual-connector.js && node --check lib/connectors/json-connector.js && node --check ui/sharing-experience.js && node --check ui/connection-template-sharing.js && node --check scripts/probe-connector.mjs && node --check scripts/cli-bridge.mjs && node --check scripts/build-registry.mjs && node --check scripts/ui-harness.mjs && node --check scripts/check-market-registration.mjs && node --check scripts/check-distribution-sync.mjs && node --check scripts/check-readme-version.mjs && node --check scripts/check-first-use-docs.mjs && node --check scripts/check-marketing-metadata.mjs && node --check scripts/check-storefront-screenshots.mjs && node --check scripts/sync-registry-stats.mjs && node --check scripts/verify-pack.mjs && node --check scripts/check-tutorial-links.mjs",
|
|
52
|
+
"lint": "node --check lib/discovery-policy.js && node --check lib/index.js && node --check lib/web.js && node --check lib/client.js && node --check lib/settings.js && node --check lib/version-status.js && node --check lib/schema.js && node --check lib/catalog.js && node --check lib/prompts.js && node --check lib/probe.js && node --check lib/diagnostics.js && node --check lib/connection-backup.js && node --check lib/shareable-connection-template.js && node --check lib/connection-editor.js && node --check lib/connection-scopes.js && node --check lib/governance.js && node --check lib/session-injection.js && node --check lib/tool-catalog-cache.js && node --check lib/status-events.js && node --check lib/mcp-validation.js && node --check lib/mcp-http.js && node --check lib/mcp-sse.js && node --check lib/migration.js && node --check lib/stores.js && node --check lib/grant-journal.js && node --check lib/oauth.js && node --check lib/grant-lifecycle.js && node --check lib/callback-server.js && node --check lib/mcp-provision.js && node --check lib/stdio-startup-guard.js && node --check lib/cli-providers.js && node --check lib/util.js && node --check lib/constants.js && node --check lib/tools.js && node --check lib/connectors/oauth-connector.js && node --check lib/connectors/manual-connector.js && node --check lib/connectors/json-connector.js && node --check ui/sharing-experience.js && node --check ui/connection-template-sharing.js && node --check scripts/probe-connector.mjs && node --check scripts/cli-bridge.mjs && node --check scripts/build-registry.mjs && node --check scripts/ui-harness.mjs && node --check scripts/check-market-registration.mjs && node --check scripts/check-distribution-sync.mjs && node --check scripts/check-readme-version.mjs && node --check scripts/check-first-use-docs.mjs && node --check scripts/check-marketing-metadata.mjs && node --check scripts/check-storefront-screenshots.mjs && node --check scripts/sync-registry-stats.mjs && node --check scripts/verify-pack.mjs && node --check scripts/check-tutorial-links.mjs",
|
|
53
53
|
"registry:build": "node scripts/build-registry.mjs",
|
|
54
54
|
"registry:validate": "node scripts/probe-connector.mjs catalog/catalog.json --validate-only",
|
|
55
55
|
"dev:ui": "node scripts/ui-harness.mjs",
|
package/ui/index.html
CHANGED
|
@@ -2391,6 +2391,11 @@
|
|
|
2391
2391
|
const explorerStatusLabel = (status) => t(EXPLORER_STATUS[status] || status);
|
|
2392
2392
|
const formatObserved = (value) => value ? new Date(value).toLocaleString(t.locale, { hour12: false }) : t('尚无记录');
|
|
2393
2393
|
|
|
2394
|
+
function explorerDiagnosticsHtml(connection) {
|
|
2395
|
+
return [connection.diagnostic, connection.discoveryDiagnostic].filter(Boolean).map((diagnostic) =>
|
|
2396
|
+
`<div>${t('{stage}:{message}', { stage: esc(diagnostic.stageLabel), message: esc(diagnostic.message) })}<br>${t('建议:{action}', { action: esc(diagnostic.action) })}</div>`).join('');
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2394
2399
|
async function loadToolExplorer() {
|
|
2395
2400
|
const render = beginViewRender();
|
|
2396
2401
|
try {
|
|
@@ -2413,7 +2418,7 @@
|
|
|
2413
2418
|
$('#explorer-server').value = explorerFilter.serverName;
|
|
2414
2419
|
$('#explorer-status').value = explorerFilter.status;
|
|
2415
2420
|
$('#explorer-summary').textContent = t('{scope} · {connections} 条连接 · 匹配 {tools} 个工具 · 显示 {shown} 个', { scope: explorerData.scopeLabel, connections: connections.length, tools: total, shown: items.length });
|
|
2416
|
-
$('#explorer-connections').innerHTML = `<details ${explorerFilter.connectionKey || !total ? 'open' : ''}><summary>${t('连接状态与故障处理({count})', { count: selectedConnections.length })}</summary>${selectedConnections.map((c) => `<div class="explorer-card"><strong>${esc(c.connectionName)}</strong><div>${esc(c.serverName)} · ${esc(explorerStatusLabel(c.status))} · ${t('缓存 {count} 个工具', { count: c.toolCount })}</div><div class="hint">${t('最近发现:{observed};最后成功:{success}{stale}{truncated}', { observed: esc(formatObserved(c.checkedAt)), success: esc(formatObserved(c.observedAt)), stale: c.stale ? t(' · 缓存超过 24 小时') : '', truncated: c.cacheTruncated ? t(' · 缓存清单已截断') : '' })}</div>${
|
|
2421
|
+
$('#explorer-connections').innerHTML = `<details ${explorerFilter.connectionKey || !total ? 'open' : ''}><summary>${t('连接状态与故障处理({count})', { count: selectedConnections.length })}</summary>${selectedConnections.map((c) => `<div class="explorer-card"><strong>${esc(c.connectionName)}</strong><div>${esc(c.serverName)} · ${esc(explorerStatusLabel(c.status))} · ${t('缓存 {count} 个工具', { count: c.toolCount })}</div><div class="hint">${t('最近发现:{observed};最后成功:{success}{stale}{truncated}', { observed: esc(formatObserved(c.checkedAt)), success: esc(formatObserved(c.observedAt)), stale: c.stale ? t(' · 缓存超过 24 小时') : '', truncated: c.cacheTruncated ? t(' · 缓存清单已截断') : '' })}</div>${explorerDiagnosticsHtml(c)}${c.retryReason === 'auth' ? `<p>${t('鉴权失败已暂停后台重试,请到已安装页更新凭据或重新授权。')}</p>` : c.nextDiscoveryAt ? `<p class="hint">${t('下次后台发现不早于:{at}(页面保持连接时)', { at: esc(formatObserved(c.nextDiscoveryAt)) })}</p>` : ''}<div class="m-actions"><button class="btn ghost" data-explorer-action="discover" data-key="${esc(c.connectionKey)}" ${explorerBusy.has(c.connectionKey) ? 'disabled' : ''}>${t('重新发现工具')}</button><button class="btn ghost" data-explorer-action="check" data-key="${esc(c.connectionKey)}" ${explorerBusy.has(c.connectionKey) ? 'disabled' : ''}>${t('检查连接')}</button></div></div>`).join('') || `<p>${t('当前筛选下没有连接。')}</p>`}</details>`;
|
|
2417
2422
|
$('#explorer-results').innerHTML = items.map((item, index) => `<article class="explorer-card"><strong>${esc(item.name)}</strong>${item.title !== item.name ? `<div>${esc(item.title)}</div>` : ''}<p>${esc(item.description || t('暂无描述'))}</p><div class="hint">${t('来源:{connector} / {connection} / {server}', { connector: esc(item.connection.connectorName), connection: esc(item.connection.connectionName), server: esc(item.serverName) })}<br>${esc(explorerStatusLabel(item.connection.status))} · ${t('最后成功缓存 {at}', { at: esc(formatObserved(item.observedAt)) })}${item.stale ? t(' · 已超过 24 小时') : ''}</div><button class="btn ghost" data-explorer-detail="${index}">${t('参数详情')}</button></article>`).join('') || `<p class="empty">${t(connections.length ? '没有匹配工具。请调整关键词或筛选;也可展开连接状态检查是否尚未发现或读取失败。' : '当前范围没有已启用连接。请先添加连接,或选择对应工作区。')}</p>`;
|
|
2418
2423
|
$('#explorer-pages').innerHTML = `<button class="btn ghost" data-explorer-page="prev" ${explorerOffset === 0 ? 'disabled' : ''}>${t('上一页')}</button><span>${Math.floor(explorerOffset / 20) + 1} / ${Math.max(1, Math.ceil(total / 20))}</span><button class="btn ghost" data-explorer-page="next" ${explorerOffset + 20 >= total ? 'disabled' : ''}>${t('下一页')}</button>`;
|
|
2419
2424
|
} finally { finishViewRender(render); }
|
|
@@ -3249,9 +3254,9 @@
|
|
|
3249
3254
|
syncGovernanceBar();
|
|
3250
3255
|
if (!toolsResult.ok) {
|
|
3251
3256
|
detailFailureState = toolsResult.detail?.connectionState || detailFailureState || 'unavailable';
|
|
3252
|
-
detailNeedsReconfigure =
|
|
3257
|
+
detailNeedsReconfigure = detailFailureState !== 'healthy';
|
|
3253
3258
|
detailReconnectKey = detailFailureState === 'unknown' && d.connected?.length > 0 ? d.connected[0] : '';
|
|
3254
|
-
const diagnostic = toolsResult.detail?.diagnostic;
|
|
3259
|
+
const diagnostic = toolsResult.detail?.discoveryDiagnostic || toolsResult.detail?.diagnostic;
|
|
3255
3260
|
$('#tools-summary').textContent = t(detailFailureState === 'unknown' ? '工具状态未知' : '工具加载失败');
|
|
3256
3261
|
const failureHtml = `<div class="tools-error">${esc(toolsResult.message)}${diagnostic ? `<br><br>${esc(t('{stage} · {code}:{message}', { stage: diagnostic.stageLabel || diagnostic.stage, code: diagnostic.code, message: diagnostic.message }))}<br>${esc(t('建议:{action}', { action: diagnostic.action }))}${diagnostic.lastSuccessfulAt ? `<br>${esc(t('最近成功:{at}', { at: new Date(diagnostic.lastSuccessfulAt).toLocaleString(t.locale, { hour12: false }) }))}` : ''}` : ''}</div>`;
|
|
3257
3262
|
detailToolServers = toolsResult.detail?.servers || [];
|
|
@@ -3263,7 +3268,7 @@
|
|
|
3263
3268
|
}
|
|
3264
3269
|
const failureLabel = detailFailureState === 'reauth'
|
|
3265
3270
|
? t(d.authMode === 'oauth2-pkce' ? '授权已失效' : '凭据已失效')
|
|
3266
|
-
: t(detailFailureState === 'unknown' ? '状态尚未确认' : '当前连接异常');
|
|
3271
|
+
: t(detailFailureState === 'healthy' ? '已连接' : detailFailureState === 'unknown' ? '状态尚未确认' : '当前连接异常');
|
|
3267
3272
|
$('#detail-vendor').textContent = d.vendor ? `${d.vendor} · ${failureLabel}` : failureLabel;
|
|
3268
3273
|
$('#detail-try-btn').textContent = detailTryLabel(d.authMode === 'oauth2-pkce' && detailFailureState === 'reauth'
|
|
3269
3274
|
? t('🔐 重新授权')
|
|
@@ -3469,13 +3474,10 @@
|
|
|
3469
3474
|
detailToolServers = result.detail.servers;
|
|
3470
3475
|
renderTools();
|
|
3471
3476
|
const pending = detailToolServers.some((server) => server.pending);
|
|
3472
|
-
|
|
3473
|
-
const
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
: available > 0 ? '部分服务可用' : '当前连接异常');
|
|
3477
|
-
detailFailureState = pending ? 'unknown' : available > 0 ? 'healthy' : 'unavailable';
|
|
3478
|
-
detailNeedsReconfigure = !pending && available === 0;
|
|
3477
|
+
detailFailureState = result.detail.connectionState || 'unknown';
|
|
3478
|
+
const label = t(detailFailureState === 'healthy' ? '已连接' : detailFailureState === 'reauth' ? '凭据已失效'
|
|
3479
|
+
: detailFailureState === 'unknown' ? '状态尚未确认' : detailFailureState === 'degraded' ? '部分服务可用' : '当前连接异常');
|
|
3480
|
+
detailNeedsReconfigure = !pending && detailFailureState !== 'healthy';
|
|
3479
3481
|
detailReconnectKey = '';
|
|
3480
3482
|
$('#detail-vendor').textContent = detailConnector.vendor ? `${detailConnector.vendor} · ${label}` : label;
|
|
3481
3483
|
$('#detail-try-btn').textContent = detailTryLabel(detailNeedsReconfigure ? t('🔄 重新检查') : t('try'));
|