Skip to content

Conversation

@syureyi
Copy link
Collaborator

@syureyi syureyi commented Nov 27, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @syureyi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求主要侧重于改进MCP(模型上下文协议)和WebSocket通信的文档。它优化了MCP文档的结构,通过添加一个type字段引入了一种更灵活、信息更丰富的设备工具发现响应格式,并为WebSocket协议添加了一种新的Notify消息类型,以处理连接设备的配置更新通知。这些更改旨在提高清晰度、扩展功能并为与协议交互的开发人员提供更好的指导。

Highlights

  • MCP协议文档结构优化: 调整了MCP协议文档的目录结构,使其更清晰,并增加了流程图、整体消息结构和JSON-RPC字段说明等新章节。
  • 设备工具列表响应格式增强: 为MCP协议的设备工具列表发现功能引入了新的响应格式,该格式包含一个type字段,用于区分标准tool函数和rpc函数,并提供了向后兼容的标准格式说明。
  • 新增WebSocket Notify消息: 在WebSocket协议中增加了Notify消息类型,用于通知设备配置更新事件,建议设备在收到此类通知后重新连接。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

本次 PR 更新了 MCP 协议文档,增加了对工具类型的支持,并补充了 WebSocket 的 Notify 消息。整体改动清晰,但存在一些小问题。在 hardware-mcp.md 中,目录部分存在重复项,并且一处 JSON 示例包含了无效的占位符,建议修正以提高文档的准确性和可读性。

## 目录

- [概述](#概述)
- [目录](#目录)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

目录中存在一个指向自身的重复链接 [目录](#目录)。这会造成困惑,建议移除此多余条目。

{
"name": "self.get_device_status",
"description": "获取设备当前状态信息",
"type": <int>, // 函数类型,0 表示 tool 函数,1 表示 rpc 函数
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

在响应格式二的 JSON 示例中,type 字段的值为 <int>,这是一个占位符,不是有效的 JSON 值。为了使示例清晰且可直接使用,建议将其替换为一个具体的示例值,例如 1

Suggested change
"type": <int>, // 函数类型,0 表示 tool 函数,1 表示 rpc 函数
"type": 1, // 函数类型,0 表示 tool 函数,1 表示 rpc 函数

{
"name": "self.get_device_status",
"description": "获取设备当前状态信息",
"type": <int>, // 函数类型,0 表示 tool 函数,1 表示 rpc 函数
Copy link

Choose a reason for hiding this comment

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

Invalid JSON Syntax

The placeholder <int> is not valid JSON. This should be replaced with an actual integer value to make the example valid and copy-paste friendly.

Suggested change
"type": <int>, // 函数类型0 表示 tool 函数1 表示 rpc 函数
"type": 0, // 函数类型,0 表示 tool 函数,1 表示 rpc 函数

}
```

##### 5. Notify 消息
Copy link

Choose a reason for hiding this comment

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

Incomplete Notify Message Documentation

The Notify message section lacks critical information:

  1. Missing session_id field - All other server messages include this field for consistency
  2. No validation guidance - How should devices authenticate/validate this notification?
  3. Missing connection management strategy - When should devices reconnect? Should they use exponential backoff to prevent thundering herd issues?
  4. No field documentation - What other event types exist besides config_updated?

Recommendations:

  • Add session_id field for consistency with other messages
  • Document reconnection strategy (complete active sessions first, use exponential backoff)
  • Add a table documenting the event field possible values
  • Include security validation requirements

@xgopilot
Copy link

xgopilot bot commented Nov 27, 2025

Code Review Summary

This PR adds important documentation for MCP tool type identification and WebSocket notify messages. Overall structure is good, but 4 critical issues need attention:

Must Fix:

  • Invalid JSON syntax (<int> placeholder) in hardware-mcp.md:273
  • Insecure HTTP URL in vision capability example (should be HTTPS)
  • Incomplete Notify message documentation lacking session_id, validation guidance, and reconnection strategy

Strengths:
✓ Clear markdown structure and formatting
✓ Good backward compatibility notes
✓ Proper Chinese documentation for target audience

Please address the inline comments before merging.

@syureyi syureyi merged commit a22e665 into qiniu:main Nov 27, 2025
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