@meshstream/docs-mcp 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,15 @@
1
1
  # MeshStream Docs MCP
2
2
 
3
- 只读 MCP 原型,数据源是官网文档 Markdown。它提供四个工具:
3
+ 只读 MCP,数据源是官网文档 Markdown。它提供文档查询、平台集成规划和公开计费指引:
4
4
 
5
5
  - `search_docs`
6
6
  - `get_sdk_release`
7
7
  - `get_integration_guide`
8
8
  - `get_troubleshooting_guide`
9
+ - `get_document`
10
+ - `get_integration_plan`
11
+ - `get_billing_guidance`
12
+ - `get_platform_matrix`
9
13
 
10
14
  ## 本地运行
11
15
 
@@ -19,4 +23,4 @@ npm start
19
23
  包内的 `content/`,独立安装后无需访问源码仓库;也可以通过 `MESHSTREAM_DOCS_ROOT`
20
24
  指向经过版本锁定的文档快照。
21
25
 
22
- 当前 MCP 只读官网资料,不接收 SDK Key,不访问客户项目文件,也不执行代码或生产操作。
26
+ MCP 只读官网资料,不接收 SDK Key,不访问客户项目文件,也不执行代码或生产操作。
@@ -7,29 +7,130 @@ description: 使用 Codex、Cursor 或 Claude Code,通过官方任务模板完
7
7
 
8
8
  # AI Coding
9
9
 
10
- MeshStream 的 AI Coding 资料让 AI 编辑器基于官方 SDK 文档协助完成接入。当前页面提供可直接复制的任务模板;执行结果仍以本地构建、播放和真实 P2P 互传证据为准。
10
+ MeshStream 的 AI Coding 资料让 AI 编辑器基于官方 SDK 文档协助完成接入。Web、Android、iOS / macOS、Windows、Flutter、React Native 和 uni-app 均可使用同一套 MCP 与 Skills 工作流;执行结果仍以本地构建、播放和真实 P2P 互传证据为准。
11
+
12
+ ## 现在能做什么
13
+
14
+ AI Coding 分成两个层次:MCP 负责查事实和生成结构化集成方案,Skills 负责把方案落到项目工作流。它们都只读取公开文档,不读取客户代码、不接收 SDK Key,也不会替用户发布生产变更。
15
+
16
+ | 能力 | MCP | Skills |
17
+ | --- | --- | --- |
18
+ | 文档、版本和错误码查询 | 支持,返回来源链接 | 支持,要求 AI 先查官方文档 |
19
+ | 按平台、框架、播放器生成接入计划 | `get_integration_plan` | 支持从项目代码识别上下文 |
20
+ | 跑官方 Demo / 从零接入 | 返回步骤和验收清单 | 支持 Codex、Cursor、Claude Code、CodeBuddy |
21
+ | 功能扩展和故障排查 | 返回公开规则 | 保留现有播放器并执行最小改动 |
22
+ | 套餐、配额和用量规则 | `get_billing_guidance` | 引导到公开价格页和控制台 |
23
+ | 平台能力与验收边界 | `get_platform_matrix` | 按平台选择安装、示例和验证范围 |
24
+
25
+ ### 配置 MCP
26
+
27
+ 在支持 MCP 的编辑器中,把下面这一项加入已有的 `mcpServers`,不要覆盖其他服务:
28
+
29
+ ```json
30
+ {
31
+ "meshstream-docs": {
32
+ "command": "npx",
33
+ "args": ["--yes", "@meshstream/docs-mcp@0.3.0"]
34
+ }
35
+ }
36
+ ```
37
+
38
+ 配置后可以直接提问:
39
+
40
+ ```text
41
+ 调用 get_integration_plan,mode=from-zero,为 Vue 3 + hls.js + HLS 点播项目生成 MeshStream 最小接入方案,保留 CDN 回退,并列出真实 P2P 双端验收证据。
42
+ ```
43
+
44
+ ## 平台支持
45
+
46
+ MCP 会根据 `platform`、`framework`、播放器和协议返回对应的安装、接入、高级用法和验收来源。Skills 会先识别当前项目,再选择对应平台的公开 SDK;不会把原生项目降级成 Web 示例。
47
+
48
+ | 平台 | 适用项目 | 官方接入文档 |
49
+ | --- | --- | --- |
50
+ | Web | Vue、React、原生 Web;hls.js、Shaka、dash.js | [Web 安装](./sdk/web-setup.md) · [快速接入](./sdk/web.md) |
51
+ | Android | Kotlin / Java 原生应用 | [Android 安装](./sdk/android-setup.md) · [快速接入](./sdk/android.md) |
52
+ | iOS / macOS | Swift / Objective-C、AVPlayer | [Apple 安装](./sdk/ios-setup.md) · [快速接入](./sdk/ios.md) |
53
+ | Windows | C++ / Windows 原生播放器 | [Windows 安装](./sdk/windows-setup.md) · [快速接入](./sdk/windows.md) |
54
+ | Flutter | Flutter/Dart,调用 iOS 和 Android 原生 SDK | [Flutter 安装](./sdk/flutter-setup.md) · [快速接入](./sdk/flutter.md) |
55
+ | React Native | React Native,调用 iOS 和 Android 原生 SDK | [React Native 安装](./sdk/react-native-setup.md) · [快速接入](./sdk/react-native.md) |
56
+ | uni-app | Vue 3 + UTS,自定义基座或云打包 | [uni-app 安装](./sdk/uniapp-setup.md) · [快速接入](./sdk/uniapp.md) |
57
+
58
+ 可以直接让 MCP 生成其他端方案,例如:
59
+
60
+ ```text
61
+ 调用 get_integration_plan,platform=android,framework=Kotlin,player=Media3,protocol=HLS,mode=from-zero。
62
+ 输出依赖、播放器连接、Android 回环代理配置、CDN 回退,以及两台真实 Android 设备的 P2P 上传/下载字节验收。
63
+ ```
11
64
 
12
65
  ## 快速开始
13
66
 
14
67
  在项目根目录打开 Codex、Cursor 或 Claude Code,先把下面的任务完整粘贴到对话框:
15
68
 
16
69
  ```text
17
- 请在当前项目中集成 MeshStream Web SDK。
70
+ 请在当前项目中集成 MeshStream SDK。
18
71
 
19
72
  执行顺序:
20
- 1. 识别项目框架、播放器、媒体协议和包管理器。
21
- 2. 阅读 MeshStream 官方 Web SDK 安装、快速接入、统计和故障排查文档。
73
+ 1. 识别目标平台、项目框架、播放器、媒体协议、包管理器和现有播放生命周期。
74
+ 2. 阅读该平台对应的 MeshStream 官方安装、快速接入、统计和故障排查文档。
22
75
  3. 使用当前公开渠道可安装的精确 SDK 版本,不猜测不存在的 API、版本或配置项。
23
- 4. 复用现有播放器,不替换源站、CDN、DRM 或业务鉴权。
24
- 5. 保留 CDN 回退,并在播放结束、切源和页面销毁时释放 MeshStream 会话。
25
- 6. 修改代码后运行项目已有的构建和测试命令。
26
- 7. 报告修改文件、实际 SDK 版本、构建结果和仍未验证的事项。
76
+ 4. 复用现有播放器,不替换源站、CDN、DRM 或业务鉴权;原生端使用对应平台的本地播放代理配置。
77
+ 5. 保留 CDN 回退,并在播放结束、切源、页面隐藏或原生控制器销毁时释放 MeshStream 会话。
78
+ 6. 修改代码后运行项目已有的构建和测试命令;移动端优先连接真实设备验证。
79
+ 7. 报告目标平台、修改文件、实际 SDK 版本、构建结果、播放结果和仍未验证的设备/网络条件。
27
80
 
28
81
  如果项目中没有可播放的媒体地址或 SDK Key,先生成需要我补充的清单,不要写入凭据。
29
82
  ```
30
83
 
84
+ ## 原生与跨端项目接入任务
85
+
86
+ Android、iOS / macOS、Windows、Flutter、React Native 和 uni-app 使用相同的任务模式,但必须读取对应平台文档并保留平台播放器生命周期:
87
+
88
+ ```text
89
+ 在当前项目中接入 MeshStream:
90
+
91
+ - 先识别平台、框架、播放器、媒体协议和现有播放控制器。
92
+ - 使用对应平台官方安装页和快速接入页中的精确公开版本。
93
+ - 原生/跨端项目保留现有播放器、DRM、ABR、源站鉴权和 CDN 回退;不要把 Web API 或 Service Worker 代码移植到原生端。
94
+ - Android、iOS / macOS 使用 SDK 返回的本地播放代理地址,并完成对应网络安全配置。
95
+ - Flutter、React Native、uni-app 只调用已发布的原生依赖,不引用本地 AAR、Pod 或内部源码路径。
96
+ - Windows 按官方 C++ 头文件、库和播放器示例接入,检查 x64 架构和关闭释放。
97
+ - 在切源、后台、播放结束和控制器销毁时释放会话与连接。
98
+ - 先运行构建和单元测试,再用真实设备或目标架构验证播放、P2P 上传/下载字节和 CDN 回退。
99
+
100
+ 输出平台、依赖版本、修改文件、构建结果、设备/系统、P2P 双端字节证据、回退结果和未执行项。
101
+ ```
102
+
103
+ ## 已发布工具
104
+
105
+ 官方工具的当前版本为 `0.3.0`,包含结构化集成规划、公开计费指引和 CodeBuddy 支持:
106
+
107
+ - [`@meshstream/agent-skills`](https://www.npmjs.com/package/@meshstream/agent-skills):将接入、排错和 P2P 验收规则安装到 Codex、Cursor 或 Claude Code 项目。
108
+ - [`@meshstream/docs-mcp`](https://www.npmjs.com/package/@meshstream/docs-mcp):只读官方文档 MCP,不读取客户项目文件,也不执行生产操作。
109
+
110
+ 在项目根目录安装编辑器规则:
111
+
112
+ ```bash
113
+ npx --yes @meshstream/agent-skills@0.3.0 add --ide codex
114
+ npx --yes @meshstream/agent-skills@0.3.0 add --ide codebuddy
115
+ ```
116
+
117
+ 在支持 MCP 的编辑器配置中加入:
118
+
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "meshstream-docs": {
123
+ "command": "npx",
124
+ "args": ["--yes", "@meshstream/docs-mcp@0.3.0"]
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
31
130
  ## Web 播放项目接入任务
32
131
 
132
+ 除了从零接入,还可以要求 AI 执行 `demo`、`troubleshooting`、`feature-extension` 或 `docs` 模式。每种模式都必须输出实际运行证据,不能只生成代码就宣称完成。
133
+
33
134
  对于 Vue、React 或原生 Web 项目,可以继续使用这段任务。它要求 AI 保持现有播放器控制权,并验证 P2P 失败时播放仍能继续:
34
135
 
35
136
  ```text
@@ -89,12 +190,12 @@ Peer 数量大于零只代表连接建立。需要两个使用同一内容标识
89
190
  - SDK Key 放在本地环境变量或受限的运行时配置中,不提交仓库。
90
191
  - 签名播放地址、Authorization、Cookie、SecretKey 和生产日志不要粘贴到 AI 对话中。
91
192
  - AI 生成的代码必须经过构建、播放、真实互传、CDN 回退和释放验证后才能上线。
92
- - 当前页面提供任务模板;官方 MCP 和可安装 Skills 会在版本索引、公开包和验收流程稳定后单独发布。
193
+ - 工具源码和发行记录见 [MeshStream AI Tools](https://github.com/Mesh-Stream/meshstream-ai-tools)。
93
194
 
94
195
  ## 下一步
95
196
 
96
197
  - [选择 SDK](./sdk/overview.md)
97
- - [Web SDK 安装与配置](./sdk/web-setup.md)
98
- - [Web SDK 快速接入](./sdk/web.md)
198
+ - [Web SDK 安装与配置](./sdk/web-setup.md) · [Android](./sdk/android-setup.md) · [iOS / macOS](./sdk/ios-setup.md)
199
+ - [Windows](./sdk/windows-setup.md) · [Flutter](./sdk/flutter-setup.md) · [React Native](./sdk/react-native-setup.md) · [uni-app](./sdk/uniapp-setup.md)
99
200
  - [统计与用量](./concepts/statistics.md)
100
201
  - [故障排查](./troubleshooting.md)
package/package.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "name": "@meshstream/docs-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "Read-only MCP server for the MeshStream official developer documentation.",
6
- "repository": { "type": "git", "url": "git+https://github.com/Mesh-Stream/meshstream-ai-tools.git", "directory": "packages/docs-mcp" },
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Mesh-Stream/meshstream-ai-tools.git",
9
+ "directory": "packages/docs-mcp"
10
+ },
7
11
  "homepage": "https://meshstream.net/docs/ai-coding",
8
12
  "type": "module",
9
- "publishConfig": { "access": "public" },
10
- "files": ["src", "content", "README.md"],
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "files": [
17
+ "src",
18
+ "content",
19
+ "README.md"
20
+ ],
11
21
  "scripts": {
12
22
  "prepack": "node scripts/sync-content.mjs",
13
23
  "start": "node src/server.mjs",
package/src/catalog.mjs CHANGED
@@ -14,6 +14,7 @@ const documentFiles = [
14
14
  "intro.md",
15
15
  "quickstart.md",
16
16
  "ai-coding.md",
17
+ "billing/usage.md",
17
18
  "best-practices.md",
18
19
  "troubleshooting.md",
19
20
  "concepts/p2p.md",
@@ -162,3 +163,87 @@ export async function getTroubleshootingGuide(query = "") {
162
163
  related: matches,
163
164
  };
164
165
  }
166
+
167
+ const integrationSources = {
168
+ web: ["sdk/web-setup.md", "sdk/web.md", "sdk/web-advanced.md"],
169
+ android: ["sdk/android-setup.md", "sdk/android.md", "sdk/android-advanced.md"],
170
+ ios: ["sdk/ios-setup.md", "sdk/ios.md", "sdk/ios-advanced.md"],
171
+ macos: ["sdk/ios-setup.md", "sdk/ios.md", "sdk/ios-advanced.md"],
172
+ windows: ["sdk/windows-setup.md", "sdk/windows.md", "sdk/windows-advanced.md"],
173
+ flutter: ["sdk/flutter-setup.md", "sdk/flutter.md", "sdk/flutter-advanced.md"],
174
+ reactnative: ["sdk/react-native-setup.md", "sdk/react-native.md", "sdk/react-native-advanced.md"],
175
+ "react-native": ["sdk/react-native-setup.md", "sdk/react-native.md", "sdk/react-native-advanced.md"],
176
+ uniapp: ["sdk/uniapp-setup.md", "sdk/uniapp.md", "sdk/uniapp-advanced.md"],
177
+ };
178
+
179
+ export async function getIntegrationPlan({ platform = "web", framework = "", player = "", protocol = "", scenario = "", mode = "from-zero" } = {}) {
180
+ const normalizedPlatform = String(platform || "web").trim().toLowerCase();
181
+ const paths = integrationSources[normalizedPlatform] || integrationSources.web;
182
+ const guides = await Promise.all(paths.map(getDocument));
183
+ const normalizedFramework = String(framework || "").trim();
184
+ const normalizedPlayer = String(player || "").trim();
185
+ const normalizedProtocol = String(protocol || "").trim().toUpperCase();
186
+ const normalizedScenario = String(scenario || "").trim();
187
+ const normalizedMode = String(mode || "from-zero").trim().toLowerCase();
188
+ const assumptions = [];
189
+ if (!normalizedFramework) assumptions.push("从项目依赖和入口文件识别框架");
190
+ if (!normalizedPlayer) assumptions.push("保留现有播放器,由 AI 根据项目代码识别播放器");
191
+ if (!normalizedProtocol) assumptions.push("从媒体地址和播放器配置识别 HLS、DASH 或直链协议");
192
+ return {
193
+ request: {
194
+ platform: normalizedPlatform,
195
+ framework: normalizedFramework || undefined,
196
+ player: normalizedPlayer || undefined,
197
+ protocol: normalizedProtocol || undefined,
198
+ scenario: normalizedScenario || undefined,
199
+ },
200
+ assumptions,
201
+ plan: [
202
+ "扫描项目入口、播放器、媒体协议、包管理器和现有鉴权,不覆盖业务代码",
203
+ "安装并锁定公开 SDK 版本,从环境变量读取 SDK Key",
204
+ "创建播放会话,把 SDK 返回的 playbackUrl 交给现有播放器",
205
+ "保留 CDN 回退、ABR、DRM、源站请求头和原有播放器生命周期",
206
+ "在切源、页面隐藏、播放结束和销毁时释放会话与连接",
207
+ "运行项目构建和测试,并输出修改文件、版本和未完成验收项",
208
+ ],
209
+ mode: normalizedMode,
210
+ modeSteps: {
211
+ "from-zero": ["确认 SDK 与播放器边界", "生成最小播放接入", "执行构建、播放和双端 P2P 验收"],
212
+ demo: ["定位对应平台的公开示例", "只配置本地环境变量和测试媒体", "运行示例并记录播放、P2P、回退和释放结果"],
213
+ troubleshooting: ["复现并收集错误码和时间线", "检查 Key、bootstrap、Tracker、ICE、分片命中和回退", "给出证据、修复动作和复测命令"],
214
+ "feature-extension": ["读取当前集成和生命周期", "只修改实现目标功能所需的文件", "补齐针对功能的测试和回退验收"],
215
+ docs: ["先用公开文档和版本表回答", "每个结论附来源 URL", "不确定时明确标记未知,不编造 API"],
216
+ }[normalizedMode] || ["先确认任务模式", "按官方平台文档生成方案", "输出构建和验收证据"],
217
+ p2pAcceptance: [
218
+ "使用相同 contentId、内容和清晰度启动发送端与接收端",
219
+ "记录首个 Peer、首个 P2P 字节、P2P 下载、P2P 上传、CDN 字节和 rebuffer",
220
+ "只有接收端下载与发送端上传同时增长才算真实 P2P 通过",
221
+ "停止或阻断 P2P 后验证 CDN 回退,最后验证 dispose/close 释放连接",
222
+ ],
223
+ sources: guides.map(({ path: sourcePath, title, url }) => ({ path: sourcePath, title, url })),
224
+ starterPrompt: `在当前${normalizedPlatform}项目中执行${normalizedMode}任务:${normalizedScenario || "接入 MeshStream P2P 媒体加速"}。已知上下文:框架=${normalizedFramework || "待识别"},播放器=${normalizedPlayer || "待识别"},协议=${normalizedProtocol || "待识别"}。先识别并确认上下文,再按官方文档生成最小改动方案。保留现有播放器、CDN、DRM、ABR 和源站鉴权;SDK Key 只能从环境变量读取;输出修改文件、精确依赖版本、构建结果、CDN 回退和真实 P2P 双端证据。`,
225
+ };
226
+ }
227
+
228
+ export function getPlatformMatrix() {
229
+ return {
230
+ platforms: Object.keys(integrationSources).map((platform) => ({
231
+ platform,
232
+ sources: integrationSources[platform].map((path) => ({ path, url: `https://meshstream.net/docs/${path.replace(/\.md$/, "")}` })),
233
+ capabilities: ["playback session", "CDN fallback", "P2P statistics", "lifecycle release"],
234
+ })),
235
+ acceptanceRule: "Peer count or WebSocket connection alone is not P2P proof; receiver download and sender upload bytes must both increase.",
236
+ };
237
+ }
238
+
239
+ export async function getBillingGuidance(query = "") {
240
+ const usage = await getDocument("billing/usage.md");
241
+ const matches = query ? await searchDocs(query, 5) : [];
242
+ return {
243
+ source: { path: usage.path, title: usage.title, url: usage.url },
244
+ pricingUrl: "https://meshstream.net/pricing",
245
+ guidance: usage.text,
246
+ related: matches,
247
+ note: "套餐、额度和用量只返回公开规则;实时余额、订单和支付状态请在控制台查看。",
248
+ };
249
+ }
package/src/server.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { z } from "zod";
5
- import { getIntegrationGuide, getSdkRelease, getTroubleshootingGuide, searchDocs } from "./catalog.mjs";
5
+ import { getBillingGuidance, getDocument, getIntegrationGuide, getIntegrationPlan, getPlatformMatrix, getSdkRelease, getTroubleshootingGuide, searchDocs } from "./catalog.mjs";
6
6
 
7
7
  const server = new McpServer({ name: "meshstream-docs", version: "0.1.0" });
8
8
 
@@ -40,4 +40,35 @@ server.registerTool("get_troubleshooting_guide", {
40
40
  },
41
41
  }, async ({ query }) => result(await getTroubleshootingGuide(query)));
42
42
 
43
+ server.registerTool("get_document", {
44
+ description: "Read one public MeshStream documentation page by its relative path. Read-only.",
45
+ inputSchema: {
46
+ path: z.string().min(1).describe("Relative path such as sdk/web.md or billing/usage.md"),
47
+ },
48
+ }, async ({ path }) => result(await getDocument(path)));
49
+
50
+ server.registerTool("get_integration_plan", {
51
+ description: "Create a structured, platform-aware MeshStream integration and P2P acceptance plan. Read-only; it does not edit customer files or use credentials.",
52
+ inputSchema: {
53
+ platform: z.string().optional().describe("web, android, ios, macos, windows, flutter, react-native, or uniapp"),
54
+ framework: z.string().optional().describe("Framework such as Vue, React, Flutter, or native"),
55
+ player: z.string().optional().describe("Existing media player such as hls.js, Shaka, Media3, or AVPlayer"),
56
+ protocol: z.string().optional().describe("HLS, DASH, MP4, or another actual media protocol"),
57
+ scenario: z.string().optional().describe("Scenario such as live playback, VOD, or add CDN fallback"),
58
+ mode: z.enum(["from-zero", "demo", "troubleshooting", "feature-extension", "docs"]).optional().describe("Task mode"),
59
+ },
60
+ }, async (args) => result(await getIntegrationPlan(args)));
61
+
62
+ server.registerTool("get_platform_matrix", {
63
+ description: "Return the supported MeshStream platform matrix and shared acceptance rules. Read-only.",
64
+ inputSchema: {},
65
+ }, async () => result(getPlatformMatrix()));
66
+
67
+ server.registerTool("get_billing_guidance", {
68
+ description: "Explain public MeshStream quota and plan rules and point to the pricing page. Read-only; it does not access account balance or place orders.",
69
+ inputSchema: {
70
+ query: z.string().optional().describe("Optional billing or quota question"),
71
+ },
72
+ }, async ({ query }) => result(await getBillingGuidance(query)));
73
+
43
74
  await server.connect(new StdioServerTransport());