Logo de 结合 MCP 和 FHIR 的电子健康记录工具

结合 MCP 和 FHIR 的电子健康记录工具

Comunidade
jmandel

Connect to an EHR and make clinical data available via MCP

Publicado porjmandel
Repositóriohealth-record-mcp
IdiomaTypeScript
Forks
36
Estrelas
87
Ferramentas disponíveis
0
Tipo de transportestdio, streamable-http
Categorias
LicençaMIT
Links
  • Conecte ferramentas a fluxos de trabalho de IA

    结合 MCP 和 FHIR 的电子健康记录工具 disponibiliza recursos MCP que podem ser usados por clientes e agentes de IA compatíveis.

  • Ferramentas disponíveis: 0

    Confira abaixo as ações que o cliente MCP pode executar, com nomes e descrições quando fornecidos pelo servidor.

  • Configuração pronta para copiar

    Use os exemplos de instalação para configurar este servidor no seu cliente MCP preferido.

  • Indicadores da comunidade de código aberto

    Estrelas: 87 e forks: 36 no repositório vinculado.

EHR Tools with MCP and FHIR

EHR Tools Overview

https://youtu.be/K0t6MRyIqZU?si=Mz4d65DcAD3i2YbO

This project acts as a specialized server providing tools for Large Language Models (LLMs) and other AI agents to interact with Electronic Health Records (EHRs). It leverages the SMART on FHIR standard for secure data access and the Model Context Protocol (MCP) to expose the tools.

Think of it as a secure gateway and toolkit enabling AI to safely access and analyze patient data from diverse EHR systems.

The Core Idea

The system works in three main stages:

  1. SMART on FHIR Client (Implemented within this project): Connects securely to an EHR using the standard SMART App Launch framework. It extracts a wide range of patient information, including both structured data (like conditions, medications, labs) and unstructured clinical notes or attachments.
  2. MCP Server (This Project): Takes the extracted EHR data and makes it available through a set of powerful tools accessible via the Model Context Protocol. These tools allow external systems (like AI models) to query and analyze the data without needing direct access to the EHR itself.
  3. AI / LLM Interface (External Consumer): An AI agent or Large Language Model connects to the MCP Server and uses the provided tools to "ask questions" about the patient's record, perform searches, or run custom analyses.

Available Tools

The MCP Server offers several tools for interacting with the loaded EHR data:

  • grep_record: Performs text or regular expression searches across all parts of the fetched record (structured FHIR data + text from notes/attachments). Ideal for finding keywords or specific mentions (e.g., "diabetes", "aspirin").
  • query_record: Executes read-only SQL SELECT queries directly against the structured FHIR data. Useful for precise lookups based on known FHIR resource structures (e.g., finding specific lab results by LOINC code).
  • eval_record: Executes custom JavaScript code directly on the fetched data (FHIR resources + attachments). Offers maximum flexibility for complex calculations, combining data from multiple sources, or custom formatting.

This setup allows AI tools to leverage comprehensive EHR data through a standardized and secure interface.

(Developer setup and usage details can be found within the codebase and specific module documentation.)


Components & Usage

This project offers different ways to fetch EHR data and expose it via MCP tools:

1. Standalone SMART on FHIR Web Client

This project includes a self-contained web application that allows users to connect to their EHR via SMART on FHIR and fetch their data.

  • Hosted Version: You can use a publicly hosted version at:
    https://mcp.fhir.me/ehr-connect#deliver-to-opener:$origin
    (Replace $origin with the actual origin of the window that opens this link).
  • Filtering Brands (?brandTags): You can filter the list of EHR providers shown on the connection page by adding the brandTags query parameter to the URL. Provide a comma-separated list of tags. Only brands matching all provided tags (from their configuration in brandFiles) will be displayed. It supports both OR (comma-separated) and AND (caret ^ separated) logic, with AND taking precedence.
    • ?brandTags=epic,sandbox: Shows brands tagged with epic OR sandbox.
    • ?brandTags=epic^dev: Shows brands tagged with both epic AND dev.
    • ?brandTags=epic^dev,sandbox^prod: Shows brands tagged with (epic AND dev) OR (sandbox AND prod).
    • If the parameter is omitted, it defaults to showing brands tagged with prod.
    • Example: .../ehr-connect?brandTags=hospital^us: Shows brands tagged with hospital AND us.
  • How it Works: When opened, this page prompts the user to select their EHR provider. It then initiates the standard SMART App Launch flow, redirecting the user to their EHR's login page. After successful authentication and authorization, the client fetches a comprehensive set of FHIR resources (Patient, Conditions, Observations, Medications, Documents, etc.) and attempts to extract plaintext from any associated attachments (like PDFs, RTF, HTML found in DocumentReference).
  • Data Output (ClientFullEHR): Once fetching is complete, the client gathers all the data into a ClientFullEHR JSON object. This object contains:
    • fhir: A dictionary where keys are FHIR resource types (e.g., "Patient") and values are arrays of the corresponding FHIR resources.
    • attachments: An array of processed attachment objects, each including metadata (source resource, path, content type) and the content itself (contentBase64 for raw data, contentPlaintext for extracted text).
  • Data Delivery: If opened with the #deliver-to-opener:$origin hash, the client will prompt the user for confirmation and then send the ClientFullEHR object back to the window that opened it using window.opener.postMessage(data, targetOrigin).

2. Local MCP Server via Stdio (src/cli.ts)

This mode is ideal for running the MCP server locally, often used with tools like Cursor or other command-line AI clients.

  • Two-Step Process:
    1. Fetch Data to Database: First, run the command-line interface with the --create-db and --db flags. This starts a temporary web server and uses the same SMART on FHIR web client logic described above to fetch data. Instead of sending the data via postMessage, it saves the ClientFullEHR data into a local SQLite database file.
      bash
      # Example: Fetch data and save to data/my_record.sqlite
      bun run src/cli.ts --create-db --db ./data/my_record.sqlite
      Follow the prompts (opening a link in your browser) to connect to your EHR.
    2. Run MCP Server: Once the database file is created, run the CLI again, pointing only to the database file. This loads the data into memory and starts the MCP server, listening for commands on standard input/output.
      bash
      # Example: Start the MCP server using the saved data
      bun run src/cli.ts --db ./data/my_record.sqlite
    • Configuration (config.*.json): This process relies on a configuration file (e.g., config.epicsandbox.json) which defines available EHR brands/endpoints in a brandFiles array. Each entry in this array specifies the brand's details, including:
      • url: Path/URL to the brand definition file (like static/brands/epic-sandbox.json).
      • tags: An array of strings (e.g., ["epic", "sandbox"]) used for categorization or filtering.
      • vendorConfig: Contains SMART on FHIR client details (clientId, scopes).
  • Client Configuration (e.g., Cursor): Configure your MCP client to execute this command. Crucially, use absolute paths for both src/cli.ts and the database file.
    json
    {
      "mcpServers": {
        "local-ehr": {
          "name": "Local EHR Search",
          "command": "bun", // Or the absolute path to bun
          "args": [
              "/home/user/projects/smart-mcp/src/cli.ts", // Absolute path to cli.ts
              "--db",
              "/home/user/projects/smart-mcp/data/my_record.sqlite" // Absolute path to DB file
            ]
        }
      }
    }

3. Full MCP Server via SSE (src/sse.ts / index.ts)

This mode runs a persistent server suitable for scenarios where multiple clients might connect over the network. It uses Server-Sent Events (SSE) for the MCP communication channel.

  • Authentication: Client authentication relies on OAuth 2.1, as specified by the Model Context Protocol. The server provides standard endpoints (/authorize, /token, /register, etc.).
  • Data Fetch: When a client initiates an OAuth connection, the server handles the SMART on FHIR flow itself, fetches the ClientFullEHR data during the authorization process, and keeps it in memory (or a persisted session) for the duration of the client's connection.
  • Status: While functional, the MCP specification for OAuth 2.1 client interaction is still evolving. Client support for this authentication method is extremely limited at present, making it difficult to test this mode with standard clients outside of specialized developer or debugging tools. This SSE mode should be considered experimental.

Instalação

TypingMind
Pré-requisitos:

Node.js 18+

{
  "mcpServers": {
    "jmandel-health-record-mcp": {
      "command": "",
      "args": []
    }
  }
}

Use o MCP de 结合 MCP 和 FHIR 的电子健康记录工具 com vários modelos de IA

O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho. Assim, após conectar 结合 MCP 和 FHIR 的电子健康记录工具, é possível usá-lo com diferentes modelos de IA no TypingMind, em vez de configurá-lo separadamente para cada modelo. É possível executar o MCP localmente no seu dispositivo ou se conectar à URL de um servidor MCP remoto.

Opção 1: use o conector local

Use esta opção quando o servidor MCP precisar acessar arquivos locais, aplicativos ou recursos privados no seu computador.

1

Abra as configurações de MCP

No TypingMind, acesse Configurações > Configurações avançadas > Model Context Protocol e selecione Configurar conector.

  1. Abra o TypingMind no navegador.
  2. Clique no ícone de Configurações.
  3. Acesse Configurações avançadas.
  4. Abra a seção Model Context Protocol.
  5. Clique em Configurar conector e selecione Este dispositivo.
Tela de configuração do conector MCP do TypingMind com a opção Este dispositivo selecionada
2

Execute o comando do conector

Selecione Este dispositivo, copie o comando do TypingMind e execute-o no Terminal. Mantenha o processo em execução enquanto usa o MCP.

  1. Copie o comando de configuração exibido pelo TypingMind.
  2. Abra o Terminal no macOS ou o Windows Terminal no Windows.
  3. Cole e execute o comando.
  4. Autorize a instalação do pacote se o Terminal pedir confirmação para continuar.
  5. Mantenha o processo em execução na janela do Terminal enquanto usa as ferramentas MCP.
3

Adicione 结合 MCP 和 FHIR 的电子健康记录工具 como servidor

Quando o status do conector for Pronto, clique em Editar servidores e cole a configuração do servidor MCP.

  1. Aguarde até que o status do conector mostre Pronto.
  2. Clique em Editar servidores.
  3. Cole a configuração do servidor MCP de 结合 MCP 和 FHIR 的电子健康记录工具.
  4. Salve a lista de servidores.
  5. Se quiser confirmar que o conector ainda está pronto para uso, atualize a página.
Configurações de MCP do TypingMind mostrando um servidor ativo e o botão Editar servidores
{
  "mcpServers": {
    "jmandel-health-record-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@jmandel/ehr-mcp"
      ]
    }
  }
}
4

Use a conexão com diferentes modelos

Salve a lista de servidores, abra Plugins, ative as ferramentas MCP de 结合 MCP 和 FHIR 的电子健康记录工具, selecione qualquer modelo de IA compatível no TypingMind e use as ferramentas no chat ou atribua-as a um agente de IA.

  1. Abra a página Plugins no TypingMind.
  2. Ative as ferramentas MCP de 结合 MCP 和 FHIR 的电子健康记录工具.
  3. Inicie um chat e escolha o modelo de IA que deseja usar.
  4. Use as ferramentas MCP no chat ou atribua-as a um agente de IA.
  5. Mude para outro modelo de IA sempre que necessário, sem reconectar o MCP.
Chat do TypingMind usando ferramentas MCP ativadas com um modelo de IA selecionado
Pode usar 结合 MCP 和 FHIR 的电子健康记录工具 para me ajudar nesta tarefa?
结合 MCP 和 FHIR 的电子健康记录工具
Claro. Já li.
Veja o que encontrei usando 结合 MCP 和 FHIR 的电子健康记录工具.

Opção 2: adicione a URL de um servidor MCP

Use esta opção quando 结合 MCP 和 FHIR 的电子健康记录工具 já estiver hospedado remotamente ou quando sua equipe quiser um conector compartilhado que vários usuários possam acessar.

1

Abra Conectores MCP

No TypingMind, vá até Plugins, abra Conectores MCP e selecione Adicionar URL.

  1. Abra o TypingMind no navegador.
  2. Acesse Plugins.
  3. Abra Conectores MCP.
  4. Clique em Adicionar URL.
Formulário do TypingMind para adicionar a URL de um servidor MCP personalizado
2

Cole a URL do servidor

Insira URL do seu servidor no campo URL do servidor. Adicione um nome para a conexão, uma descrição, um ícone, cabeçalhos HTTP personalizados ou configurações do cliente OAuth se o servidor exigir.

  1. Cole URL do seu servidor no campo URL do servidor.
  2. Digite um nome para a conexão de 结合 MCP 和 FHIR 的电子健康记录工具.
  3. Se quiser, adicione uma descrição e um ícone para facilitar a identificação.
  4. Adicione cabeçalhos HTTP personalizados ou dados do cliente OAuth se o servidor exigir autenticação.
3

Crie a conexão

Clique em Criar conexão, volte à lista de Plugins e confirme que a nova conexão MCP está ativa.

  1. Clique em Criar conexão.
  2. Volte à lista de conectores MCP.
  3. Confirme que a conexão de 结合 MCP 和 FHIR 的电子健康记录工具 aparece como ativa.
  4. Atualize a lista de plugins se a conexão não aparecer imediatamente.
4

Troque de modelo sem reconectar o MCP

Inicie um chat com seu modelo preferido, ative as ferramentas de 结合 MCP 和 FHIR 的电子健康记录工具 em Plugins e mude para outro modelo sempre que necessário. A conexão MCP continua disponível no espaço de trabalho do TypingMind.

  1. Inicie um novo chat no TypingMind.
  2. Selecione o modelo de IA que deseja usar.
  3. Ative as ferramentas de 结合 MCP 和 FHIR 的电子健康记录工具 em Plugins.
  4. Peça ao modelo para usar a ferramenta quando necessário.
  5. Mude para outro modelo de IA e reutilize a mesma conexão MCP.
Chat do TypingMind usando ferramentas MCP ativadas com um modelo de IA selecionado
Pode usar 结合 MCP 和 FHIR 的电子健康记录工具 para me ajudar nesta tarefa?
结合 MCP 和 FHIR 的电子健康记录工具
Claro. Já li.
Veja o que encontrei usando 结合 MCP 和 FHIR 的电子健康记录工具.

Perguntas frequentes

Para que serve o servidor MCP 结合 MCP 和 FHIR 的电子健康记录工具?

结合 MCP 和 FHIR 的电子健康记录工具 é um servidor MCP que permite que aplicativos de IA compatíveis se conectem a ferramentas externas e informações de contexto. No TypingMind, basta adicionar esse servidor MCP uma vez para disponibilizar suas ferramentas no seu espaço de trabalho com IA.

Posso usar o MCP 结合 MCP 和 FHIR 的电子健康记录工具 com vários modelos de IA no TypingMind?

Sim. O TypingMind conecta as ferramentas MCP no nível do espaço de trabalho, permitindo usar 结合 MCP 和 FHIR 的电子健康记录工具 com diferentes modelos de IA, como Claude, ChatGPT, Gemini ou outros modelos configurados no TypingMind, sem configurar o servidor MCP separadamente para cada modelo.

Por que usar o MCP 结合 MCP 和 FHIR 的电子健康记录工具 com o TypingMind?

O TypingMind é uma das melhores interfaces de chat com LLMs porque reúne vários modelos de IA, prompts, plugins, agentes de IA, chaves de API e ferramentas MCP em um só espaço de trabalho. Com 结合 MCP 和 FHIR 的电子健康记录工具 conectado, é possível usar suas ferramentas MCP nos seus modelos preferidos e manter seu fluxo de trabalho de chat organizado no TypingMind.

Como conecto o MCP 结合 MCP 和 FHIR 的电子健康记录工具 ao TypingMind?

É possível conectar 结合 MCP 和 FHIR 的电子健康记录工具 ao TypingMind com o conector MCP local ou adicionando a URL de um servidor MCP remoto. Use o conector local quando o servidor precisar acessar arquivos, apps ou recursos privados no seu dispositivo, e use uma URL de servidor quando o servidor MCP estiver hospedado remotamente.

Quais ferramentas o MCP 结合 MCP 和 FHIR 的电子健康记录工具 oferece no TypingMind?

结合 MCP 和 FHIR 的电子健康记录工具 disponibiliza recursos MCP que podem ser ativados na página Plugins do TypingMind e usados no chat ou atribuídos a agentes de IA.

Preciso compartilhar minhas chaves de API com o TypingMind para usar o MCP 结合 MCP 和 FHIR 的电子健康记录工具?

Não. O TypingMind prioriza o uso local e permite manter seus provedores de modelos, chaves de API, prompts e configuração MCP sob seu controle. Se 结合 MCP 和 FHIR 的电子健康记录工具 exigir autenticação, adicione os cabeçalhos, as configurações OAuth ou a configuração local exigidos por esse servidor MCP ao criar a conexão.

Servidores MCP relacionados

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇