feat(mcp): 添加elicitation功能支持#798
Conversation
- 在McpClientBuilder中添加asyncElicitation和syncElicitation方法 - 更新文档说明elicitation特性和使用示例 - 添加完整的单元测试验证elicitation功能
Summary of ChangesHello @miniceM, 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 客户端构建器( Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
这个 PR 很好地为 McpClientBuilder 添加了 elicitation 功能的支持,包括核心逻辑、单元测试和文档更新。代码整体质量很高。
我提出了一些改进建议:
- 在
McpClientBuilder.java中,buildAsync和buildSync方法中存在一些重复代码,建议通过提取辅助方法来优化,以提高代码的可维护性。 - 在英文文档
docs/en/task/mcp.md中,新添加的部分存在中英文混用的情况,建议统一为英文,以保证文档的一致性。
这些修改将有助于进一步提升代码质量和文档的清晰度。
- 提取客户端功能构建为独立的私有方法 buildCapabilities - 简化异步和同步客户端构建中的重复代码 - 将文档中的中文注释翻译为英文
- 调整了 McpClientBuilder 中客户端功能构建的代码缩进 - 改进了版本测试中断言语句的代码布局
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
LearningGp
left a comment
There was a problem hiding this comment.
Should we provide a default implementation for ElicitationHandler (perhaps feeding back to the Model)? This could be handled in a separate PR—let me know if you'd be interested in taking that on.
ok, I will take it |
Updated section title from 'elicitation 支持' to 'elicitation support' for consistency.
agentscope-ai#797 - 在McpClientBuilder中添加asyncElicitation和syncElicitation方法 - 更新文档说明elicitation特性和使用示例 - 添加完整的单元测试验证elicitation功能 ## AgentScope-Java Version <revision>1.0.10-SNAPSHOT</revision> ## Description 为 McpClientBuilder 添加了 MCP 官方 SDK 定义的 elicitation 功能支持。 ### 核心变更 修改了 McpClientBuilder.java: 新增导入 io.modelcontextprotocol.spec.McpSchema.ElicitRequest io.modelcontextprotocol.spec.McpSchema.ElicitResult java.util.function.Function 新增字段 asyncElicitationHandler: 用于异步客户端的 elicitation handler syncElicitationHandler: 用于同步客户端的 elicitation handler 新增方法 asyncElicitation(Function<ElicitRequest, Mono> handler): 注册异步 elicitation handler syncElicitation(Function<ElicitRequest, ElicitResult> handler): 注册同步 elicitation handler 修改 buildAsync() 方法 当 asyncElicitationHandler 不为 null 时,在 ClientCapabilities.builder() 中调用 .elicitation() 当 asyncElicitationHandler 不为 null 时,在 McpClient.async() builder 中调用 .elicitation(asyncElicitationHandler) 修改 buildSync() 方法 当 syncElicitationHandler 不为 null 时,在 ClientCapabilities.builder() 中调用 .elicitation() 当 syncElicitationHandler 不为 null 时,在 McpClient.sync() builder 中调用 .elicitation(syncElicitationHandler) 新增单元测试 McpClientBuilderTest 类中相关测试方法 测试命令 ``` mvn test -pl agentscope-core -Dtest='McpClientBuilderTest#test*Elicitation*' ``` 更新了中英两版 mcp.md 文件,添加了使用示例。
#797
AgentScope-Java Version
1.0.10-SNAPSHOT
Description
为 McpClientBuilder 添加了 MCP 官方 SDK 定义的 elicitation 功能支持。
核心变更
修改了 McpClientBuilder.java:
新增导入
io.modelcontextprotocol.spec.McpSchema.ElicitRequest
io.modelcontextprotocol.spec.McpSchema.ElicitResult
java.util.function.Function
新增字段
asyncElicitationHandler: 用于异步客户端的 elicitation handler
syncElicitationHandler: 用于同步客户端的 elicitation handler
新增方法
asyncElicitation(Function<ElicitRequest, Mono> handler): 注册异步 elicitation handler
syncElicitation(Function<ElicitRequest, ElicitResult> handler): 注册同步 elicitation handler
修改 buildAsync() 方法
当 asyncElicitationHandler 不为 null 时,在 ClientCapabilities.builder() 中调用 .elicitation()
当 asyncElicitationHandler 不为 null 时,在 McpClient.async() builder 中调用 .elicitation(asyncElicitationHandler)
修改 buildSync() 方法
当 syncElicitationHandler 不为 null 时,在 ClientCapabilities.builder() 中调用 .elicitation()
当 syncElicitationHandler 不为 null 时,在 McpClient.sync() builder 中调用 .elicitation(syncElicitationHandler)
新增单元测试 McpClientBuilderTest 类中相关测试方法
测试命令
更新了中英两版 mcp.md 文件,添加了使用示例。