Skip to content

Conversation

@Erica177
Copy link
Collaborator

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@lingma-agents
Copy link

lingma-agents bot commented Jun 12, 2025

修复McpStreamableProtocol常量拼写错误及关联配置更新

变更概述

问题修复

  • 修正拼写错误:
    • registry/mcp_model.go中修正了McpStreambleProtocol的拼写错误为McpStreamableProtocol
    • 同步更新了registry/nacos/mcpserver/watcher.go中所有引用该常量的配置映射
  • 配置修复:
    • 更新了supportedProtocols协议支持列表
    • 修正protocolUpstreamTypeMapping协议类型映射关系
    • 调整routeRewriteProtocols路由重写规则中的协议标识
变更统计
  • 📁 修改文件: 2 个文件

  • ✅ 新增代码: +16 行

  • ❌ 删除代码: -16 行

变更文件
文件路径 变更说明
registry/mcp_model.go 修正McpStreambleProtocol拼写为McpStreamableProtocol,并调整协议常量定义顺序
registry/​nacos/​mcpserver/​watcher.​go 更新支持协议列表、上游类型映射和路由重写规则中的协议标识,使用修正后的常量名称

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 46.03%. Comparing base (ef31e09) to head (d414ee4).
Report is 557 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2405       +/-   ##
===========================================
+ Coverage   35.91%   46.03%   +10.12%     
===========================================
  Files          69       81       +12     
  Lines       11576    13018     +1442     
===========================================
+ Hits         4157     5993     +1836     
+ Misses       7104     6679      -425     
- Partials      315      346       +31     

see 78 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@johnlanni johnlanni left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@lingma-agents lingma-agents bot left a comment

Choose a reason for hiding this comment

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

🔎 代码评审报告

🎯 评审意见概览
严重度 数量 说明
🔴 Blocker 0 阻断性问题,需立即修复。例如:系统崩溃、关键功能不可用或严重安全漏洞。
🟠 Critical 3 严重问题,高优先级修复。例如:核心功能异常或性能瓶颈影响用户体验。
🟡 Major 0 主要问题,建议修复。例如:非核心功能缺陷或代码维护性较差。
🟢 Minor 0 次要问题,酬情优化。例如:代码格式不规范或注释缺失。

总计: 3 个问题

📋 评审意见详情
💡 代码实现建议
以下是文件级别的代码建议,聚焦于代码的可读性、可维护性和潜在问题。
🔹 registry/nacos/mcpserver/watcher.go (3 💬)
🚀 架构设计建议
以下是对代码架构和设计的综合分析,聚焦于跨文件交互、系统一致性和潜在优化空间。
🔍1. 存在未修正的旧常量引用风险

在修正McpStreambleProtocol拼写错误后,需确认其他文件是否仍存在旧名称引用。当前PR仅修复了watcher.go中的相关引用,但未检查其他可能使用该常量的模块。若其他文件(如配置解析、协议处理模块)仍保留旧拼写,可能导致协议类型不匹配或路由规则失效等系统性问题。建议全局搜索并修正所有旧名称引用。

📌 关键代码

McpSSEProtocol        = "mcp-sse"
McpStreamableProtocol = "mcp-streamable"
provider.McpStreamableProtocol: true
provider.McpStreamableProtocol: mcpserver.UpstreamTypeStreamable
provider.McpStreamableProtocol: true

⚠️ 潜在风险

若其他模块仍使用旧名称,可能导致协议类型判断错误、路由规则失效或配置加载失败。

🔍2. 协议常量分散管理存在维护风险

当前协议常量(如HttpProtocolMcpStreamableProtocol)虽集中定义在mcp_model.go,但未通过枚举或接口约束强制引用,可能导致开发人员在新模块中直接硬编码字符串。建议将协议常量定义为枚举类型或提供只读访问方法,减少拼写错误和维护成本。

📌 关键代码

StdioProtocol         = "stdio"
HttpProtocol          = "http"
...
McpStreamableProtocol = "mcp-streamable"

⚠️ 潜在风险

新增协议类型时可能因重复定义导致不一致,或因拼写错误引发隐蔽性故障。

🔍3. 路由重写协议的映射逻辑需全局验证

修正McpStreamableProtocol后,需验证所有涉及协议类型映射的模块(如protocolUpstreamTypeMappingrouteRewriteProtocols)是否覆盖了新名称。当前PR仅修正了watcher.go中的映射,但未检查如server.goconfig_parser.go等可能依赖旧名称的文件,可能导致部分场景下协议类型未被正确识别。

📌 关键代码

provider.McpStreamableProtocol: true

⚠️ 潜在风险

路由规则或上游类型映射失效,导致服务发现异常或通信协议不兼容。

审查详情
📒 文件清单 (2 个文件)
📝 变更: 2 个文件

📝 变更文件:

  • registry/mcp_model.go
  • registry/nacos/mcpserver/watcher.go

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

Comment on lines +59 to +62
provider.HttpProtocol: true,
provider.HttpsProtocol: true,
provider.McpSSEProtocol: true,
provider.McpStreamableProtocol: true,
Copy link

Choose a reason for hiding this comment

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

修正映射配置中的常量名称拼写错误,确保协议支持逻辑正确。

🟠 Critical | 🐞 Bugs

📋 问题详情

supportedProtocolsprotocolUpstreamTypeMappingrouteRewriteProtocols中,McpStreambleProtocol拼写错误可能导致协议不被识别或映射失败,需修正为McpStreamableProtocol

💡 解决方案

更新所有协议映射的常量引用:

- provider.McpStreambleProtocol: true,
+ provider.McpStreamableProtocol: true,

您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

有用意见👍无用意见👎错误意见❌

Comment on lines +65 to +68
provider.HttpProtocol: mcpserver.UpstreamTypeRest,
provider.HttpsProtocol: mcpserver.UpstreamTypeRest,
provider.McpSSEProtocol: mcpserver.UpstreamTypeSSE,
provider.McpStreamableProtocol: mcpserver.UpstreamTypeStreamable,
Copy link

Choose a reason for hiding this comment

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

修正上游类型映射中的常量名称拼写错误,确保协议类型正确关联。

🟠 Critical | 🐞 Bugs

📋 问题详情

protocolUpstreamTypeMapping中,McpStreambleProtocol拼写错误可能导致协议类型无法正确映射到UpstreamTypeStreamable,需修正为McpStreamableProtocol

💡 解决方案

更新上游类型映射的常量引用:

- provider.McpStreambleProtocol: mcpserver.UpstreamTypeStreamable,
+ provider.McpStreamableProtocol: mcpserver.UpstreamTypeStreamable,

您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

有用意见👍无用意见👎错误意见❌

Comment on lines +71 to +72
provider.McpSSEProtocol: true,
provider.McpStreamableProtocol: true,
Copy link

Choose a reason for hiding this comment

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

修正路由重写协议配置中的常量名称拼写错误,确保路由规则生效。

🟠 Critical | 🐞 Bugs

📋 问题详情

routeRewriteProtocols中,McpStreambleProtocol拼写错误可能导致路由重写规则失效,需修正为McpStreamableProtocol

💡 解决方案

更新路由重写协议的常量引用:

- provider.McpStreambleProtocol: true,
+ provider.McpStreamableProtocol: true,
🔧 建议代码

[!NOTE]
AI 生成代码 - 请在应用前检查逻辑、规范并测试

Suggested change
provider.McpSSEProtocol: true,
provider.McpStreamableProtocol: true,
provider.McpSSEProtocol: true,
provider.McpStreamableProtocol: true,

您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

有用意见👍无用意见👎错误意见❌

Copy link
Collaborator

@CH3CHO CH3CHO left a comment

Choose a reason for hiding this comment

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

LGTM

@CH3CHO CH3CHO merged commit 86934b3 into alibaba:main Jun 12, 2025
10 checks passed
ink-hz pushed a commit to ink-hz/higress-ai-capability-auth that referenced this pull request Nov 5, 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.

4 participants