Not able to call tools in run mode

I am new to Agno and trying to access whether should I use it to build a multi orchestrated agentic Ai system. However I am finding one or the other bugs, sometimes the thing is working sometimes not. What are other opinions? yesterday It wasn’t able to call the MCP server, today it is. Below is the sample code as given in the doc. I am running it normally insteaf of the AgentOs mode. In agentOs mode it’s able to call the mcp server and give right answer.

from agno.agent import Agent

from agno.db.sqlite import SqliteDb

from agno.models.anthropic import Claude

from agno.models.openai import OpenAIChat

from agno.os import AgentOS

from agno.tools.mcp import MCPTools

from agno.agent import RunOutput

from agno.utils.pprint import pprint_run_response

# Create the Agent

agno_agent = Agent(

name="Agno Agent",

model=OpenAIChat(id="gpt-4o"),

# Add a database to the Agent

db=SqliteDb(db_file="agno.db"),

# Add the Agno MCP server to the Agent

tools=\[MCPTools(transport="streamable-http", url="https://docs.agno.com/mcp")\],

# Add the previous session history to the context

add_history_to_context=True,

markdown=True,

debug_mode=True

)

# agent_os = AgentOS(agents=[agno_agent])

# app = agent_os.get_app()

response: RunOutput =agno_agent.run(“what is agno?”)

pprint_run_response(response, markdown=True)

Reponse:

(agno) ➜ agno git:(main) ✗ python agno_agent.py
DEBUG ******************************************************************************************************* Agent ID: agno-agent ******************************************************************************************************
DEBUG Reading AgentSession: a21f0214-e9d8-4c4e-9045-e2c938b8ac8e
DEBUG Loaded existing table agno_sessions
DEBUG Creating new AgentSession: a21f0214-e9d8-4c4e-9045-e2c938b8ac8e
DEBUG Processing tools for model
DEBUG ************************************************************************************** Agent Run Start: 284f1d88-0b3c-4d08-ae70-e8f9ba039599 **************************************************************************************
DEBUG ------------------------------------------------------------------------------------------------------ OpenAI Response Start ------------------------------------------------------------------------------------------------------
DEBUG ---------------------------------------------------------------------------------------------------------- Model: gpt-4o ----------------------------------------------------------------------------------------------------------
DEBUG ============================================================================================================== system =============================================================================================================
DEBUG <additional_information>

  • Use markdown to format your answers.
    </additional_information>
    DEBUG =============================================================================================================== user ==============================================================================================================
    DEBUG what is agno?
    DEBUG ============================================================================================================ assistant ============================================================================================================
    DEBUG “AgNO” does not appear to be a commonly recognized term or acronym. However, in chemistry, “AgNO” could be a typographical error or shorthand for silver nitrate, which is correctly represented as “AgNO₃”. Silver nitrate is a chemical
    compound with various applications, including in photography, medicine, and as a reagent in chemical reactions.
  If you meant something else or if "AgNO" is a specific term in a niche field or a newly emerging concept, please provide more context or check for any potential typos.                                                                          

DEBUG ************************************************************************************************************ METRICS ************************************************************************************************************
DEBUG * Tokens: input=32, output=109, total=141
DEBUG * Duration: 3.2007s
DEBUG * Tokens per second: 34.0545 tokens/s
DEBUG ************************************************************************************************************ METRICS ************************************************************************************************************
DEBUG ------------------------------------------------------------------------------------------------------- OpenAI Response End -------------------------------------------------------------------------------------------------------
DEBUG Added RunOutput to Agent Session
DEBUG Loaded existing table agno_sessions
DEBUG Created or updated AgentSession record: a21f0214-e9d8-4c4e-9045-e2c938b8ac8e
DEBUG *************************************************************************************** Agent Run End: 284f1d88-0b3c-4d08-ae70-e8f9ba039599 ***************************************************************************************
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ “AgNO” does not appear to be a commonly recognized term or acronym. However, in chemistry, “AgNO” could be a typographical error or shorthand for silver nitrate, which is correctly represented as “AgNO₃”. Silver nitrate is a chemical compound │
│ with various applications, including in photography, medicine, and as a reagent in chemical reactions. │
│ │
│ If you meant something else or if “AgNO” is a specific term in a niche field or a newly emerging concept, please provide more context or check for any potential typos.

Hi @garg10may
With MCPtools you have to connect/close the tools for the MCP lifecycle (see here). We do this automatically with AgentOS.
So here is an updated example
```
import asyncio

from agno.agent import Agent

from agno.db.sqlite import SqliteDb

from agno.models.openai import OpenAIChat

from agno.tools.mcp import MCPTools

# Create the Agent

async def run_agent():

mcp_tools = MCPTools(transport="streamable-http", url="https://docs.agno.com/mcp")

await mcp_tools.connect()

agno_agent = Agent(

name=“Agno Agent”,

model=OpenAIChat(id=“gpt-4o”),

db=SqliteDb(db_file=“agno.db”),

tools=[mcp_tools],

add_history_to_context=True,

markdown=True,

debug_mode=True

)

await agno_agent.aprint_response(input=“what is agno?”, stream=True, markdown=True)

await mcp_tools.close()

asyncio.run(run_agent())
```