adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Please provide a tutorial on combining "ADK Streaming" with "MCP". The "MCP" tool proxy cannot run in the example of "Quick Start"

Open sleepMoreEarly opened this issue 1 year ago • 9 comments

As the title suggests, thank you very much!

sleepMoreEarly avatar Apr 16 '25 02:04 sleepMoreEarly

@kazunori279 to consider adding this after you get bandwidth.

hangfei avatar Apr 16 '25 03:04 hangfei

I'm also encountering the same issue when trying to run the MCP tool with ADK Streaming in the "Quick Start" example. Would appreciate any guidance or a workaround in the meantime. Thanks!

ycchoo28 avatar Apr 17 '25 09:04 ycchoo28

Sure, let me work on this.

kazunori279 avatar Apr 18 '25 03:04 kazunori279

For me i just have a question : can we use mcp server with adk when we build a system of many agents?

Pessidjo-Germann avatar Apr 18 '25 08:04 Pessidjo-Germann

@kazunori279 Thanks for adding the instructions!

However, I’m encountering an issue when trying to create sub-agents using a similar method. The agent initialization fails with the following error:

RuntimeError: cannot reuse already awaited coroutine

Here’s a simplified version of the code that triggers the error:

sub_agent = create_db_agent()

# Create the root agent
root_agent = LlmAgent(
    model='gemini-2.0-flash',
    name='coordinator',
    description="Main coordinator agent that handles user requests and delegates database queries.",
    instruction='''
    You are a helpful assistant that can answer questions by coordinating with a database specialist.

    When a user asks for information that might be in a database:
    1. If the query requires database access, transfer to the database_specialist agent.
    2. If the query doesn't require database access, answer directly.

    Always be helpful, concise, and user-friendly in your responses.
    ''',
    sub_agents=[sub_agent],
    allow_transfer=True,
)

Is there a recommended pattern for creating and attaching sub-agents with MCP that avoids this issue?

ycchoo28 avatar Apr 21 '25 08:04 ycchoo28

Sorry for my slow response! Let me check this in a couple of days.

kazunori279 avatar Apr 23 '25 03:04 kazunori279

The current MCP tools sample code doesn't work with adk web. The code is being updated with this PR: https://github.com/google/adk-docs/pull/141#pullrequestreview-2782252406

@sleepMoreEarly @ycchoo28 Do you think this PR would fix your issue?

kazunori279 avatar Apr 24 '25 07:04 kazunori279

The PR is merged so the example should work with adk web now. https://github.com/google/adk-docs/pull/141 @sleepMoreEarly @ycchoo28 please try and close this issue if it works!

kazunori279 avatar Apr 30 '25 06:04 kazunori279

I have tried and streaming works with MCP now. Feel free to re-open if you still see any issues.

hangfei avatar May 31 '25 16:05 hangfei