BA

bhancockio/adk-mcp-tutorial

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

90 stars 74 forks Качество 45 Тренд 15

bhancockio/adk-mcp-tutorial - кандидат на сервер MCP, импортированный из https://github.com/bhancockio/adk-mcp-tutorial.

Обзор

bhancockio/adk-mcp-tutorial - кандидат на сервер MCP, импортированный из https://github.com/bhancockio/adk-mcp-tutorial.

Обзор (машинный перевод)

Этот проект демонстрирует агент Agent Development Kit (ADK), который взаимодействует с локальной базой данных SQLite. Взаимодействие облегчается сервером Model Context Protocol (MCP), который предоставляет инструменты для запроса и изменения базы данных.

Проектная структура

Инструкции по установке

###1 Предпосылки Python 3.8 или новее Доступ к терминалу или командной строке

###2 Создание и активация виртуальной среды

Рекомендуется использовать виртуальную среду для управления зависимостями проекта.

Активировать виртуальную среду:

На macOS/Linux:

В Windows:

###3 Установите зависимость

Установите все необходимые пакеты Python с помощью pip:

###4 Настройка API-ключа Gemini (для агента ADK)

Агент ADK в этом проекте использует модель Gemini. Вам понадобится ключ Gemini API.

  1. Создать или использовать существующую учетную запись Google AI Studio.
  2. Получите ключ Gemini API из раздела API Keys. 3.Установите ключ API в качестве переменной среды. Создайте файл .env в корне adk-mcp проекта** (т.е. рядом с папкой local_mcp и readme.md):

[[Т4]] и [[Т5]] загрузят этот ключ.

###5 Создание базы данных и таблиц SQLite

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.

ADK Agent MCP Server

This project demonstrates an Agent Development Kit (ADK) agent that interacts with a local SQLite database. The interaction is facilitated by a Model Context Protocol (MCP) server that exposes tools to query and modify the database.

Project Structure

adk-mcp/
├── local_mcp/
│   ├── agent.py             # The ADK agent for the local SQLite DB
│   ├── server.py            # The MCP server exposing database tools
│   ├── create_db.py         # Script to initialize the SQLite database
│   ├── database.db          # The SQLite database file
│   └── __init__.py
├── remote_mcp_agent/        # Example agent for connecting to a remote MCP server
│   ├── agent.py             # The ADK agent configured for a remote MCP
│   └── __init__.py
├── .env                   # For GOOGLE_API_KEY (ensure it's in .gitignore if repo is public)
├── requirements.txt       # Python dependencies
└── readme.md              # This file

Setup Instructions

1. Prerequisites

  • Python 3.8 or newer
  • Access to a terminal or command prompt

2. Create and Activate Virtual Environment

It’s highly recommended to use a virtual environment to manage project dependencies.

# Create a virtual environment (e.g., named .venv)
python3 -m venv .venv

Activate the virtual environment:

On macOS/Linux:

# Activate virtual environment
source .venv/bin/activate

On Windows:

# Activate virtual environment
.venv\Scripts\activate

3. Install Dependencies

Install all required Python packages using pip:

# Install all dependencies from requirements.txt
pip install -r requirements.txt

4. Set Up Gemini API Key (for the ADK Agent)

The ADK agent in this project uses a Gemini model. You’ll need a Gemini API key.

  1. Create or use an existing Google AI Studio account.

  2. Get your Gemini API key from the API Keys section.

  3. Set the API key as an environment variable. Create a .env file in the root of the adk-mcp project (i.e., next to the local_mcp folder and readme.md):

    # .env
    GOOGLE_API_KEY=your_gemini_api_key_here
    

    The server.py and agent.py will load this key.

5. Create the SQLite Database and Tables

The project includes a script to create and populate the SQLite database (database.db) with some initial tables (users, todos) and dummy data.

Navigate to the local_mcp directory and run the script:

cd local_mcp
python3 create_db.py
cd ..

This will create local_mcp/database.db if it doesn’t already exist.

Running the Agent and MCP Server

The ADK agent (local_mcp/agent.py) is configured to automatically start the MCP server (local_mcp/server.py) when it initializes its MCP toolset.

To run the agent:

  1. Ensure your virtual environment is active and you are in the root directory of the adk-mcp project.
  2. Execute the agent script:
Открыть полный README на GitHub

Установка

npx -v
Новичок в MCP? Начните с руководства на mcpskill.org →