Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions deployed-agents/Google-ADK/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<h1> Corvic MCP with Google ADK</h1>
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.
<h2>Pre-requisites</h2>
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
```

<h2>Setup Google Credentials</h2>
In the directory where the code is downloaded, set the Google credentials
```bash

export GOOGLE_GENAI_USE_VERTEXAI=FALSE
export GOOGLE_API_KEY=<YOUR GOOGLE API KEY>
```

<h2>Setup Corvic </h2>
Add MCP endpoint and Authorization in `agent.py`. Your administrator will provide these items

<h2>Start the ADK Server </h2>
Start the ADK web agent using the following command
```bash

adk web
```

<h2>Ask questions on the Web Interface</h2>
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)
<p></p>
In the image above, a question `Provide sales data for customer id 1234` is being answered by Corvic.
Binary file added deployed-agents/Google-ADK/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions deployed-agents/Google-ADK/multi_tool_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import agent
63 changes: 63 additions & 0 deletions deployed-agents/Google-ADK/multi_tool_agent/agent.py
Original file line number Diff line number Diff line change
@@ -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],
)