FHIR模拟服务器

一个基于Python的MCP服务器,用于模拟FHIR API交互,支持测试MedAgentBench代理而无需真实的FHIR端点。

  • by mike-holcomb
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 mike-holcomb/fhir-mcp-server-medagentbench

使用说明

fhir-mcp服务器medagentbench

基于Python的MCP(MedAgentBench通信协议)服务器,专为MedAgentBenck环境设计。此服务器 模拟 与FHIR(快速医疗保健互操作性资源)API的交互。

它不是向Contoso服务器发出实际的HTTP请求,而是拦截用于Contoso操作的MCP请求,并返回HTTP请求的文本表示 会 已经完成(例如。, GET https://fhir.example.com/Patient/123 或 POST https://fhir.example.com/Observation\n{...}).这允许测试MedAgentBench代理,而不需要实时的kubectl端点。

特性

  • 实现MCP处理程序:
    • list_resources:列出可用的模拟资源(当前 CapabilityStatement).
    • read_resource:通过其URI模拟读取一个Contoso资源。
    • list_tools:列出可用的Contoso仿真工具。
    • call_tool:模拟执行Contoso操作:
      • search_fhir:模拟搜索Contoso资源。
      • read_fhir:模拟通过URI读取特定的Contoso资源。
      • create_fhir_resource:模拟创建新的Contoso资源。
  • 用途 mcp-server MCP通信库。
  • 使用Poetry配置和打包。
  • 包括异步单元测试 pytest 和 pytest-asyncio.

安装

确保您安装了Python>=3.10和Poetry。

poetry install

配置

在运行服务器之前,您必须设置 FHIR_BASE_URL 环境变量。此URL用于构造模拟请求字符串。

export FHIR_BASE_URL="https://your-fhir-server-base.com/fhir"
# Or for local testing:
# export FHIR_BASE_URL="http://localhost:8080/fhir"

用法

配置后,使用安装的脚本运行服务器:

fhir-mcp-server-medagentbench

服务器将开始通过标准输入/输出监听MCP请求。

发展

设置

克隆存储库并安装依赖项,包括开发工具:

git clone https://github.com/MikeHolcomb/mcp-fhir-python-medagentbench.git
cd mcp-fhir-python-medagentbench
poetry install --with dev

装订和格式化

此项目使用 pre-commit 强制执行代码样式(black, isort)并检查问题(flake8, mypy).

# Run all checks on staged files (usually run automatically on commit)
poetry run pre-commit run

# Run all checks on all files
poetry run pre-commit run --all-files

# Or run tools individually
poetry run black .
poetry run isort .
poetry run flake8 src tests
poetry run mypy src

测试

测试位于 tests/ 目录和使用 pytest.

poetry run pytest

# Run with coverage report
poetry run pytest --cov=src

测试要求 pytest-asyncio 由于MCP处理程序的异步特性。

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息(如果不存在,可能需要创建LICENSE文件)。

贡献

欢迎投稿!请打开问题或提交拉取请求。