Agentic-AI---YouTube-Search-Assistant-with-ADK-MCP-and-Gemma-3-

このプロジェクトは、Googleのエージェント開発キット(ADK)、モデルコンテキストプロトコル(MCP)、およびGemma 3モデルを使用してYouTube検索機能を実装したものです。ユーザーがYouTube動画を効率的に検索できるように設計されており、データフローやアーキテクチャの詳細が含まれています。

GitHubスター

0

ユーザー評価

未評価

フォーク

0

イシュー

0

閲覧数

1

お気に入り

0

README
YouTube Search Assistant with ADK, MCP and Gemma 3

A practical implementation demonstrating YouTube search functionality using Google's Agent Development Kit (ADK), Model Context Protocol (MCP), and the Gemma 3 model via Ollama.

ADK Gemma3 Demo

ADK Gemma Web Demo

📚 Table of Contents
🔍 Introduction

This project showcases how to leverage Google's ADK (Agent Development Kit) and MCP (Model Context Protocol) to build an agent powered by Gemma 3, Google's latest large language model. It demonstrates how to:

  • Connect to locally-hosted Gemma 3 via Ollama
  • Implement YouTube search functionality using MCP
  • Create a conversational agent that can format and present search results
🏗️ Architecture
🧩 Core Components
  • Google ADK - Provides the agent framework
  • Model Context Protocol (MCP) - Standardizes tool communication
  • Gemma 3 (12B) - Powers the language understanding and generation
  • Ollama - Hosts the Gemma model locally
  • MCP YouTube Search - Provides YouTube search capabilities
  • Python 3.9+ - Base runtime environment
📊 Architecture Diagram

YouTube Search Assistant Architecture

🔄 Data Flow
  1. User submits a query through the interface
  2. ADK Agent Framework processes the query and determines intent
  3. If a YouTube search is needed:
    • The request is routed to the MCP Tool Registry
    • The MCP YouTube Search tool receives the query
    • SERP API is called to fetch YouTube results
    • Results are returned through the MCP standardized format
  4. Gemma 3 model (via Ollama and LiteLlm):
    • Receives the search results
    • Generates a natural language response
    • Formats the search results into readable bullet points
  5. The formatted response is returned to the user interface
✨ Technology Highlights
  • Google ADK
    Manages conversation flow and tool orchestration.
  • Model Context Protocol (MCP)
    Enables standardized communication between models and tools.
  • Gemma 3 via Ollama
    Delivers high-quality text generation with tool-calling capabilities.
  • LiteLlm Integration
    Connects ADK to Ollama-hosted models seamlessly.
  • SERP API
    Provides access to YouTube data through search API.
🚀 Features
  • 🔍 Search for YouTube videos using natural language queries
  • 🤖 Powered by Gemma 3 running on Ollama
  • 📋 Formats search results in a clean, easy-to-read format
  • 🛠️ Built with Google's Agent Development Kit (ADK)
  • 🔄 Integrates MCP (Model Context Protocol) for seamless tool communication
🧠 Core Concepts
ADK - Agent Development Kit

Agent Development Kit (ADK) is an open-source, code-first Python toolkit for building intelligent AI agents.

MCP - Model Context Protocol

Model Context Protocol (MCP) is a standard for communication between models and tools. It allows for:

  • Consistent tool invocation patterns
  • Structured data exchange
  • Tool composition and chaining
  • Language-agnostic tool definitions
Agents in ADK

An Agent in ADK acts as the orchestrator for AI interactions. In this project, we use LlmAgent, which is a core component in ADK acting as the "thinking" part of your application that:

  • Leverages a Large Language Model (LLM) for reasoning and understanding
  • Manages conversation history and context
  • Coordinates tool usage based on user queries
Tools with MCP

Tools in this project are implemented using the MCP (Model Context Protocol) framework, which:

  • Defines a standard interface for tool interaction
  • Makes tools easily discoverable by the LLM
  • Structures input/output formats
  • Facilitates tool composition

The MCP YouTube Search tool provides a standardized way for the agent to interact with YouTube search functionality.

Ollama Integration

Ollama provides a way to run Gemma 3 and other large language models locally. Google ADK connects to Ollama through:

  • LiteLlm - A wrapper that standardizes communication with different LLM providers
  • Custom configurations to optimize model performance
📋 Requirements
  • Python 3.9+
  • Ollama installed with Gemma 3 model
  • A SERP API key for YouTube search
🚦 Getting Started
1. Installation Steps

Clone this repository:

git clone https://github.com/arjunprabhulal/adk-mcp-gemma3.git
cd adk-mcp-gemma3
2. Setup
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
Install dependencies:
pip install -r requirements.txt
Set up your SERP API key:

Create a .env file in the root directory with your SERP API key:

SERP_API_KEY=your_serp_api_key_here
Pull the Gemma 3 model:
ollama pull gemma3:12b
3. Usage
Option 1: Web-based UI (Recommended for debugging)

Run the agent using ADK's browser-based developer UI:

# Navigate to the parent directory
cd adk-mcp-gemma3

# Start the web interface
adk web

You should see output similar to this:

ADK Web Command Output

Then open the URL provided (usually http://localhost:8000) in your browser.

  • Select "search" from the dropdown menu in the top-left corner
  • Type your query in the chat interface
  • You can inspect tool calls, model responses, and see detailed execution flow
Option 2: Command Line

Run the agent directly:

python -m search

You can now interact with the agent by asking it to find YouTube videos.

Example queries:

  • "Find videos about Google Cloud Next 25"
  • "Search for YouTube tutorials on Python programming"
  • "Look for videos about machine learning for beginners"
🔄 How It Works

The implementation follows these steps:

  1. Agent Initialization:

    • Creates an LlmAgent with a reference to the Ollama-hosted Gemma 3 model
    • Configures the agent with appropriate instructions
    • Adds the YouTube search tool to the agent's capabilities
  2. Tool Definition:

    • Defines a YouTube search function through MCP
    • MCP provides a standardized way for the model to interact with the tool
    • The tool connects to SERP API for YouTube search functionality
  3. Query Processing:

    • User query is passed to the agent
    • Gemma 3 decides whether to use the YouTube search tool based on the query
    • If needed, the model formulates an appropriate search query
    • Results are processed and formatted by the model
  4. Response Generation:

    • The agent processes all information and formats the search results
    • Output is returned to the user as a clean, bulleted list
    • Each result includes title, link, channel, description, and metadata
📁 Project Structure
adk_mcp_gemma3/
├── Images/
│   ├── adk-gemma3.gif           # Demo gif of the application
│   ├── adk-gemma-web.gif        # Web interface demo
│   ├── adk-gemma3-mcp-architecture.png  # Architecture diagram
│   └── adk-web-command.png      # Web command output example
├── mcp_youtube_search/
│   ├── __init__.py              # Package initialization
│   ├── cli.py                   # Command line interface
│   └── server.py                # MCP server implementation
├── search/
│   ├── __init__.py              # Package initialization
│   └── agent.py                 # Agent implementation with ADK
├── .env                         # Environment variables (not in version control)
├── .gitignore                   # Git ignore file
├── README.md                    # Project documentation
├── LICENSE                      # MIT license
└── requirements.txt             # Dependencies
作者情報
Asharam Khatik

Student at IIT Madras

IIT MADRAS

3

フォロワー

30

リポジトリ

0

Gist

1

貢献数

トップ貢献者

スレッド