Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

MCP Server × PostgreSQL on MIMIC‑IV

Project goal: Evaluate whether a Model Context Protocol (MCP) Server layered on Azure Database for PostgreSQL can match—or outperform—direct SQL while reducing developer effort for large‑scale clinical analytics.


1. Problem Statement

Clinical datasets such as MIMIC‑IV contain tens of millions of rows and hundreds of attributes. Writing and maintaining raw SQL against such breadth is error‑prone and slow. We ask:

Can an MCP‑based abstraction simultaneously improve developer productivity and sustain (or enhance) runtime efficiency compared with traditional SQL‑only workflows?

To answer this we compare direct SQL against an MCP Server → Postgres path on identical workloads—ranging from a simple COUNT(*) on mimiciv_hosp.emar_detail (≈ 87 M rows) to multi‑table note aggregations.


2. Repository Layout

.
├── mimic-postgres/          # Scripts to create schemas & ingest MIMIC‑IV CSVs
├── src/            # Fork of azure_postgresql_mcp with env configs
└── README.md              # This file

3. Prerequisites

  • Python 3.10+
  • Node 18+ (optional, for additional MCP tooling)
  • Azure Database for PostgreSQL – Flexible Server (Standard_D4s v5 or larger)
  • MIMIC‑IV credential & data download permission
# core libs
pip install psycopg[binary] rich click pandas matplotlib
# benchmarking
pip install httpx pytest pytest‑benchmark
# MCP server
pip install mcp[cli] azure-identity azure-mgmt-postgresqlflexibleservers

4. Dataset Loading

cd data-loading
psql "$PGURI" -f 00_create_mimiciv_note_schema.sql
psql "$PGURI" -f 01_create_emar_tables.sql
python 02_bulk_copy.py --csv-root /path/to/mimic-iv

Estimated ingest time on Standard_D4s: ~45 min for 72 GB (11.7 M note rows + 87 M EMAR rows).


5. Starting the MCP Server

cd mcp-server
python azure_postgresql_mcp.py

Environment variables (PGHOST, PGUSER, PGPASSWORD, PGDATABASE) must be set or supplied in your Claude Desktop / VS Code configuration.

To use Microsoft Entra authentication instead of a password, set:

export AZURE_USE_AAD=True
export AZURE_SUBSCRIPTION_ID=...
export AZURE_RESOURCE_GROUP=...

6. Running Baselines

6.1 Direct SQL

python benchmarks/run_sql.py --query count_emar_detail

Outputs a single line like:

count=87,371,064 elapsed=101550.2 ms

6.2 MCP Server

python benchmarks/run_mcp.py --query count_emar_detail

Sample output:

count=87,371,064 elapsed=67560.1 ms

Multiple runs (default = 30) are aggregated into CSV under benchmarks/results/.


7. Key Results (Preview)

Query Direct SQL MCP Server Δ (ms) Δ %
COUNT(*) on emar_detail 101,550 ms 67,560 ms −33,990 −33 %
LOC to implement workload #1 68 23 −45 −66 %

8. Future Work

  • Enable Entra ID + RBAC and re‑benchmark connection latency.
  • Add pgvector semantic‑search benchmark via a custom MCP tool.
  • Run clinician UX trials comparing MCP+Claude vs. SQL IDE.

9. License & Citation

MIT License — see LICENSE.

If you use this code or results, please cite:

Menon S.K., N. (2025). MCP Server × PostgreSQL on MIMIC‑IV: productivity and performance comparison. Georgia Tech CS 6423 Final Project Report.

10. Acknowledgements

  • PhysioNet for access to the MIMIC‑IV dataset
  • Azure Database for PostgreSQL
  • Anthropic for the MCP specification and Claude Desktop tooling

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • Byaidu
  • PDF科学纸翻译带有保留格式的pdf -基于ai完整保留排版的pdf文档全文双语翻译

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

    Reviews

    3 (1)
    Avatar
    user_BI5Ltbsn
    2025-04-23

    The mimic-mcp-server developed by ambakick is an outstanding tool for anyone looking to streamline their server management processes. Despite lacking specific product details, I can confidently say that its user-friendly interface and efficiency make it a must-have for tech enthusiasts. Highly recommend!