Skip to content

Fix use mcp name as endpoint name instead of mcp server id #13438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025

Conversation

luoxiner
Copy link
Contributor

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

use mcp name as endpoint name instead of mcp server id

Brief changelog

XX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

Copy link

Thanks for your this PR. 🙏
Please check again for your PR changes whether contains any usage/api/configuration change such as Add new API , Add new configuration, Change default value of configuration.
If so, please add or update documents(markdown type) in docs/next/ for repository nacos-group/nacos-group.github.io


感谢您提交的PR。 🙏
请再次查看您的PR内容,确认是否包含任何使用方式/API/配置参数的变更,如:新增API新增配置参数修改默认配置等操作。
如果是,请确保在提交之前,在仓库nacos-group/nacos-group.github.io中的docs/next/目录下添加或更新文档(markdown格式)。

Copy link

lingma-agents bot commented May 27, 2025

将MCP服务端点名称从使用服务器ID改为使用服务名称

变更文件

文件路径 变更说明
ai/​src/​main/​java/​com/​alibaba/​nacos/​ai/​service/​McpServerOperationService.java 将createMcpServerEndpointServiceIfNecessary方法的第二个参数从mcpServerId改为serverSpecification.getName(),实现端点服务名称由服务名称而非服务器ID决定

💡 小贴士

与 lingma-agents 交流的方式

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

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

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

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

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

  • @Lingma-Agent 对这个方法生成优化代码。

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

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

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

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.

🔍 代码评审报告

📋 评审意见详情

💡 单文件建议

✅ 未发现需要特别关注的代码问题。

🚀 跨文件建议

以下是对代码架构和设计的综合分析,聚焦于跨文件交互、系统一致性和潜在优化空间。
🔍 1. 使用MCP名称而非ID作为端点名称可能导致系统架构不一致

该变更将MCP服务器名称作为端点名称的来源,替代原有基于ID的命名方式。若系统架构设计要求端点名称必须基于唯一且稳定的ID(如依赖ID的其他模块或接口),此变更可能破坏架构一致性。例如,其他服务可能依赖端点名称的唯一性或ID的固定格式,而名称可能重复、变更或不符合格式要求。

📌 关键代码:

Service service = endpointOperationService.createMcpServerEndpointServiceIfNecessary(namespaceId, serverSpecification.getName(), endpointSpecification);

⚠️ 潜在风险: 可能导致端点名称冲突、其他模块逻辑失效、系统行为不可预测,或与其他依赖ID的服务产生接口不兼容问题。

🔍 2. 跨服务调用参数不一致可能导致接口行为差异

endpointOperationService.createMcpServerEndpointServiceIfNecessary方法中,若其他调用点仍然传递mcpServerId而非名称,将导致参数不一致。例如,若某些服务调用此方法时仍使用ID,而此处改用名称,可能导致端点名称生成逻辑混乱或服务创建失败。

📌 关键代码:

Service service = endpointOperationService.createMcpServerEndpointServiceIfNecessary(namespaceId, serverSpecification.getName(), endpointSpecification);

⚠️ 潜在风险: 不同调用场景下端点名称生成不一致,引发服务调用失败、数据错乱或系统状态不一致。

🔍 3. 使用名称作为端点名称可能引入唯一性冲突风险

MCP名称可能不是系统内唯一的标识符(如不同服务器可能有相同名称),使用名称作为端点名称的来源可能导致重复名称冲突。例如,当多个MCP服务器具有相同名称时,创建端点服务时可能出现命名冲突,影响系统扩展性和稳定性。

⚠️ 潜在风险: 高并发或大规模部署下,端点名称冲突可能导致服务创建失败、覆盖现有服务,或引发不可预见的逻辑错误。

🔍 4. 业务逻辑未明确支持名称作为端点名称的变更

若业务需求中未明确规定必须使用MCP名称作为端点名称,此变更可能违背业务规则。例如,名称可能被用户修改,导致端点名称动态变化,而某些业务流程(如配置、监控)可能依赖端点名称的稳定性。

⚠️ 潜在风险: 业务流程中断、配置失效或监控数据错乱,导致系统功能异常。

🔍 5. 测试覆盖不足可能遗漏名称相关场景

当前的单元测试可能未覆盖MCP名称变更、重复名称、名称为空或包含非法字符等场景,可能导致潜在问题未被发现。例如,未测试名称变更后的影响或冲突处理逻辑。

⚠️ 潜在风险: 未发现的缺陷在生产环境引发错误,导致服务不可用或数据不一致。


💡 小贴士

与 lingma-agents 交流的方式

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

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

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

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

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

  • @Lingma-Agent 对这个方法生成优化代码。

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

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

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

@@ -464,7 +464,7 @@ private void injectToolAndEndpoint(String namespaceId, String mcpServerId, McpSe
serverSpecification.setToolsDescriptionRef(toolSpecDataId);
}
if (null != endpointSpecification) {
Service service = endpointOperationService.createMcpServerEndpointServiceIfNecessary(namespaceId, mcpServerId,

Choose a reason for hiding this comment

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

Level me free and I need to be correct

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.28%. Comparing base (cf0a7a8) to head (be0f14c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             develop   #13438   +/-   ##
==========================================
  Coverage      70.28%   70.28%           
  Complexity     11728    11728           
==========================================
  Files           1601     1601           
  Lines          51106    51106           
  Branches        5152     5152           
==========================================
  Hits           35920    35920           
  Misses         12752    12752           
  Partials        2434     2434           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf0a7a8...be0f14c. Read the comment docs.

🚀 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.

@KomachiSion KomachiSion merged commit 7e3da5b into alibaba:develop May 27, 2025
5 checks passed
@KomachiSion KomachiSion added this to the 3.0.2 milestone May 27, 2025
@KomachiSion KomachiSion added the kind/bug Category issues or prs related to bug. label May 27, 2025
@wuyfee
Copy link

wuyfee commented May 27, 2025

$\color{red}{FAILURE}$
DETAILS
✅ - docker: success
❌ - deploy (standalone & cluster & standalone_auth): failure
❌ - e2e-java-test (standalone & cluster & standalone_auth): skipped
❌ - e2e-go-test (standalone & cluster): skipped
❌ - e2e-cpp-test (standalone & cluster): skipped
❌ - e2e-csharp-test (standalone & cluster): skipped
❌ - e2e-nodejs-test (standalone & cluster): skipped
❌ - e2e-python-test (standalone & cluster): skipped
✅ - clean (standalone & cluster & standalone_auth): success

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants