# DevOps MCP Agent with ADK
This project demonstrates an AI agent built with the **Agent Development Kit (ADK)** that connects to a **Model Context Protocol (MCP)** server to retrieve real‑world data from BigQuery and answer questions about CI/CD pipeline failures.
## Architecture
- **MCP Toolbox server** – a public MCP server (deployed on Cloud Run) that exposes a BigQuery tool.
- **ADK agent** – a Gemini‑powered agent that uses the MCP client (`toolbox_core`) to call the MCP server and format responses.
## Prerequisites
- A Google Cloud project with billing enabled.
- [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) installed and authenticated.
- Docker installed locally (for building the MCP server).
- Python 3.10+ with virtual environment support.
## Step‑by‑Step Deployment
### 1. Set up BigQuery data
Run the provided script to create a dataset and insert sample pipeline logs:
cd bigquery-setup Make the script executable: chmod +x bigquery-setup/setup_bigquery.sh ./setup_bigquery.sh
这将创建一个表 `devops.pipeline_logs` 有三个失败的管道示例。
### 2.部署MCP工具箱服务器
The Dockerfile automatically downloads the toolbox binary during the build, so no manual download is required.
cd mcp-toolbox-server
Build and push the container image
gcloud builds submit --tag gcr.io/YOUR_PROJECT_ID/mcp-toolbox-server .
Deploy to Cloud Run
gcloud run deploy mcp-toolbox-server \ --image gcr.io/YOUR_PROJECT_ID/mcp-toolbox-server \ --platform managed \ --region us-central1 \ --allow-unauthenticated
部署后注意服务URL(例如。, `https://mcp-toolbox-server-...-uc.a.run.app`).\
您将在下一步中使用此URL。
### 3.使用Web UI部署ADK代理
cd adk-agent
Copy the environment template and fill in your project ID and MCP server URL
cp .env.template .env
Edit .env and set:
GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID
MCP_SERVER_URL=https://mcp-toolbox-server-...-uc.a.run.app
Deploy using ADK (this builds and pushes the agent with the UI)
adk deploy cloud_run --with_ui .
当系统提示时,选择您的地区(例如。, `us-central1`).\
部署将输出云运行URL(例如。, `https://adk-default-service-name-...-uc.a.run.app`).
### 4.测试试剂
在浏览器中打开Cloud Run URL。\
选择代理 `devops_failure_analyzer` 从下拉列表中。\
键入一个问题,例如:
Show me the last 3 failed pipelines
代理将调用MCP工具箱服务器,查询BigQuery,并返回一个结构化的答案,其中包含管道ID、根本原因、类别和建议的修复。
## 清理
为避免持续收费,请删除Cloud Run服务和BigQuery数据集:
gcloud run services delete adk-default-service-name --region us-central1 gcloud run services delete mcp-toolbox-server --region us-central1 bq rm -r -f YOUR_PROJECT_ID:devops
## 使用Vertex AI(无API键)
代理人使用 **顶点AI** 默认情况下(如中所设置 `.env.template`).\
确保Cloud Run服务帐户具有该角色 `roles/aiplatform.user`.\
此角色通常由以下人员自动分配 `adk deploy` 指挥;如果没有,您可以手动添加:
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \ --member="serviceAccount:YOUR_PROJECT_NUMBER-compute@developer.gserviceaccount.com" \ --role="roles/aiplatform.user"
## 许可证
Apache 2.0