Skip to content

调整mcp描述#70

Open
liuzhe910422 wants to merge 3 commits into
qiniu:mainfrom
liuzhe910422:mcp
Open

调整mcp描述#70
liuzhe910422 wants to merge 3 commits into
qiniu:mainfrom
liuzhe910422:mcp

Conversation

@liuzhe910422

Copy link
Copy Markdown
Contributor

调整mcp描述

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for the Model Context Protocol (MCP) interaction guide and the camera feature guide. It details the dynamic configuration of the visual analysis interface, refactors the MCP interaction guide to clarify message structures, schemas, and error handling, and replaces C++ registration examples with general JSON-based guidelines. The review feedback points out a broken Markdown anchor link in the camera feature guide, an inconsistency regarding the outer-layer session_id between the two documents, and a recommendation to unify the data type of the tools[].type field to simplify JSON deserialization in statically typed languages.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

### 4. 视觉分析接口

设备端将捕获的图片发送到视觉分析接口(可通过mcp里面的capabilities获取url以及token):
设备端将捕获的图片发送到视觉分析接口。接口地址和鉴权 token 由平台在 MCP 初始化阶段下发,请以 `initialize` 消息中的 `capabilities.vision.url` 和 `capabilities.vision.token` 为准,详见 [MCP 初始化能力字段](../mcp/hardware-mcp.md#步骤2初始化-mcp-会话)。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

hardware-mcp.md 中,对应的标题为 ### 步骤2:初始化 MCP 会话(冒号后包含一个空格)。在 GitHub Markdown 渲染时,全角冒号会被移除,而空格会被转换为连字符 -,因此生成的锚点为 #步骤2-初始化-mcp-会话。当前链接中缺失了 步骤2初始化 之间的连字符,会导致点击链接时无法正确跳转。建议修改为:\n\n设备端将捕获的图片发送到视觉分析接口。接口地址和鉴权 token 由平台在 MCP 初始化阶段下发,请以 initialize消息中的capabilities.vision.urlcapabilities.vision.token 为准,详见 [MCP 初始化能力字段](../mcp/hardware-mcp.md#步骤2-初始化-mcp-会话)。

注意事项:

- 当前协议只解析 `payload` 字段,不解析旧字段 `data`。
- MCP 外层不携带 `session_id`。`session_id` 只会出现在平台返回的基础协议 `hello`、`stt`、`tts`、`llm` 等消息中。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

文档中提到 “MCP 外层不携带 session_id,但在另一篇文档 docs/xrobot/guide/camera-feature.md 的第 90 行 MCP 响应示例中,外层依然保留了 "session_id": "XXXXXX" 字段。这会导致两处文档不一致,可能会给开发者带来困惑。建议后续将 camera-feature.md 中的示例也同步更新,移除外层的 session_id 字段。

| `tools` | array | 是 | 工具列表。缺失或不是数组会导致本次 MCP 初始化失败 |
| `tools[].name` | string | 是 | 设备端原始工具名。为空会被跳过 |
| `tools[].description` | string | 否 | 工具说明,会提供给大模型理解工具用途 |
| `tools[].inputSchema` | object | 否 | JSON Schema。缺失时平台按 `{"type":"object"}` 处理 |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

在 API 协议设计中,同一个字段 tools[].type 同时支持 numberstring 混合类型(如 0 / 1"rpc")会增加强类型语言(如 C/C++、Go、Java 等设备端或服务端常用语言)在进行 JSON 反序列化时的复杂度。建议在文档中推荐一种首选类型(例如统一使用 string 类型,如 "tool""rpc",或者统一使用 number),以简化双端的解析与实现逻辑。

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review found one documentation accuracy issue in the updated MCP error schema.

Comment thread docs/xrobot/mcp/hardware-mcp.md Outdated
| `payload.method` | string | request/notification 必填 | 方法名,如 `initialize`、`tools/list`、`tools/call` |
| `payload.params` | object | request/notification 可选 | 方法参数 |
| `payload.result` | any | success response 必填 | 成功响应结果 |
| `payload.error` | object/string | error response 必填 | 失败响应错误信息 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table now says payload.error may be object/string, and the generic schema above shows error.code as a string placeholder. Because this page says MCP follows JSON-RPC 2.0, implementers copying this will produce invalid error responses: JSON-RPC errors must be an object with a numeric code and string message. Please keep the schema/table aligned with that shape so devices don't send errors the platform or standard JSON-RPC clients may reject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant