🏆 Inspiration

The 2026 FIFA World Cup is the biggest sporting event on the planet, hosted across the USA, Canada, and Mexico. Fantasy football is a massive part of the World Cup experience — millions of fans create leagues, debate predictions, and compete with friends.

I wanted to build something that brings the magic of AI agents into the fantasy football world. What if you could have an intelligent assistant that not only answers questions about matches but actually takes action — creating leagues, saving predictions, and pulling live stats from a database?

That's how World Cup Fantasy Agent (WCA) was born: a multi-step AI agent that turns natural language into real database operations.

🧠 What It Does

WCA is a full-stack fantasy football platform powered by Google Cloud Agent Builder. Users can:

  • 📅 Browse 104+ real World Cup matches seeded from openfootball data
  • 🏆 Create fantasy leagues with custom scoring modes
  • 🔮 Save match predictions and share them socially
  • 🤖 Chat with an AI agent that executes multi-step tasks:
    • "Show me Group A matches then give me stats"
    • "Create a league called HackathonFC for 12 players"
    • "Find Argentina matches and predict a 2-0 win"

The agent doesn't just talk — it calls tools, queries MongoDB, writes data, and returns real results.

🏗️ How We Built It

Architecture

The system is built on a 4-layer architecture:

  1. Frontend: Streamlit app with a vibrant dark-themed UI featuring 5 tabs (Home, Matches, Leagues, Predictions, AI Agent)
  2. AI Layer: Google Agent Development Kit (ADK) with LlmAgent, Runner, and InMemorySessionService
  3. LLM Backend: Vertex AI (Gemini 2.5 Flash) via Google Cloud Agent Builder
  4. Database: MongoDB Atlas with collections for matches, leagues, and predictions

The Agent Flow

User Prompt → ADK Runner → Gemini (Vertex AI) → Tool Selection → MongoDB → Response

What it does

I defined 5 custom tools using ADK's FunctionTool:

  • get_matches_tool(limit, group) — queries matches by group
  • get_leagues_tool() — retrieves all leagues
  • save_prediction_tool(match, prediction, user) — writes predictions
  • create_league_tool(name, participants) — creates new leagues
  • get_stats_tool() — returns database statistics

Gemini decides which tools to call based on the user's intent, executes them in sequence, and synthesizes a natural language response.

Real-Time Data

  • 104 matches from the group stage through the final
  • Live league creation persisted to MongoDB Atlas
  • Prediction tracking with timestamps and user attribution

🚧 Challenges We Faced

1. MCP Toolbox Integration

The hackathon required an MCP server integration. I initially tried the Google MCP Toolbox for Databases, but ran into API routing issues (404s on REST endpoints, SSE transport mismatches). I pivoted to using ADK's native FunctionTool which provided a cleaner, more reliable tool-calling experience while still demonstrating the multi-step agent architecture.

2. Authentication Complexity

I navigated multiple authentication layers:

  • Application Default Credentials (ADC) via gcloud
  • Vertex AI project configuration
  • Service account management
  • API key fallbacks for quota management

3. Quota Management

Free trial accounts have strict RPM/RPD limits on Vertex AI. I implemented model switching strategies (gemini-2.5-flashgemini-2.0-flash-lite) to stay within quotas while maintaining functionality.

4. Async Execution in Streamlit

Streamlit's synchronous nature conflicted with ADK's async Runner.run_async(). I used nest_asyncio to bridge the gap and properly manage session state across user interactions.

🎓 What I Learned

  • Agent Development Kit (ADK) is a powerful framework for building production-ready agents with tool-calling capabilities
  • Multi-step reasoning is where LLMs truly shine — chaining tool calls to accomplish complex tasks
  • MongoDB + Gemini is a natural fit for dynamic, data-driven applications
  • Vertex AI provides enterprise-grade infrastructure for deploying AI agents at scale
  • Real-world hackathons teach you to pivot fast — our MCP → FunctionTool pivot saved the project

🚀 What's Next

  • Live match updates via FIFA API integration
  • Player statistics and injury tracking
  • Multiplayer leagues with real-time leaderboards
  • Voice-enabled agent for hands-free predictions
  • Deployment to Cloud Run with proper CI/CD pipeline

🙏 Acknowledgments

Built for the Google Cloud Rapid Agent Hackathon 2026 in partnership with MongoDB. Special thanks to the Google Cloud and MongoDB teams for the excellent documentation and support.

Built With

Share this project:

Updates