
bhancockio/adk-mcp-tutorial
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
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.
- Создать или использовать существующую учетную запись Google AI Studio.
- Получите ключ 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.
-
Create or use an existing Google AI Studio account.
-
Get your Gemini API key from the API Keys section.
-
Set the API key as an environment variable. Create a
.envfile in the root of theadk-mcpproject (i.e., next to thelocal_mcpfolder andreadme.md):# .env GOOGLE_API_KEY=your_gemini_api_key_hereThe
server.pyandagent.pywill 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:
- Ensure your virtual environment is active and you are in the root directory of the
adk-mcpproject. - Execute the agent script:
Установка
npx -v