This tutorial demonstrates how to integrate Google Agent Development Kit (ADK) with Klavis MCP servers to build AI agents that can interact with Gmail and Slack.
You can find the complete example code in Klavis GitHub repository here ->
The agent.py file contains a root_agent definition which is the only required element of an ADK agent.Update your agent.py to integrate Klavis MCP servers:
import osimport webbrowserfrom google.adk.agents.llm_agent import Agentfrom google.adk.tools.mcp_tool import StreamableHTTPConnectionParamsfrom google.adk.tools.mcp_tool.mcp_toolset import McpToolsetfrom klavis import Klavisfrom klavis.types import McpServerNamefrom dotenv import load_dotenvload_dotenv()KLAVIS_API_KEY = os.getenv("KLAVIS_API_KEY")# Initialize Klavis and set up Strata serverklavis_client = Klavis(api_key=KLAVIS_API_KEY)user_id = "user_123"# Create Strata server with multiple MCP serversstrata_response = klavis_client.mcp_server.create_strata_server( servers=[McpServerName.GMAIL, McpServerName.SLACK], user_id=user_id)# Handle OAuth authenticationif strata_response.oauth_urls: for server_name, oauth_url in strata_response.oauth_urls.items(): user_integration_auth = klavis_client.user.get_user_auth( user_id=user_id, server_name=server_name ) if not user_integration_auth.is_authenticated: print(f"🔐 Opening OAuth for {server_name}...") webbrowser.open(oauth_url) input(f"Press Enter after completing {server_name} OAuth authorization...")mcp_server_url = strata_response.strata_server_url# Create AI agent with MCP toolset (exposed at module level for ADK)root_agent = Agent( name="my_agent", model="gemini-2.5-flash", description="An agent with access to tools through Klavis MCP", instruction="You are a helpful assistant with access to MCP tools.", tools=[ McpToolset( connection_params=StreamableHTTPConnectionParams( url=mcp_server_url, ), ) ],)
OAuth Authorization Required: The code above will open browser windows for each service. Click through the OAuth flow to authorize access to your accounts.