Mix sync agents with mcp tools

Is there an example that shows how to combine mcp tools with regular tools and an example about combining regular agents with agents using mcp in the same team?

is the solution to wrap async agents into a sync class or function?

Hi @zzzrpagliari, thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.
If it’s urgent, please let us know. We appreciate your patience!

Hey @zzzrpagliari

We don’t have those examples right now. But let me quickly illustrate how these implementations would look like:

  1. MCP and other tools
# Async function to run the agent with MCP tooling
async def run_agent(message: str) -> None:
    
    # Setup the MCPTools
    async with MCPTools(...) as mcp_tools:

        # This agent receives the MCP tools, and can also receive any other tool
        agent = Agent(tools=[mcp_tools, ...])

        # Run the agent
        response_stream = await agent.arun(message, stream=True)
        await apprint_run_response(response_stream, markdown=True)
  1. Team containing agents using MCP
# Async function to run the team
async def run_team(message: str) -> None:
    
    # Setup the MCPTools
    async with MCPTools(...) as mcp_tools:

        # This agent receives the MCP tools, and can also receive any other tool
        agent = Agent(tools=[mcp_tools])

        # Some more agents
        agent_two = ...

        # Team
        team = Team(members=[agent, agent_two, ...])

        # Run the team
        response_stream = await team.arun(message, stream=True)
        await apprint_run_response(response_stream, markdown=True)

We are currently working on a new MCPTools version that will allow us to use MCPTools without the async context manager. That would simplify these cases a lot! Should be out soon.

Thanks for using Agno!

1 Like