# langcare/langcare-mcp-fhir architecture

> Architecture diagram of the GitHub repository langcare/langcare-mcp-fhir, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/langcare/langcare-mcp-fhir
- Repository: https://github.com/langcare/langcare-mcp-fhir

## Overview

LangCare is an MCP server that proxies AI-agent requests to FHIR R4 electronic medical records: clients invoke MCP tools, the server dispatches generic read/search/create/update operations, and provider-specific clients reach the configured FHIR backend. The repository also includes interactive MCP apps, a Python CLI, and a healthcare voice agent. The graph follows documented and excerpted wiring; unsampled subsystems are included only where their presence and role are documented, with evidence limits reflected in omitted links.

Main entry points: [`cmd/server/main.go`](https://github.com/langcare/langcare-mcp-fhir/blob/main/cmd/server/main.go) (Server Startup), [`internal/tools`](https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/tools) (FHIR Operations), [`internal/mcp/server.go`](https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/mcp/server.go) (MCP Tool Server), [`internal/transport`](https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/transport) (HTTP and stdio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["MCP Server"]
  node_config["Configuration<br/>[config.go]"]
  node_entry["Server Startup<br/>[main.go]"]
  node_mcp["MCP Tool Server<br/>[server.go]"]
  node_transport["HTTP and stdio"]
  node_security["HTTP Security"]
  node_toolregistry["Tool Registry<br/>[registry.go]"]
  node_audit["PHI Audit Logging<br/>[logger.go]"]
end

subgraph group_fhir["FHIR Access"]
  node_operations["FHIR Operations"]
  node_client["FHIR Client Factory<br/>[client.go]"]
  node_providers["FHIR Providers"]
end

subgraph group_apps["Client Interfaces"]
  node_cli["LangCare CLI<br/>[cli.py]"]
  node_mcpclient["CLI MCP Client<br/>[mcp_client.py]"]
  node_explorer["FHIR Explorer<br/>[app.tsx]"]
  node_chart["Patient Chart Review<br/>[app.tsx]"]
end

subgraph group_voice["Voice Agent"]
  node_voicebot["Voice Assistant<br/>[bot.py]"]
  node_prompt["Clinical Prompt<br/>[base_prompt.py]"]
  node_webhook["Voice Webhook<br/>[server.py]"]
end

node_agent(("AI Agent"))
node_emr[("FHIR R4 EMR")]

node_agent -->|"calls MCP tools"| node_transport
node_entry -->|"loads"| node_config
node_entry -->|"creates"| node_client
node_entry -->|"creates"| node_audit
node_entry -->|"registers tools"| node_toolregistry
node_entry -->|"creates"| node_mcp
node_entry -->|"starts"| node_transport
node_transport -->|"serves"| node_mcp
node_transport -->|"wraps with"| node_security
node_mcp -->|"dispatches through"| node_toolregistry
node_toolregistry -->|"registers"| node_operations
node_operations -->|"calls FHIR methods"| node_client
node_operations -->|"logs access"| node_audit
node_client -->|"selects provider"| node_providers
node_providers -.->|"proxies requests"| node_emr
node_cli -->|"uses"| node_mcpclient
node_mcpclient -.->|"sends HTTP requests"| node_transport
node_explorer -->|"calls FHIR tools"| node_operations
node_chart -->|"calls FHIR tools"| node_operations
node_mcp -->|"registers app resource"| node_explorer
node_mcp -->|"registers app resource"| node_chart
node_voicebot -->|"uses prompt"| node_prompt
node_voicebot -->|"calls FHIR tools"| node_operations
node_webhook -.->|"starts session"| node_voicebot

click node_config "https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/config/config.go"
click node_entry "https://github.com/langcare/langcare-mcp-fhir/blob/main/cmd/server/main.go"
click node_mcp "https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/mcp/server.go"
click node_transport "https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/transport"
click node_security "https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/middleware"
click node_toolregistry "https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/tools/registry.go"
click node_audit "https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/audit/logger.go"
click node_operations "https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/tools"
click node_client "https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/fhir/client.go"
click node_providers "https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/fhir/providers"
click node_cli "https://github.com/langcare/langcare-mcp-fhir/blob/main/cli/langcare/cli.py"
click node_mcpclient "https://github.com/langcare/langcare-mcp-fhir/blob/main/cli/langcare/mcp_client.py"
click node_explorer "https://github.com/langcare/langcare-mcp-fhir/blob/main/apps/fhir-explorer/src/app.tsx"
click node_chart "https://github.com/langcare/langcare-mcp-fhir/blob/main/apps/patient-chart-review/src/app.tsx"
click node_voicebot "https://github.com/langcare/langcare-mcp-fhir/blob/main/pipecat-agent/server/bot.py"
click node_prompt "https://github.com/langcare/langcare-mcp-fhir/blob/main/pipecat-agent/server/prompts/base_prompt.py"
click node_webhook "https://github.com/langcare/langcare-mcp-fhir/blob/main/pipecat-agent/webhook/server.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config,node_entry,node_mcp,node_transport,node_security,node_toolregistry,node_audit toneBlue
class node_operations,node_client,node_providers,node_emr toneAmber
class node_cli,node_mcpclient,node_explorer,node_chart toneMint
class node_voicebot,node_prompt,node_webhook toneRose
class node_agent toneIndigo
```

## Components

### MCP Server

- [Configuration](https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/config/config.go): `internal/config/config.go`
- [Server Startup](https://github.com/langcare/langcare-mcp-fhir/blob/main/cmd/server/main.go): `cmd/server/main.go`
- [MCP Tool Server](https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/mcp/server.go): `internal/mcp/server.go`
- [HTTP and stdio](https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/transport): `internal/transport`
- [HTTP Security](https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/middleware): `internal/middleware`
- [Tool Registry](https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/tools/registry.go): `internal/tools/registry.go`
- [PHI Audit Logging](https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/audit/logger.go): `internal/audit/logger.go`

### FHIR Access

- [FHIR Operations](https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/tools): `internal/tools`
- [FHIR Client Factory](https://github.com/langcare/langcare-mcp-fhir/blob/main/internal/fhir/client.go): `internal/fhir/client.go`
- [FHIR Providers](https://github.com/langcare/langcare-mcp-fhir/tree/main/internal/fhir/providers): `internal/fhir/providers`

### Client Interfaces

- [LangCare CLI](https://github.com/langcare/langcare-mcp-fhir/blob/main/cli/langcare/cli.py): `cli/langcare/cli.py`
- [CLI MCP Client](https://github.com/langcare/langcare-mcp-fhir/blob/main/cli/langcare/mcp_client.py): `cli/langcare/mcp_client.py`
- [FHIR Explorer](https://github.com/langcare/langcare-mcp-fhir/blob/main/apps/fhir-explorer/src/app.tsx): `apps/fhir-explorer/src/app.tsx`
- [Patient Chart Review](https://github.com/langcare/langcare-mcp-fhir/blob/main/apps/patient-chart-review/src/app.tsx): `apps/patient-chart-review/src/app.tsx`

### Voice Agent

- [Voice Assistant](https://github.com/langcare/langcare-mcp-fhir/blob/main/pipecat-agent/server/bot.py): `pipecat-agent/server/bot.py`
- [Clinical Prompt](https://github.com/langcare/langcare-mcp-fhir/blob/main/pipecat-agent/server/prompts/base_prompt.py): `pipecat-agent/server/prompts/base_prompt.py`
- [Voice Webhook](https://github.com/langcare/langcare-mcp-fhir/blob/main/pipecat-agent/webhook/server.py): `pipecat-agent/webhook/server.py`

### Other components

- **AI Agent**
- **FHIR R4 EMR**

## Connections

- AI Agent → HTTP and stdio: calls MCP tools (evidence: `README.md`)
- Server Startup → Configuration: loads (evidence: `cmd/server/main.go`)
- Server Startup → FHIR Client Factory: creates (evidence: `cmd/server/main.go`)
- Server Startup → PHI Audit Logging: creates (evidence: `cmd/server/main.go`)
- Server Startup → Tool Registry: registers tools (evidence: `cmd/server/main.go`)
- Server Startup → MCP Tool Server: creates (evidence: `cmd/server/main.go`)
- Server Startup → HTTP and stdio: starts (evidence: `cmd/server/main.go`)
- HTTP and stdio → MCP Tool Server: serves (evidence: `internal/transport/http.go`)
- HTTP and stdio → HTTP Security: wraps with (evidence: `internal/transport/http.go`)
- MCP Tool Server → Tool Registry: dispatches through (evidence: `internal/mcp/server.go`)
- Tool Registry → FHIR Operations: registers
- FHIR Operations → FHIR Client Factory: calls FHIR methods (evidence: `internal/tools/fhir_search.go`)
- FHIR Operations → PHI Audit Logging: logs access (evidence: `internal/tools/fhir_search.go`)
- FHIR Client Factory → FHIR Providers: selects provider (evidence: `internal/fhir/client.go`)
- FHIR Providers → FHIR R4 EMR: proxies requests (evidence: `README.md`)
- LangCare CLI → CLI MCP Client: uses (evidence: `cli/langcare/cli.py`)
- CLI MCP Client → HTTP and stdio: sends HTTP requests
- FHIR Explorer → FHIR Operations: calls FHIR tools (evidence: `README.md`)
- Patient Chart Review → FHIR Operations: calls FHIR tools (evidence: `apps/patient-chart-review/src/app.tsx`)
- MCP Tool Server → FHIR Explorer: registers app resource (evidence: `internal/mcp/server.go`)
- MCP Tool Server → Patient Chart Review: registers app resource (evidence: `internal/mcp/server.go`)
- Voice Assistant → Clinical Prompt: uses prompt (evidence: `pipecat-agent/server/bot.py`)
- Voice Assistant → FHIR Operations: calls FHIR tools (evidence: `pipecat-agent/server/bot.py`)
- Voice Webhook → Voice Assistant: starts session
