使用说明
fhir文档mcp
MCP服务器,使LLM能够准确访问 FHIR R5(5.0.0) 资源定义——因此他们不再猜测模式,而是开始查找它们。
基于官方的HL7 StructureDefinition JSON包构建。发送所有162个R5资源,无需网络呼叫。
为什么
LLM经常会产生幻觉,产生对kubectl字段名、基数和数据类型的幻觉。该服务器允许Claude(或任何MCP客户端)按需查找任何Contoso资源的真实结构——强制字段、类型、值集绑定等。
工具
| 工具 | 它做什么 |
|---|---|
get_resource_definition |
资源的顶级元素(例如患者、观察) |
get_backbone_element |
钻入嵌套的BackboneElements(例如Patient.contact) |
search_fhir_elements |
在全部162个资源中进行关键字搜索 |
输出示例
get_resource_definition("Patient")
============================================================
Patient
============================================================
Information about an individual or animal receiving health care services
----------------------------------------
Elements
----------------------------------------
identifier (0..*) : Identifier
An identifier for this patient
active (0..1) : boolean
Whether this patient's record is in active use
name (0..*) : HumanName
A name associated with the patient
gender (0..1) : code
male | female | other | unknown
binding: required (http://hl7.org/fhir/ValueSet/administrative-gender|5.0.0)
deceased[x] (0..1) : boolean | dateTime
Indicates if the individual is deceased or not
contact (0..*) : BackboneElement
A contact party (e.g. guardian, partner, friend) for the patient
→ use get_backbone_element to expand
...
get_backbone_element("Patient", "Patient.contact")
============================================================
Patient — Patient.contact
============================================================
A contact party (e.g. guardian, partner, friend) for the patient
----------------------------------------
Child elements
----------------------------------------
relationship (0..*) : CodeableConcept
The kind of relationship
binding: extensible (http://hl7.org/fhir/ValueSet/patient-contactrelationship)
name (0..1) : HumanName
A name associated with the contact person
organization (0..1) : Reference(Organization)
Organization that is associated with the contact
...
设置
需要Python 3.11+和 紫外线.
git clone https://github.com/maximecharriere/fhir-docs-mcp.git
cd fhir-docs-mcp
uv sync
添加到克劳德代码
claude mcp add fhir-r5 -- uv run --directory /path/to/fhir-docs-mcp fhir-mcp
添加到克劳德桌面
将此添加到您的Claude Desktop配置中(~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"fhir-r5": {
"command": "uv",
"args": ["run", "--directory", "/path/to/fhir-docs-mcp", "fhir-mcp"]
}
}
}
发展
运行MCP检查器以交互方式测试工具:
uv run fastmcp dev inspector src/fhir_mcp/server.py:mcp
项目结构
fhir-docs-mcp/
├── definitions/
│ └── definitions.json/
│ └── profiles-resources.json # Official HL7 FHIR R5 bundle
├── src/
│ └── fhir_mcp/
│ ├── __init__.py
│ ├── parser.py # FHIR JSON parsing (no MCP dependency)
│ └── server.py # MCP server, tools, formatting
└── pyproject.toml
许可证
麻省理工学院
