diff --git a/deployed-agents/Google-ADK/README.md b/deployed-agents/Google-ADK/README.md new file mode 100644 index 0000000..415adfa --- /dev/null +++ b/deployed-agents/Google-ADK/README.md @@ -0,0 +1,35 @@ +

Corvic MCP with Google ADK

+In this example, we use the ADK framework to forward a question to Corvic Agent via MCP. The Corvic agent is a sales reporting agent that reports the total sales given a customer id. +

Pre-requisites

+Download this folder to a local path and make sure you have the following libraries installed. + +```bash + +pip install google-adk +pip install mcp +pip install nest-asyncio +``` + +

Setup Google Credentials

+In the directory where the code is downloaded, set the Google credentials +```bash + +export GOOGLE_GENAI_USE_VERTEXAI=FALSE +export GOOGLE_API_KEY= +``` + +

Setup Corvic

+Add MCP endpoint and Authorization in `agent.py`. Your administrator will provide these items + +

Start the ADK Server

+Start the ADK web agent using the following command +```bash + +adk web +``` + +

Ask questions on the Web Interface

+Navigate to http://localhost:8000 where a prompt is presented. You can go ahead and ask the question you want Corvic to answer. +![img.png](img.png) +

+In the image above, a question `Provide sales data for customer id 1234` is being answered by Corvic. \ No newline at end of file diff --git a/deployed-agents/Google-ADK/img.png b/deployed-agents/Google-ADK/img.png new file mode 100644 index 0000000..9ca0968 Binary files /dev/null and b/deployed-agents/Google-ADK/img.png differ diff --git a/deployed-agents/Google-ADK/multi_tool_agent/__init__.py b/deployed-agents/Google-ADK/multi_tool_agent/__init__.py new file mode 100644 index 0000000..02c597e --- /dev/null +++ b/deployed-agents/Google-ADK/multi_tool_agent/__init__.py @@ -0,0 +1 @@ +from . import agent diff --git a/deployed-agents/Google-ADK/multi_tool_agent/agent.py b/deployed-agents/Google-ADK/multi_tool_agent/agent.py new file mode 100644 index 0000000..a845013 --- /dev/null +++ b/deployed-agents/Google-ADK/multi_tool_agent/agent.py @@ -0,0 +1,63 @@ +import asyncio +import datetime +from zoneinfo import ZoneInfo +from google.adk.agents import Agent +from mcp import ClientSession +from mcp.client.sse import sse_client +import nest_asyncio + +nest_asyncio.apply() + + +async def run(customer_id): + async with sse_client( + "YOUR-CORVIC-MCP-SSE-ENDPOINT-GOES-HERE", + headers={ + "Authorization": "YOUR-API-TOKEN-GOES-HERE" + }, + ) as (read, write): + async with ClientSession(read, write) as session: + # Initialize the connection + await session.initialize() + + # List available tools + tools = await session.list_tools() + print(tools) + + # Call a tool + result = await session.call_tool( + "query", arguments={"query_content": f"Provide the total sales amount for customer id {customer_id}"} + ) + return result + + +def get_sales_data(customer_id: str) -> dict: + """Retrieves the sales data for the customer id. + + Args: + customer_id (str): The id of the customer. + + Returns: + dict: status and result or error msg. + """ + final_response = asyncio.run(run(customer_id)) + + return { + "status": "success", + "report": ( + f"Corvic response: {repr(final_response)}" + ), + } + + +root_agent = Agent( + name="Sales_Reporting_agent", + model="gemini-2.0-flash", + description=( + "Agent to provide sales data for a given customer id." + ), + instruction=( + "Only answer based on the tool, and dont add any information of your own. You are a helpful agent who can answer user questions about sales to a customer." + ), + tools=[get_sales_data], +)