@tencent-rtc/mcp 1.7.5 → 1.7.7

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +60 -52
  3. package/index.js +23 -1
  4. package/knowledge/chunker.js +1 -0
  5. package/knowledge/path-meta.js +12 -1
  6. package/knowledge/search/search-core.js +22 -4
  7. package/knowledge/search/search-knowledge.js +1 -1
  8. package/package.json +1 -1
  9. package/resource/index/manifest.json +1 -1
  10. package/server-config.js +20 -6
  11. package/server.js +35 -29
  12. package/tools/common/get_usersig.js +1 -1
  13. package/tools/definitions/get_native_call_uikit_integration_def.js +13 -7
  14. package/tools/definitions/get_native_callkit_core_integration_def.js +42 -31
  15. package/tools/definitions/get_native_chat_uikit_integration_def.js +11 -4
  16. package/tools/definitions/get_native_live_uikit_integration_def.js +21 -15
  17. package/tools/definitions/get_native_livekit_core_integration_def.js +11 -4
  18. package/tools/definitions/get_usersig_def.js +18 -11
  19. package/tools/definitions/get_web_call_uikit_integration_def.js +11 -4
  20. package/tools/definitions/get_web_chat_uikit_integration_def.js +11 -4
  21. package/tools/definitions/get_web_live_uikit_integration_def.js +11 -4
  22. package/tools/definitions/get_web_room_core_integration_def.js +16 -13
  23. package/tools/definitions/get_web_room_uikit_integration_def.js +11 -4
  24. package/tools/definitions/integration-boundary.js +9 -5
  25. package/tools/definitions/present_framework_choice_def.js +20 -20
  26. package/tools/definitions/search_trtc_knowledge_def.js +47 -27
  27. package/tools/definitions/submit_feedback_def.js +18 -14
  28. package/utils/normalize-error.js +13 -0
  29. package/utils/report-cls-client.js +2 -2
  30. package/utils/report-es-client.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Version 1.7.7 @2026.09.11
4
+
5
+ ### Changed
6
+ - Optimized MCP connection stability and observability, improving exception troubleshooting and runtime diagnostics.
7
+
8
+ ## Version 1.7.6 @2026.09.09
9
+
10
+ ### Changed
11
+ - Cleaned traffic-entry content in the knowledge base to reduce retrieval noise.
12
+ - Refactored tool definitions: unified invocation boundaries, trigger semantics, and template structures across tools.
13
+ - Adjusted global Workflow semantics to be consultation-flow-only, reducing tool-routing ambiguity.
14
+
15
+ ### Fixed
16
+ - Fixed boundary conflicts and inconsistent parameter wording in some integration tool definitions (for example, `get_native_callkit_core_integration`), improving invocation stability.
17
+
3
18
  ## Version 1.7.5 @2026.09.04
4
19
 
5
20
  ### Changed
package/README.md CHANGED
@@ -1,25 +1,25 @@
1
- ## Tencent RTC SDK MCP Server Guide
1
+ ## Tencent RTC SDK MCP Server
2
2
 
3
- This repository provides a CLI-based Model Context Protocol (MCP) Server that exposes Tencent RTC SDK documentation and API resources to LLM tools, helping AI agents deliver more accurate implementation guidance and integration support.
3
+ Tencent RTC SDK MCP Server exposes official Tencent Cloud RTC knowledge and integration capabilities to AI assistants through MCP (Model Context Protocol), helping teams deliver Chat/Call/Live/Room/RTCEngine/TIMPush implementations faster.
4
4
 
5
- ## Features
5
+ ## Highlights
6
6
 
7
- - **Efficient retrieval**: Supports Tencent RTC documentation retrieval for fast access to official references and best practices.
8
- - **Broad coverage**: Covers Chat (IM), Call, Live, Room, RTCEngine (TRTC SDK), and TIMPush domains.
9
- - **Intelligent routing**: Supports product/platform intent disambiguation and prompts for missing platform/framework information when needed.
10
- - **Integration-friendly**: In addition to documentation Q&A, provides integration entry points for Web / Android / iOS / Flutter, including UI-based integration directions.
11
- - **Reliable source**: Grounded in official Tencent Cloud materials to improve answer reliability and implementation readiness.
12
- - **Wide compatibility**: Exposes MCP capabilities over STDIN/STDOUT JSON-RPC, compatible with MCP clients such as Cursor / Codex / Claude / CodeBuddy.
13
- - **Quick start**: Run with `npx` and get started with minimal setup.
7
+ - **Official knowledge retrieval**: Quickly locate product docs, integration guides, and best practices.
8
+ - **Intent-aware routing**: Routes by product, platform, and framework to reduce retrieval noise.
9
+ - **Integration generation support**: Supports Web / Android / iOS / Flutter integration entry points.
10
+ - **MCP compatible**: Works with Cursor, CodeBuddy, Codex, Claude, and other MCP clients.
14
11
 
15
12
  ## Requirements
16
- - Node.js (>= 18) and npm
17
- - An MCP-capable IDE
18
13
 
19
- ## Usage
20
- ### Standard setup flow
14
+ - Node.js >= 18
15
+ - npm
16
+ - Any MCP-capable IDE / AI client
21
17
 
22
- - Step1: In your Cursor project, create or edit `.cursor/mcp.json` or `~/.cursor/mcp.json` and add the following configuration.
18
+ ## 30-Second Quick Start (No console app creation required)
19
+
20
+ ### 1) Configure MCP Server (Trial mode)
21
+
22
+ Using Cursor as an example, add this to your project `.cursor/mcp.json` (or `~/.cursor/mcp.json`):
23
23
 
24
24
  ```json
25
25
  {
@@ -28,67 +28,75 @@ This repository provides a CLI-based Model Context Protocol (MCP) Server that ex
28
28
  "command": "npx",
29
29
  "args": ["-y", "@tencent-rtc/mcp@latest"],
30
30
  "env": {
31
- "SDKAPPID": "YOUR_SDKAPPID",
32
- "SECRETKEY": "YOUR_SECRET_KEY"
31
+ "SDKAPPID": "",
32
+ "SECRETKEY": ""
33
33
  }
34
34
  }
35
35
  }
36
36
  }
37
37
  ```
38
- After saving, a prompt appears. Click **Enable** in the prompt.
39
38
 
40
- ![mcp-server-prompt](https://web.sdk.qcloud.com/im/assets/images/mcp-server-prompt-en.png)
39
+ ### 2) Confirm server is connected
41
40
 
42
- - Step2: Go to **Cursor Settings** (top-right gear icon) -> **MCP**, and make sure `tencent-rtc` is enabled.
41
+ In your MCP panel, ensure `tencent-rtc` shows **Connected**.
43
42
 
44
- ![cursor-setting](https://web.sdk.qcloud.com/im/assets/images/cursor-setting-en.png)
43
+ ### 3) Explicitly trigger tools
45
44
 
46
- - Step3: Describe your requirements directly in the IDE, and let the AI complete implementation or troubleshooting based on Tencent Cloud SDK documentation.
45
+ For higher tool activation rate and more stable results, prefix your prompt with `@tencent-rtc`.
47
46
 
48
- ### Optional: global install
47
+ Example:
49
48
 
50
- If you want quick global invocation locally, run:
49
+ ```text
50
+ @tencent-rtc How do I send an audio message when integrating the Web IM SDK in H5?
51
+ ```
52
+
53
+ ## Full Configuration (Requires creating an app in console)
51
54
 
52
- ```bash
53
- npx -y @tencent-rtc/mcp
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "tencent-rtc": {
59
+ "command": "npx",
60
+ "args": ["-y", "@tencent-rtc/mcp@latest"],
61
+ "env": {
62
+ "SDKAPPID": "YOUR_SDKAPPID",
63
+ "SECRETKEY": "YOUR_SECRET_KEY"
64
+ }
65
+ }
66
+ }
67
+ }
54
68
  ```
55
69
 
56
- ## Changelog
70
+ Console entries: `https://console.trtc.io`
57
71
 
58
- > Only recent updates are listed here. For full history, see `CHANGELOG.md`.
72
+ ## Prerequisites
59
73
 
60
- ## Version 1.7.5 @2026.09.04
74
+ - **No account / no app yet? You can still try first**: Start with document retrieval and knowledge Q&A in trial mode.
75
+ - `SDKAPPID`: Your IM/TRTC application ID from Tencent Cloud console.
76
+ - `SECRETKEY`: Used for local/test `userSig` generation.
77
+ - **Production requirement**: `userSig` must be generated by your server-side service.
61
78
 
62
- ### Changed
63
- - Refactored the `preflight-route` decision model to an **agent-first, minimal-correction** strategy: prioritize agent-provided `product/frameworks`, and use prompt signals only for high-confidence corrections and narrowing to avoid unsupported expansion.
64
- - Optimized framework-axis conflict handling: added/enhanced strong-lock strategies for `react-native` and `miniprogram`, and in strong-lock scenarios, separated host environment (`android/ios`) from the actual framework to reduce over-narrowing.
65
- - Optimized native TRTC correction: when the prompt matches native TRTC classes/methods and no WebRTC hard signal is present, narrow `rtcengine` to `native_trtc_sdk` to reduce web/native cross-routing risk.
79
+ ## Common Issues
66
80
 
67
- ### Fixed
68
- - Fixed over-overriding of agent results when strong framework terms are only passively mentioned, reducing false corrections triggered by doc-enumeration terms.
81
+ - **Connection failed / tool not activated**: Verify MCP config and Connected status.
82
+ - **`npx` failures**: Retry after cache cleanup: `rm -rf ~/.npm/_npx && npm cache verify`.
83
+ - **Invalid `userSig`**: Regenerate via `get_usersig`.
69
84
 
70
- ## Version 1.7.4 @2026.08.31
85
+ ## Changelog
71
86
 
72
- ### Added
73
- - Added 4 CallKit Flutter best-practice docs: Android background call keep-alive, iOS background audio keep-alive, iOS startup crash troubleshooting, background incoming call notification troubleshooting.
74
- - Added CallKit Android video chat dating scenario (VideoChat Demo) best-practice doc, covering Demo setup and component quick integration.
75
- - Added CallKit HarmonyOS platform support: UIKit integration guide and API reference.
76
- - Added CallKit Mini Program & uni-app docs: UIKit integration guide, API reference, uni-app packaging guide.
77
- - Added CallKit uni-app (Android/iOS) standalone integration docs and API reference.
78
- - Added Chat Vue3/React H5 mobile integration docs.
87
+ > Only the latest release is shown here. See `CHANGELOG.md` for full history.
79
88
 
80
- ### Changed
81
- - Optimized Chat UIKit search tags: vue/react framework changed from single tag to dual tags (`['vue','web']` / `['react','web']`), allowing `frameworks=['web']` to match Chat Web docs.
89
+ ## Version 1.7.7 @2026.09.11
82
90
 
83
- ## Version 1.7.3 @2026.08.17
91
+ ### Changed
92
+ - Optimized MCP connection stability and observability, improving exception troubleshooting and runtime diagnostics.
84
93
 
85
- ### Added
86
- - Added knowledge base resources for RoomKit multi-platform integration, recording, whiteboard, network proxy, AI noise reduction, and subtitle translation, expanding coverage of the Room product domain.
87
- - Added best-practice docs covering error codes, log levels, automatic screen-share stop, and WeChat Mini Program error troubleshooting.
88
- - Added a generic additive rerank module with anchor selection and phrase extraction, integrated into the search reranking logic to improve recall ranking accuracy.
94
+ ## Version 1.7.6 @2026.09.09
89
95
 
90
96
  ### Changed
91
- - Optimized the BM25 index to use prototype-less objects, improving the isolation and stability of the index structure.
97
+ - Cleaned traffic-entry content in the knowledge base to reduce retrieval noise.
98
+ - Refactored tool definitions: unified invocation boundaries, trigger semantics, and template structures across tools.
99
+ - Adjusted global Workflow semantics to be consultation-flow-only, reducing tool-routing ambiguity.
92
100
 
93
101
  ### Fixed
94
- - Fixed BM25 scoring anomalies caused by prototype-key pollution by adding prototype-key guards, preventing score pollution and NaN issues.
102
+ - Fixed boundary conflicts and inconsistent parameter wording in some integration tool definitions (for example, `get_native_callkit_core_integration`), improving invocation stability.
package/index.js CHANGED
@@ -2,15 +2,37 @@
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
3
  import { createServer } from './server.js';
4
4
  import { ServerConfig } from './server-config.js';
5
+ import { normalizeError } from './utils/normalize-error.js';
6
+ import { reportCLSClient } from './utils/report-cls-client.js';
5
7
  // 启动服务器
8
+ let startTime = 0;
6
9
  async function main() {
10
+ startTime = Date.now();
7
11
  ServerConfig.getInstance();
8
12
  const server = createServer();
9
13
  const transport = new StdioServerTransport();
10
14
  await server.connect(transport);
11
15
  console.error('RTC Official MCP Server running on stdio');
12
16
  }
13
- main().catch((error) => {
17
+ main().then(() => {
18
+ reportCLSClient({
19
+ method: 'mcp_connect_success',
20
+ from: 'stdio',
21
+ info: JSON.stringify({
22
+ status: 'success',
23
+ latency_ms: Date.now() - startTime,
24
+ }),
25
+ });
26
+ }).catch((error) => {
27
+ reportCLSClient({
28
+ method: 'mcp_connect_fail',
29
+ from: 'stdio',
30
+ info: JSON.stringify({
31
+ status: 'fail',
32
+ latency_ms: Date.now() - startTime,
33
+ ...normalizeError(error),
34
+ }),
35
+ });
14
36
  console.error('Server error:', error);
15
37
  process.exit(1);
16
38
  });
@@ -125,6 +125,7 @@ function buildChunk(meta, source, title, body, id, char_start, char_end, extra)
125
125
  types: meta.types,
126
126
  scenario: meta.scenario,
127
127
  variant: meta.variant,
128
+ platform: meta.platform,
128
129
  scope: meta.scope,
129
130
  doc_kind: meta.doc_kind,
130
131
  capability_status: meta.capability_status,
@@ -65,6 +65,7 @@ export function inferPathMeta(relativeSource) {
65
65
  let types = corpus === 'integration' ? ['integration'] : [];
66
66
  let scenario = null;
67
67
  let variant;
68
+ let platform;
68
69
  let doc_kind;
69
70
  let capability_status;
70
71
  let retrievable_scope;
@@ -78,10 +79,19 @@ export function inferPathMeta(relativeSource) {
78
79
  else if (normalized.startsWith('knowledge/chat/') || normalized.startsWith('integration/chat/')) {
79
80
  product = 'chat';
80
81
  if (parts.includes('preset') && parts.length >= 4) {
81
- const fw = normalizeFrameworkDir(parts[parts.indexOf('preset') + 1]);
82
+ const presetIdx = parts.indexOf('preset');
83
+ const fw = normalizeFrameworkDir(parts[presetIdx + 1]);
84
+ const platformSegment = String(parts[presetIdx + 2] ?? '').toLowerCase();
82
85
  // vue/react 运行在 Web/H5 端,追加 web 标签,使 frameworks=['web'] 也能命中
83
86
  framework = (fw === 'vue' || fw === 'react') ? [fw, 'web'] : [fw];
84
87
  variant = 'preset';
88
+ // 仅在显式 h5/mobile 路径时标记为移动网页;默认按 desktop 处理,避免误伤 native 路由
89
+ if (platformSegment === 'h5' || platformSegment === 'mobile') {
90
+ platform = 'mobile';
91
+ }
92
+ else {
93
+ platform = 'desktop';
94
+ }
85
95
  // preset 下的 integration.md 显式标记 integration type
86
96
  if (fileName.toLowerCase() === 'integration.md') {
87
97
  types.push('integration');
@@ -371,6 +381,7 @@ export function inferPathMeta(relativeSource) {
371
381
  scenario,
372
382
  corpus,
373
383
  variant,
384
+ platform,
374
385
  scope,
375
386
  doc_kind,
376
387
  capability_status,
@@ -151,16 +151,24 @@ export function sourceTitle(source) {
151
151
  const base = source.split('/').pop()?.replace(/\.md$/i, '') ?? source;
152
152
  return base || source;
153
153
  }
154
- export function pickNarrativeSource(_exactHits, ranked, poolWithContent) {
154
+ function detectH5Intent(prompt) {
155
+ return /(\bh5\b|移动端网页|手机网页|mobile\s*web|web\s*mobile)/i.test(prompt);
156
+ }
157
+ function hasNativeIntent(prompt) {
158
+ return /(android|ios|flutter|react\s*native|react-native|uni-?app|harmonyos|鸿蒙|原生|小程序|miniprogram)/i.test(prompt);
159
+ }
160
+ export function pickNarrativeSource(prompt, ranked, poolWithContent) {
155
161
  const bySource = new Map();
156
162
  const chunksById = new Map(poolWithContent.map((chunk) => [chunk.id, chunk]));
157
- const upsertSource = (source, score, weight) => {
163
+ const h5BoostEnabled = detectH5Intent(prompt) && !hasNativeIntent(prompt);
164
+ const upsertSource = (source, score, weight, platform) => {
158
165
  const prev = bySource.get(source);
159
166
  if (!prev) {
160
167
  bySource.set(source, {
161
168
  hitCount: 1,
162
169
  bestScore: score,
163
170
  weightedScore: score * weight,
171
+ platform,
164
172
  });
165
173
  return;
166
174
  }
@@ -168,6 +176,7 @@ export function pickNarrativeSource(_exactHits, ranked, poolWithContent) {
168
176
  hitCount: prev.hitCount + 1,
169
177
  bestScore: Math.max(prev.bestScore, score),
170
178
  weightedScore: prev.weightedScore + score * weight,
179
+ platform: prev.platform ?? platform,
171
180
  });
172
181
  };
173
182
  const topScore = ranked[0]?.score ?? 0;
@@ -178,12 +187,21 @@ export function pickNarrativeSource(_exactHits, ranked, poolWithContent) {
178
187
  continue;
179
188
  if (topScore > 0 && idx > 120 && item.score < topScore * 0.03)
180
189
  break;
181
- const weight = idx < 20 ? 1 : idx < 80 ? 0.7 : 0.5;
182
- upsertSource(chunk.source, item.score, weight);
190
+ let weight = idx < 20 ? 1 : idx < 80 ? 0.7 : 0.5;
191
+ if (h5BoostEnabled && chunk.platform === 'mobile') {
192
+ weight *= 1.3;
193
+ }
194
+ upsertSource(chunk.source, item.score, weight, chunk.platform);
183
195
  }
184
196
  const candidates = [...bySource.entries()].sort((a, b) => {
185
197
  if (b[1].weightedScore !== a[1].weightedScore)
186
198
  return b[1].weightedScore - a[1].weightedScore;
199
+ if (h5BoostEnabled && a[1].platform !== b[1].platform) {
200
+ if (a[1].platform === 'mobile')
201
+ return 1;
202
+ if (b[1].platform === 'mobile')
203
+ return -1;
204
+ }
187
205
  if (b[1].hitCount !== a[1].hitCount)
188
206
  return b[1].hitCount - a[1].hitCount;
189
207
  return b[1].bestScore - a[1].bestScore;
@@ -340,7 +340,7 @@ export function searchKnowledge(params) {
340
340
  }
341
341
  const resolveNarrativeState = (passSnapshot) => {
342
342
  const source = retrievalMode === 'narrative'
343
- ? pickNarrativeSource(passSnapshot.exactHits, passSnapshot.rankedWithMultipliers, passSnapshot.poolWithContent)
343
+ ? pickNarrativeSource(norm.prompt, passSnapshot.rankedWithMultipliers, passSnapshot.poolWithContent)
344
344
  : null;
345
345
  const document = source ? buildNarrativeDocument(source, allChunks) : null;
346
346
  const quality = assessNarrativeCompleteness(document, norm.prompt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tencent-rtc/mcp",
3
- "version": "1.7.5",
3
+ "version": "1.7.7",
4
4
  "description": "Tencent Cloud MCP Server for SDK",
5
5
  "type": "module",
6
6
  "main": "index.js",