import os# Set environment variablesos.environ["FIREWORKS_API_KEY"] = "your-fireworks-api-key-here" # Replace with your actual Fireworks API keyos.environ["KLAVIS_API_KEY"] = "your-klavis-api-key-here" # Replace with your actual Klavis API key
// Set environment variables in your .env fileprocess.env.FIREWORKS_API_KEY = "your-fireworks-api-key-here"; // Replace with your actual Fireworks API keyprocess.env.KLAVIS_API_KEY = "your-klavis-api-key-here"; // Replace with your actual Klavis API key
Use the agent to analyze and summarize a YouTube video
YOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v=kPXvf2-C_Hs" # Pick a video you like!# 1. Create YouTube MCP server instanceyoutube_mcp_instance = klavis_client.mcp_server.create_server_instance( server_name=McpServerName.YOUTUBE, user_id="1234")# 2. Create an agent with YouTube MCP serveragent = Agent(fireworks_client, klavis_client, youtube_mcp_instance.server_url)# 3. Process the requestresponse = agent.process_request( f"Summarize this YouTube video with timestamps: {YOUTUBE_VIDEO_URL}")print(response)
const YOUTUBE_VIDEO_URL = "https://www.youtube.com/watch?v=kPXvf2-C_Hs"; // Pick a video you like!// 1. Create YouTube MCP server instanceconst youtubeMcpInstance = await klavisClient.mcpServer.createServerInstance({ serverName: Klavis.McpServerName.Youtube, userId: "1234"});// 2. Create an agent with YouTube MCP serverconst agent = new Agent(fireworksClient, klavisClient, youtubeMcpInstance.serverUrl);// 3. Process the requestconst response = await agent.processRequest( `Summarize this YouTube video with timestamps: ${YOUTUBE_VIDEO_URL}`);console.log(response);
Gmail integration requires OAuth authentication, so you’ll need to authorize the application in your browser.
1
Create Gmail Instance
Create a Gmail MCP server instance
2
OAuth Authorization
Complete OAuth flow for Gmail access
3
Send Email
Use the agent to send an email
import webbrowser# Create Gmail MCP server instancegmail_mcp_instance = klavis_client.mcp_server.create_server_instance( server_name=McpServerName.GMAIL, user_id="1234")# Redirect to Gmail OAuth pagewebbrowser.open(gmail_mcp_instance.oauth_url)print(f"🔐 Opening OAuth authorization for Gmail, if you are not redirected, please open the following URL in your browser: {gmail_mcp_instance.oauth_url}")EMAIL_SUBJECT = "Hello, World!"EMAIL_BODY = "This is a test email sent using Fireworks AI and Klavis integration."EMAIL_RECIPIENT = "recipient@example.com" # Replace with your email# After OAuth authorization, create an agent with Gmail MCP serveragent = Agent(fireworks_client, klavis_client, gmail_mcp_instance.server_url)# Send the emailresponse = agent.process_request( f"Send an email to {EMAIL_RECIPIENT} with subject {EMAIL_SUBJECT} and body {EMAIL_BODY}")print(response)
// Create Gmail MCP server instanceconst gmailMcpInstance = await klavisClient.mcpServer.createServerInstance({ serverName: Klavis.McpServerName.Gmail, userId: "1234"});// Redirect to Gmail OAuth pageconsole.log("🔐 Opening OAuth authorization for Gmail");console.log(`If you are not redirected, please open the following URL in your browser: ${gmailMcpInstance.oauthUrl}`);// In a web environment, you might redirect the userwindow.open(gmailMcpInstance.oauthUrl);const EMAIL_SUBJECT = "Hello, World!";const EMAIL_BODY = "This is a test email sent using Fireworks AI and Klavis integration.";const EMAIL_RECIPIENT = "recipient@example.com"; // Replace with your email// After OAuth authorization, create an agent with Gmail MCP serverconst agent = new Agent(fireworksClient, klavisClient, gmailMcpInstance.serverUrl);// Send the emailconst response = await agent.processRequest( `Send an email to ${EMAIL_RECIPIENT} with subject ${EMAIL_SUBJECT} and body ${EMAIL_BODY}`);console.log(response);