医疗报告生成查询系统

MedAgent是一个端到端的AI驱动系统,通过Gemini CLI作为客户端界面和MCP Toolbox for Databases作为服务器端编排层,使用户能够查询医疗数据并生成结构化医疗报告。

  • by Madhu-712
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Madhu-712/MedAgent-Report-Generation-Query-Alloydb-using-MCP-Toolbox-and-Gemini-CLI-

使用说明


MedAgent——医疗报告生成与查询系统

使用MCP数据库工具箱、AlloyDB和Gemini CLI


📌 概述

MedAgent 是一个端到端的人工智能系统,使用户能够查询医疗数据并生成结构化的医疗报告 双子座命令行界面 作为客户端界面和 MCP数据库工具箱 作为服务器端编排层。

该项目展示了如何 模型上下文协议(MCP) 可用于将大型语言模型与数据库(AlloyDB)安全连接,以获取相关的医疗信息并生成智能的上下文响应。

此存储库用作 参考实现 用于:

  • MCP数据库工具箱

  • Gemini CLI集成

  • 支持数据库的LLM工作流

  • 医疗报告生成和查询管道


🧠 主要特点

  • 通过以下方式进行自然语言医学查询 双子座命令行界面
  • 使用安全的数据库访问 MCP工具箱
  • AlloyDB作为后端医疗数据存储
  • 结构化医疗报告生成
  • 模块化和可扩展的架构
  • 基于MCP的端到端LLM+数据库工作流

🏗 高级体系结构

流量: User → Gemini CLI(客户端)→ MCP工具箱(服务器)→ 合金数据库→ 响应

Gemini CLI从不直接访问数据库。 所有数据库交互都由中定义的MCP工具进行中介 tools.yaml.


📁 项目结构

MedAgent-Report-Generation-Query-Alloydb-using-MCP-Toolbox-and-Gemini-CLI-/
│
├── .env
├── README.md
├── Medical_Treatment_Plan.md
├── dbscript.sql
├── tools.yaml
│
└── Outputs/

📂 文件和目录细分

🔐 .env

包含以下所需的环境变量:

  • AlloyDB连接
  • MCP工具箱配置
  • 身份验证密钥

📄 tools.yaml

定义 MCP工具 由MCP工具箱服务器公开。

这些工具:

  • 描述数据库模式
  • 定义允许的SQL查询
  • 控制Gemini CLI可以访问的内容

目的:

  • 作为 合同 Gemini CLI和AlloyDB之间
  • 确保安全、模式感知的查询

🗄 dbscript.sql

SQL脚本用于:

  • 初始化AlloyDB架构
  • 创建医疗表格
  • 插入样本医疗数据(患者、诊断、治疗)

必须执行此脚本 在运行查询之前.


📘 Medical_Treatment_Plan.md

包含:

  • 医学领域背景
  • 样本治疗计划
  • Gemini CLI使用的提示或参考逻辑

用于指导:

  • 报告生成
  • 治疗总结
  • 医学推理背景

📤 Outputs/

商店:

  • 生成的医疗报告
  • 查询响应
  • Gemini CLI生成的结构化输出

🚀 入门指南

1.️⃣ 克隆仓库

git clone https://github.com/Madhu-712/MedAgent-Report-Generation-Query-Alloydb-using-MCP-Toolbox-and-Gemini-CLI.git
cd MedAgent-Report-Generation-Query-Alloydb-using-MCP-Toolbox-and-Gemini-CLI


### 2️⃣ Setup AlloyDB

Create an AlloyDB instance

Create table patientsinfo 

Load sample data into the table

### 3️⃣ Configure MCP Toolbox Server

Create MCP Toolbox using command:

export VERSION=0.23.0
curl -O https://storage.googleapis.com/genai-toolbox/v$VERSION/linux/amd64/toolbox
chmod +x toolbox

Update database connection details
Define tools.yaml for querying medical records

Start MCP server

./toolbox --tools-file="tools.yaml"

### 4️⃣ Configure Gemini CLI
Point Gemini CLI to MCP server endpoint

Enable MCP tool usage

sudo npm install -g @google/gemini-cli

export GOOGLE_CLOUD_PROJECT=<<YOUR_PROJECT_ID>>

gemini

### 5️⃣ Run End-to-End Query

eg: List all patients suffering from Anginia?
How many ppl suffer from Cancer .List all patients info.Youngest patient suffering from Depression?
What are possible treatment for this patient ?
Suggest treatment plan for getting patient treated in USA Newyork.


---

### 🔁 End-to-End Flow

1. User enters medical query in Gemini CLI
2. Gemini CLI analyzes intent
3. MCP tool is invoked from `tools.yaml`
4. MCP Toolbox executes SQL on AlloyDB
5. Results returned as structured data
6. Gemini CLI generates medical report
7. Output stored in `Outputs/` and displayed to user

---

## 🤝 Contribution

Contributions are welcome!

Steps:

1. Fork the repo
2. Create a feature branch
3. Commit your changes
4. Open a Pull Request

Please include:

* Clear commit messages
* Updated documentation where applicable

---

## 📜 License

This project is licensed under the **MIT License**.

---

## ⭐ Final Notes

This repository is ideal for:

* Learning **MCP-based LLM + Database integration**
* Demonstrating **Gemini CLI workflows**
* Building secure AI-powered data agents

---

# References
https://codelabs.developers.google.com/search-app-with-geminicli

https://codelabs.developers.google.com/genai-toolbox-for-alloydb

https://codelabs.developers.google.com/mcp-toolbox-bigquery-dataset