fhir-patient-consent-mcp-server
fhir-patient-consent-mcp-server
一个 MCP 服务器,让模型可以询问关于患者、患者的胰岛素泵,以及哪些人已获同意查看这些数据的问题——所有数据都实时来自 FHIR (R4) 数据存储。本服务器不保存任何数据;每一个回答都是一次实时的 FHIR REST 查询。
它是 fhir-consent-service(一个将 Patient/Device/Consent 写入 FHIR 的 Spring Boot API)的配套服务,但与它没有任何代码依赖。本服务器只依赖 FHIR 的传输格式,因此可用于任何 FHIR R4 端点。
工具
工具 | 用途 |
| 按 MRN 和/或姓氏查找患者 |
| 按 FHIR id 获取某位患者的人口学信息 |
| 列出患者的设备(通过 SNOMED CT |
| 列出患者的数据共享同意(合作方、目的、数据类别、时间段) |
| 授权检查:合作方 X 当前是否对患者 Y 拥有有效同意? |
Related MCP server: FHIR MCP Server
资源
fhir-chart://{patientId} —— 一个为患者聚合的 JSON“病历”(人口学资料 + 设备 + 有效同意),目的是让宿主应用直接将其附加到上下文中,而不是由模型通过多次工具调用来组装。参见 docs/architecture.md,了解为什么它是一个资源而不是第六个工具。
设置
npm install
npm run build将其指向一个 FHIR 服务器
export FHIR_BASE_URL=http://localhost:8081/fhir # default shown
export FHIR_AUTH_TOKEN=... # optional bearer token要获得可供查询的数据,最简单的方法是:运行 fhir-consent-service 的 docker compose up -d(会在 :8081 上启动一个本地 HAPI FHIR JPA 服务器),然后通过它的 REST API 创建患者、设备与同意(consent),再在这里查询同一个数据存储。
直接运行(用于 stdio 测试)
npm run dev将其注册到 MCP 客户端
对于 Claude Desktop / Claude Code,加入你的 MCP 配置:
{
"mcpServers": {
"fhir-patient-consent": {
"command": "node",
"args": ["/absolute/path/to/fhir-patient-consent-mcp-server/dist/index.js"],
"env": {
"FHIR_BASE_URL": "http://localhost:8081/fhir"
}
}
}
}先运行 npm run build,确保 dist/index.js 存在。
连接后可以问的示例问题
"查找 MRN 为 MRN-778001 的患者。"
"患者 123 用的是哪款胰岛素泵?序列号是多少?"
"GlucoVue Remote Monitoring 是否已获同意查看患者 123 的设备数据?"
"显示患者 123 的完整病历。" (调用
fhir-chart://资源)
测试
npm test单元测试覆盖映射层(src/mappers/*.ts),包括 isConsentActiveForPartner 中的同意授权逻辑——特别是它如何处理已撤销的同意、尚未开始/已过期的时间段,以及开放日期(缺少 end)的时间段,因为这些情况最容易在细节上出错。
本仓库中没有针对真实 FHIR 服务器的集成测试(这一点与使用 Testcontainers 的 fhir-consent-service 不同),因为本服务器没有可写入的数据路径来注入种子数据——它必须依赖那个仓库(或复制其资源创建逻辑)仅仅为了搭建测试夹具。如果这个仓库将来加入了数据种子脚本,届时再补上即可。
注意: 本仓库是在无法访问 npm 注册表的沙箱环境中编写的,因此
npm install/npm run build/npm test实际上都没有在这里执行过。代码以@modelcontextprotocol/sdk@^1.12为目标;如果你所安装的版本中,SDK 的server.tool(...)/server.resource(...)签名已改为registerTool/registerResource,修复方式只是机械性的——请查看 SDK 自带的 README/CHANGELOG。
项目结构
src/
├── index.ts Server entry point, registers all tools/resources
├── fhirClient.ts Thin fetch-based FHIR REST client
├── tools/ One file per MCP tool
├── resources/ One file per MCP resource
├── mappers/ FHIR JSON -> summary objects + consent auth logic
└── util/results.ts Shared tool-result formatting helpers安全说明
本服务器不会对 PHI 做任何脱敏处理,只会把 FHIR 服务器返回的内容直接透传。如果要在真实患者数据上部署,请把访问控制放在 FHIR 服务器本身(本服务器会把 FHIR_AUTH_TOKEN 作为 Bearer 令牌转发,但不负责令牌的获取/刷新),并认真考虑哪些内容应当或根本不应当暴露给 MCP 客户端。
许可证
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables LLM-based agents to interact with FHIR healthcare data through natural language prompts, providing full CRUD operations on FHIR resources, document processing, and semantic search capabilities.1397MIT
- -licenseNot gradedqualityNot gradedmaintenanceEnables seamless integration with FHIR APIs for healthcare applications, allowing users to search, retrieve, create, update, and analyze clinical information through natural language interactions. Supports SMART-on-FHIR authentication and works with various healthcare systems like EPIC and HAPI FHIR servers.
- AlicenseNot gradedqualityCmaintenanceEnables natural-language querying of a mock legacy healthcare database and returns validated FHIR resources (Patient, Observation, Condition).MIT
Related MCP Connectors
Securely access and manage FHIR healthcare data stored in Medplum.
Hosted MCP server exposing US hospital procedure cost data to AI assistants
An AI concierge that turns static forms into adaptive AI conversations. From any MCP client.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/scollard001/fhir-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server