From 62f760c18e63b36adff0ced5628abbe97c3a66d0 Mon Sep 17 00:00:00 2001 From: Shubhamsaboo Date: Sun, 9 Nov 2025 15:02:32 -0800 Subject: [PATCH] refactor: Update travel planner and GitHub agent to use RunOutput and enhance requirements - Changed `add_datetime_to_instructions` to `add_datetime_to_context` in travel planner for better context handling. - Updated response type to `RunOutput` in both travel planner and GitHub agent for improved type safety. - Specified minimum version for the 'agno' package in requirements.txt for compatibility. --- .../ai_travel_planner_mcp_agent_team/app.py | 7 +-- .../requirements.txt | 2 +- .../github_mcp_agent/github_agent.py | 43 ++++++++----------- .../github_mcp_agent/requirements.txt | 2 +- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/mcp_ai_agents/ai_travel_planner_mcp_agent_team/app.py b/mcp_ai_agents/ai_travel_planner_mcp_agent_team/app.py index 5a62f37c..ca0e4d52 100644 --- a/mcp_ai_agents/ai_travel_planner_mcp_agent_team/app.py +++ b/mcp_ai_agents/ai_travel_planner_mcp_agent_team/app.py @@ -2,6 +2,7 @@ import re import asyncio from textwrap import dedent from agno.agent import Agent +from agno.run.agent import RunOutput from agno.tools.mcp import MultiMCPTools from agno.tools.googlesearch import GoogleSearchTools from agno.models.openai import OpenAIChat @@ -118,9 +119,9 @@ async def run_mcp_travel_planner(destination: str, num_days: int, preferences: s "Generate the complete, detailed itinerary in one response without follow-up questions" ], tools=[mcp_tools, GoogleSearchTools()], - add_datetime_to_instructions=True, + add_datetime_to_context=True, markdown=True, - show_tool_calls=False, + debug_mode=False, ) # Create the planning prompt @@ -169,7 +170,7 @@ async def run_mcp_travel_planner(destination: str, num_days: int, preferences: s Generate the complete, highly detailed itinerary in one response without asking for clarification. """ - response = await travel_planner.arun(prompt) + response: RunOutput = await travel_planner.arun(prompt) return response.content finally: diff --git a/mcp_ai_agents/ai_travel_planner_mcp_agent_team/requirements.txt b/mcp_ai_agents/ai_travel_planner_mcp_agent_team/requirements.txt index 4915938c..e43e3c64 100644 --- a/mcp_ai_agents/ai_travel_planner_mcp_agent_team/requirements.txt +++ b/mcp_ai_agents/ai_travel_planner_mcp_agent_team/requirements.txt @@ -1,5 +1,5 @@ streamlit -agno +agno>=2.2.10 openai icalendar google-search-results \ No newline at end of file diff --git a/mcp_ai_agents/github_mcp_agent/github_agent.py b/mcp_ai_agents/github_mcp_agent/github_agent.py index 0e0066ed..da0618dd 100644 --- a/mcp_ai_agents/github_mcp_agent/github_agent.py +++ b/mcp_ai_agents/github_mcp_agent/github_agent.py @@ -3,9 +3,9 @@ import os import streamlit as st from textwrap import dedent from agno.agent import Agent +from agno.run.agent import RunOutput from agno.tools.mcp import MCPTools -from mcp import ClientSession, StdioServerParameters -from mcp.client.stdio import stdio_client +from mcp import StdioServerParameters st.set_page_config(page_title="🐙 GitHub MCP Agent", page_icon="🐙", layout="wide") @@ -86,26 +86,22 @@ async def run_github_agent(message): } ) - async with stdio_client(server_params) as (read, write): - async with ClientSession(read, write) as session: - mcp_tools = MCPTools(session=session) - await mcp_tools.initialize() - - agent = Agent( - tools=[mcp_tools], - instructions=dedent("""\ - You are a GitHub assistant. Help users explore repositories and their activity. - - Provide organized, concise insights about the repository - - Focus on facts and data from the GitHub API - - Use markdown formatting for better readability - - Present numerical data in tables when appropriate - - Include links to relevant GitHub pages when helpful - """), - markdown=True, - ) - - response = await asyncio.wait_for(agent.arun(message), timeout=120.0) - return response.content + async with MCPTools(server_params=server_params) as mcp_tools: + agent = Agent( + tools=[mcp_tools], + instructions=dedent("""\ + You are a GitHub assistant. Help users explore repositories and their activity. + - Provide organized, concise insights about the repository + - Focus on facts and data from the GitHub API + - Use markdown formatting for better readability + - Present numerical data in tables when appropriate + - Include links to relevant GitHub pages when helpful + """), + markdown=True, + ) + + response: RunOutput = await asyncio.wait_for(agent.arun(message), timeout=120.0) + return response.content except asyncio.TimeoutError: return "Error: Request timed out after 120 seconds" @@ -152,6 +148,3 @@ if 'result' not in locals(): """, unsafe_allow_html=True ) - -st.markdown("---") -st.write("Built with Streamlit, Agno, and Model Context Protocol ❤️") diff --git a/mcp_ai_agents/github_mcp_agent/requirements.txt b/mcp_ai_agents/github_mcp_agent/requirements.txt index 6880686a..c858ad58 100644 --- a/mcp_ai_agents/github_mcp_agent/requirements.txt +++ b/mcp_ai_agents/github_mcp_agent/requirements.txt @@ -1,5 +1,5 @@ streamlit>=1.28.0 -agno>=1.1.0 +agno>=2.2.10 mcp>=0.1.0 openai>=1.0.0 asyncio>=3.4.3 \ No newline at end of file