Skip to content

Error with Agno Agentic Framework #1199

Open
@manjukampali1

Description

@manjukampali1

Describe the bug
Time out error while using with Agno Agents

ERROR Failed to call MCP tool 'list_remote_tables': Timed out while waiting
for response to ClientRequest. Waited 5.0 seconds.
Traceback (most recent call last):
File
"/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/anyio/streams
/memory.py", line 111, in receive
return self.receive_nowait()
File
"/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/anyio/streams
/memory.py", line 106, in receive_nowait
raise WouldBlock
anyio.WouldBlock

     During handling of the above exception, another exception occurred:     
                                                                             
     Traceback (most recent call last):                                      
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/anyio/_core/_
     tasks.py", line 115, in fail_after                                      
         yield cancel_scope                                                  
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/mcp/shared/se
     ssion.py", line 280, in send_request                                    
         response_or_error = await response_stream_reader.receive()          
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/anyio/streams
     /memory.py", line 119, in receive                                       
         await receive_event.wait()                                          
       File "/opt/anaconda3/envs/wren-mcp/lib/python3.10/asyncio/locks.py",  
     line 214, in wait                                                       
         await fut                                                           
     asyncio.exceptions.CancelledError: Cancelled by cancel scope 1064dc6a0  
                                                                             
     During handling of the above exception, another exception occurred:     
                                                                             
     Traceback (most recent call last):                                      
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/mcp/shared/se
     ssion.py", line 279, in send_request                                    
         with anyio.fail_after(timeout):                                     
       File "/opt/anaconda3/envs/wren-mcp/lib/python3.10/contextlib.py", line
     153, in __exit__                                                        
         self.gen.throw(typ, value, traceback)                               
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/anyio/_core/_
     tasks.py", line 118, in fail_after                                      
         raise TimeoutError                                                  
     TimeoutError                                                            
                                                                             
     During handling of the above exception, another exception occurred:     
                                                                             
     Traceback (most recent call last):                                      
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/agno/utils/mc
     p.py", line 33, in call_tool                                            
         result: CallToolResult = await session.call_tool(tool_name, kwargs) 
     # type: ignore                                                          
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/mcp/client/se
     ssion.py", line 277, in call_tool                                       
         return await self.send_request(                                     
       File                                                                  
     "/opt/anaconda3/envs/wren-mcp/lib/python3.10/site-packages/mcp/shared/se
     ssion.py", line 282, in send_request                                    
         raise McpError(                                                     
     mcp.shared.exceptions.McpError: Timed out while waiting for response to 
     ClientRequest. Waited 5.0 seconds.  

To Reproduce
import os
import asyncio
from dotenv import load_dotenv
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.mcp import MCPTools

Load environment variables from .env

load_dotenv()

Check for OpenAI API key

openai_api_key = os.environ.get("OPENAI_API_KEY")
if not openai_api_key:
raise ValueError("OPENAI_API_KEY environment variable not set. Please set it before running.")

Set the MCP server command with correct working directory

mcp_server_command = "uv run app/wren.py"

async def main():
print("\nWren MCP Snowflake Agent is ready! Type your request (type 'exit' to quit).\n")
async with MCPTools(mcp_server_command) as mcp_tools:
agent = Agent(
name="Wren SQL Agent",
role="You are a Data Analyst who specializes in analyzing Snowflake data using SQL. You have access to a Snowflake database through Wren Engine MCP. You can list tables, describe table structures, and execute SQL queries.",
model=OpenAIChat(id="gpt-4o"),
tools=[mcp_tools],
instructions=[
"Use the Wren MCP tools to interact with the Snowflake database.",
"Start by listing available tables or models using the tables or listModels tool.",
"When asked to query data, first understand the schema using tableStructure or listModels.",
"Generate appropriate SQL queries based on the user's natural language request.",
"Execute queries using MCP tools",
"Present results in a clear, well-formatted manner with explanations when needed.",
"Always validate your queries for syntax and logic errors before execution."
],
show_tool_calls=True,
markdown=True,
)
while True:
user_query = input("Enter your data analysis request: ")
if user_query.lower() in ["exit", "quit", "q"]:
print("\nExiting Wren MCP Agent. Goodbye!")
break
print("\nProcessing your request...\n")
try:
await agent.aprint_response(user_query, stream=True)
except Exception as e:
print(f"\nError processing request: {e}")
print("\nReady for another request.")

if name == "main":
asyncio.run(main())

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows, Linux, Mac, Mac Arm ...]

Wren AI Information

  • Version: [e.g, 0.1.0]

Additional context
Also Unable to execute Query

Used Snowflake to connect

It seems there was an internal error when executing the query. Let me try to ┃
┃ resolve this by trying an alternative approach to fetch the information. ┃
┃ Please hold on.Unfortunately, there seems to be a persistent internal error ┃
┃ with executing this query. This might be related to the handling of the data ┃
┃ or system constraints. I recommend contacting a database administrator to ┃
┃ inspect the issue further, as it is likely beyond typical query syntax or ┃
┃ logic and requires deeper system-level resolution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions