Skip to content

Conversation

@wenhaozhao
Copy link

support async-mcp-client

@wenhaozhao wenhaozhao changed the title Feat async mcp tool feature: support async mcp tool client Jul 16, 2025
@wenhaozhao wenhaozhao closed this Jul 16, 2025
@wenhaozhao wenhaozhao deleted the feat-async_mcp_tool branch July 16, 2025 03:19
@wenhaozhao wenhaozhao reopened this Jul 16, 2025
@wenhaozhao wenhaozhao force-pushed the feat-async_mcp_tool branch 2 times, most recently from 119ebf9 to 86ebe47 Compare July 22, 2025 02:27
@wenhaozhao wenhaozhao force-pushed the feat-async_mcp_tool branch from 86ebe47 to 4d40166 Compare July 23, 2025 01:39
@Poggecci Poggecci self-requested a review July 24, 2025 21:25
Copy link
Contributor

@Poggecci Poggecci left a comment

Choose a reason for hiding this comment

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

Thank you a lot for this contribution!
Would you mind updating the description briefly detailing why the Async client was necessary for your use case? Would love to better understand and see if we should update our docs to default to the Async over the sync client

@wenhaozhao
Copy link
Author

Thank you a lot for this contribution! Would you mind updating the description briefly detailing why the Async client was necessary for your use case? Would love to better understand and see if we should update our docs to default to the Async over the sync client

Thanks for you relay.

I am building an Agent service based on Java, providing RESTful APIs through Spring Boot Webflux. ADK-Java meets my needs. Meanwhile, it is developed based on RxJava. Although it and Reactor in Webflux are two different reactive frameworks, it's not a problem. Asynchronous and reactive technology stacks are exactly what I want. But in the process of me gradually delving into using ADK, I found that in the link based on the asynchronous technology stack:

1 McpTool is actually an implementation based on McpSyncClient.
2 And mcp-java-sdk is an asynchronous implementation based on Reactor, providing asynchronous APIs through McpAsyncClient. McpSyncClient converts asynchronous APIs to synchronous APIs by means of Mono.block().
Thus, the call link of Async -> Sync -> Async is formed for McpTool in ADK.
However, the key point is that using blocking operations in an asynchronous context may lead to performance problems and waste of thread resources.
So, I decided to provide an asynchronous implementation of McpTool to better match the asynchronous technology stack architecture of ADK.

@wenhaozhao wenhaozhao force-pushed the feat-async_mcp_tool branch from 6c377e0 to 7d62b21 Compare July 25, 2025 03:46
@wenhaozhao
Copy link
Author

Thank you a lot for this contribution! Would you mind updating the description briefly detailing why the Async client was necessary for your use case? Would love to better understand and see if we should update our docs to default to the Async over the sync client

Thank you a lot for this contribution! Would you mind updating the description briefly detailing why the Async client was necessary for your use case? Would love to better understand and see if we should update our docs to default to the Async over the sync client

Thanks for you relay.

I am building an Agent service based on Java, providing RESTful APIs through Spring Boot Webflux. ADK-Java meets my needs. Meanwhile, it is developed based on RxJava. Although it and Reactor in Webflux are two different reactive frameworks, it's not a problem. Asynchronous and reactive technology stacks are exactly what I want. But in the process of me gradually delving into using ADK, I found that in the link based on the asynchronous technology stack:

1 McpTool is actually an implementation based on McpSyncClient. 2 And mcp-java-sdk is an asynchronous implementation based on Reactor, providing asynchronous APIs through McpAsyncClient. McpSyncClient converts asynchronous APIs to synchronous APIs by means of Mono.block(). Thus, the call link of Async -> Sync -> Async is formed for McpTool in ADK. However, the key point is that using blocking operations in an asynchronous context may lead to performance problems and waste of thread resources. So, I decided to provide an asynchronous implementation of McpTool to better match the asynchronous technology stack architecture of ADK.

So, I think it's a better choice to use asynchronous clients in the asynchronous link.

@wenhaozhao wenhaozhao force-pushed the feat-async_mcp_tool branch from 7d62b21 to 0c50970 Compare July 25, 2025 04:04
@Poggecci Poggecci self-requested a review July 28, 2025 16:11
@andrey-star
Copy link

andrey-star commented Jul 28, 2025

Can we also either update core/src/main/java/com/google/adk/tools/mcp/McpToolset.java to allow choosing, or create an McpAsyncToolset?

@copybara-service copybara-service bot merged commit d5ca1ec into google:main Jul 28, 2025
7 checks passed
@wenhaozhao
Copy link
Author

In my opinion, it might be better to create an McpAsyncToolset first, and then gradually and smoothly migrate the McpToolset to McpAsyncToolset.

@wenhaozhao
Copy link
Author

I'll add McpAsyncToolset later

@wenhaozhao
Copy link
Author

Can we also either update core/src/main/java/com/google/adk/tools/mcp/McpToolset.java to allow choosing, or create an McpAsyncToolset?

The pr for McpAsyncToolset: #306

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants