import os# Set environment variablesos.environ["GEMINI_API_KEY"] = "YOUR_GEMINI_API_KEY" # Replace with your actual Gemini API keyos.environ["KLAVIS_API_KEY"] = "YOUR_KLAVIS_API_KEY" # Replace with your actual Klavis API key
Step 1 - Create Strata MCP Server with Gmail and Slack
Copy
Ask AI
from klavis import Klavisfrom klavis.types import McpServerName, ToolFormatimport webbrowserklavis_client = Klavis(api_key=os.getenv("KLAVIS_API_KEY"))response = klavis_client.mcp_server.create_strata_server( servers=[McpServerName.GMAIL, McpServerName.SLACK], user_id="1234")# Handle OAuth authorization for each servicesif response.oauth_urls: for server_name, oauth_url in response.oauth_urls.items(): webbrowser.open(oauth_url) print(f"Or please open this URL to complete {server_name} OAuth authorization: {oauth_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.
result = gemini_with_mcp_server( mcp_server_url=response.strata_server_url, user_query="Check my latest 5 gmails and summarize them in a Slack message to #engineering")print(f"\n🤖 Final Response: {result}")
Perfect! You’ve integrated Gemini with Klavis MCP servers.