---
title: "Connect AdvancedMD to Claude: Analyze Clinical Records & Lab Results"
slug: connect-advancedmd-to-claude-analyze-clinical-records-lab-results
date: 2026-11-25
author: Uday Gajavalli
categories: ["AI & Agents"]
excerpt: Learn how to connect AdvancedMD to Claude using a managed MCP server. Securely expose FHIR R4 APIs to AI agents for clinical workflows and data analysis.
tldr: "A technical guide to connecting AdvancedMD to Claude using a managed MCP server. Learn how to securely expose FHIR R4 APIs to AI agents for clinical workflows, patient history summaries, and bulk data exports without the maintenance overhead."
canonical: https://truto.one/blog/connect-advancedmd-to-claude-analyze-clinical-records-lab-results/
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://truto.one/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Connect AdvancedMD to Claude: Analyze Clinical Records & Lab Results


If your team needs to connect AdvancedMD to Claude to analyze clinical records, summarize patient history, or track lab results, you need a Model Context Protocol (MCP) server. This server acts as the translation layer between Claude's function calls and AdvancedMD's Fast Healthcare Interoperability Resources (FHIR) API. You can either build and maintain this infrastructure in-house, or use a managed integration platform like Truto to dynamically generate a secure, authenticated MCP server URL. If your team uses ChatGPT, check out our guide on [/connect-advancedmd-to-chatgpt-access-patient-history-care-plans/](https://truto.one/connect-advancedmd-to-chatgpt-access-patient-history-care-plans/) or explore our broader architectural overview on [/connect-advancedmd-to-ai-agents-automate-bulk-patient-data-workflows/](https://truto.one/connect-advancedmd-to-ai-agents-automate-bulk-patient-data-workflows/).

Giving a Large Language Model (LLM) read and write access to a sprawling Electronic Health Record (EHR) system like AdvancedMD is an engineering challenge. You have to handle strict OAuth token lifecycles, map massive FHIR R4 JSON schemas to MCP tool definitions, and deal with complex asynchronous data exports. Every time an endpoint shifts or a schema evolves, you have to update your server code, redeploy, and test the integration.

This guide breaks down exactly how to use Truto to generate a secure, managed MCP server for AdvancedMD, [connect it natively to Claude Desktop or Web](https://truto.one/how-to-connect-claude-to-saas-apis-via-mcp-zero-data-retention/), and execute complex clinical workflows using natural language.

> Want to give your AI agents secure, authenticated access to AdvancedMD and 100+ other SaaS APIs? Let's talk about managed [MCP architecture](https://truto.one/the-hands-on-guide-to-building-mcp-servers-for-ai-agents-2026/).
>
> [Talk to us](https://truto.one/book-a-demo/)

## The Engineering Reality of the AdvancedMD API

A custom MCP server is a self-hosted integration layer. While the open MCP standard provides a predictable way for models to discover tools, the reality of implementing it against specialized healthcare APIs is painful. AdvancedMD utilizes the FHIR R4 standard, which introduces highly specific architectural patterns that LLMs struggle with natively.

If you decide to build a [custom AdvancedMD MCP server](https://truto.one/the-hands-on-guide-to-building-mcp-servers-for-ai-agents-2026/), here are the specific integration challenges you will face:

**FHIR R4 Bundle Pagination and Payload Depth**
AdvancedMD's search endpoints (like `/v1/r4/<Organization ID>/Patient/_search`) do not return flat arrays of records. They return deeply nested FHIR `Bundle` resources. The actual patient or condition records are buried under `entry.*.resource`. An LLM without strict schema guidance will often hallucinate the JSON path or fail to parse the pagination `next` links correctly. Your MCP server must explicitly define JSON Schemas that teach the LLM exactly where the data lives in the response payload.

**Asynchronous Bulk Data Exports**
Not all endpoints in AdvancedMD behave like synchronous CRUD operations. Extracting a patient group's data requires triggering a Bulk FHIR connection. You must send a `GET` with a `Prefer: respond-async` header to `/v1/r4/Group/{groupId}/$export`. AdvancedMD answers with a `202 Accepted` and provides a `groupId` and `jobId`. Your system (and the LLM) must then poll a status endpoint until the job finishes, and finally download the results as application/fhir+ndjson (Newline Delimited JSON). An LLM cannot inherently manage this multi-step async polling loop unless you wrap it in explicitly defined tools.

**Context-Dependent Token Scoping**
AdvancedMD API behavior changes fundamentally based on the token context. A token issued for a patient can only read that specific patient's data. A token issued for a provider is scoped to the patient picked at sign-in. If you build your own MCP server, you must maintain strict session state and token injection logic to ensure the LLM does not cross patient data boundaries, which is a critical [HIPAA compliance risk](https://truto.one/how-to-build-hipaa-compliant-integrations-for-healthcare-saas/).

## Generating the AdvancedMD MCP Server

Instead of building an MCP server from scratch, you can use Truto to dynamically generate one. Truto introspects the AdvancedMD integration, maps the FHIR resources and documentation into MCP tools, and exposes them via a secure URL. 

You can generate this server in two ways.

### Method 1: Via the Truto UI

For administrators and operators, the simplest path is the Truto Dashboard:

1. Navigate to the **Integrated Accounts** page and select your connected AdvancedMD instance.
2. Click the **MCP Servers** tab.
3. Click **Create MCP Server**.
4. Select your desired configuration. (For example, check "Read Only" to ensure the LLM cannot modify clinical records, or restrict access using tool tags).
5. Click Save and copy the generated MCP server URL (e.g., `https://api.truto.one/mcp/a1b2c3d4e5f6...`).

### Method 2: Via the Truto API

For engineers embedding this functionality into an application, you can provision MCP servers programmatically. Make an authenticated `POST` request to the Truto API:

```bash
curl -X POST https://api.truto.one/integrated-account/{integrated_account_id}/mcp \
  -H "Authorization: Bearer YOUR_TRUTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "AdvancedMD Clinical Analyzer",
    "config": {
      "methods": ["read"],
      "tags": ["clinical", "patient"]
    }
  }'
```

The API provisions the server, validates that AdvancedMD tools are available, stores the cryptographic token, and returns the URL you will pass to Claude.

## Connecting the MCP Server to Claude

Once you have your Truto MCP URL, you need to register it with your AI client. You can do this visually in the UI for hosted models, or via configuration files for local desktop agents.

### Method A: Via the Claude or ChatGPT UI

If you are using Claude's web interface (or ChatGPT):

**For Claude Web:**
1. Go to **Settings** - **Integrations** - **Add MCP Server**.
2. Paste your Truto MCP URL.
3. Click **Add**. Claude will instantly connect and discover the available AdvancedMD tools.

**For ChatGPT:**
1. Go to **Settings** - **Apps** - **Advanced settings**.
2. Toggle **Developer mode** on.
3. Under **MCP servers / Custom connectors**, click add, provide a name (e.g., "AdvancedMD Data"), and paste the Truto MCP URL.

### Method B: Via Manual Config File (Claude Desktop)

If you are building custom agents or using Claude Desktop, you connect to the remote server using the Server-Sent Events (SSE) transport over npx.

Locate your Claude Desktop configuration file:
- Mac: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

Add the Truto MCP server URL using the standard `@modelcontextprotocol/server-sse` package:

```json
{
  "mcpServers": {
    "advancedmd": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "https://api.truto.one/mcp/a1b2c3d4e5f6..."
      ]
    }
  }
}
```

Restart Claude Desktop. The model will handshake with Truto, fetch the JSON Schemas, and the tools will appear in the interface.

## AdvancedMD Hero Tools for AI Agents

Truto automatically maps the AdvancedMD API into discrete, LLM-friendly tools. Here are the highest-leverage tools available for clinical analysis.

### Search Patient Records

**Tool name:** `list_all_advanced_md_patient_search_results`

This tool executes a POST request against the `/Patient/_search` endpoint using form body encoding. It is the entry point for almost all clinical workflows, allowing Claude to find a specific patient by ID, name, or birthdate in order to fetch their clinical context.

> "Search the AdvancedMD system for the patient record matching the ID 'pt-98765' and return their core demographic information."

### Retrieve Medical Conditions

**Tool name:** `list_all_advanced_md_condition_search_results`

Searches a set of `Condition` resources based on filter criteria. This is vital for summarizing a patient's active problem list. It parses the nested FHIR Bundle and extracts the relevant SNOMED or ICD-10 codes associated with the patient.

> "Fetch all active conditions for patient ID 'pt-98765' and summarize their chronic health issues."

### Analyze Diagnostic Reports

**Tool name:** `list_all_advanced_md_diagnostic_report_search_results`

Searches `DiagnosticReport` resources (like lab results, radiology reads, and pathology reports). Claude can use this tool to fetch recent labs and interpret the findings against reference ranges provided in the FHIR payload.

> "Find the most recent diagnostic reports for patient 'pt-98765' from the last 30 days and summarize any abnormal lab values."

### Review Medication Requests

**Tool name:** `list_all_advanced_md_medication_request_search_results`

Searches `MedicationRequest` resources to reconstruct a patient's active medication list. It filters by intent and patient ID, giving Claude the context needed to check for potential drug interactions when analyzing the patient's record.

> "List all active medication requests for patient 'pt-98765' and output them in a structured table."

### Initiate Bulk Data Export

**Tool name:** `create_a_advanced_md_bulk_export`

Starts a Bulk FHIR export of a patient Group's data. This tool triggers the async `$export` operation and returns a `groupId` and `jobId` that the LLM must use in subsequent polling steps. It is essential for population health analytics workflows.

> "Start a bulk export job for patient group 'grp-101' and tell me the job ID so we can track its status."

### Check Bulk Export Status

**Tool name:** `advanced_md_bulk_export_jobs_lookup`

Checks the status of a running bulk export. It returns a `202` while running, and eventually a `200` containing the manifest with URLs to the output files. Claude can be instructed to poll this tool until the manifest is ready.

> "Check the status of bulk export job 'job-456' for group 'grp-101'. If it is done, list the output file URLs."

To view the complete inventory of AdvancedMD tools, endpoints, and schemas, visit the [AdvancedMD integration page](https://truto.one/integrations/detail/advancedmd).

## Workflows in Action

Connecting an LLM to AdvancedMD transforms static clinical data into active intelligence. Here is how Claude executes real-world scenarios using MCP tool calling.

### Workflow 1: Pre-Consultation Clinical Summary

Physicians spend significant time reading through past charts before a visit. An AI agent can compile a concise summary of the patient's active state instantly.

> "Generate a pre-consultation summary for patient 'pt-554'. I need their active conditions, current medications, and the results of their last diagnostic report."

**Execution steps:**
1. Claude calls `list_all_advanced_md_patient_search_results` with `_id: pt-554` to verify the patient and grab basic demographics.
2. Claude calls `list_all_advanced_md_condition_search_results` filtering for active statuses to build the problem list.
3. Claude calls `list_all_advanced_md_medication_request_search_results` to fetch currently prescribed drugs.
4. Claude calls `list_all_advanced_md_diagnostic_report_search_results` to pull the latest lab work.

**Result:** The LLM returns a structured, easily readable clinical summary containing the patient's current health baseline, saving the provider 10 - 15 minutes of chart review.

### Workflow 2: Asynchronous Population Health Extraction

Pulling bulk data out of an EHR is notoriously difficult due to async polling requirements. Claude can orchestrate this entire state machine.

> "We need to extract the data for the diabetic patient cohort (Group ID 'grp-diab'). Start the bulk export, monitor it until complete, and then give me the file URLs for the output."

```mermaid
sequenceDiagram
  participant Claude as Claude
  participant MCP as Truto MCP Server
  participant API as AdvancedMD API
  Claude->>MCP: Call create_a_advanced_md_bulk_export
  MCP->>API: GET /v1/r4/Group/grp-diab/$export
  API-->>MCP: 202 Accepted {groupId, jobId}
  MCP-->>Claude: Return Job IDs
  Claude->>MCP: Call advanced_md_bulk_export_jobs_lookup
  MCP->>API: GET /v1/fhir-bulk/status
  API-->>MCP: 202 In Progress
  Claude->>MCP: Wait, then call lookup again
  MCP->>API: GET /v1/fhir-bulk/status
  API-->>MCP: 200 OK (Manifest URLs)
  MCP-->>Claude: Return File URLs
```

**Execution steps:**
1. Claude calls `create_a_advanced_md_bulk_export` to initiate the request. AdvancedMD returns the Job ID.
2. Claude pauses, then calls `advanced_md_bulk_export_jobs_lookup`.
3. Seeing a "202 In progress" status, Claude knows to wait and retry.
4. Claude calls `advanced_md_bulk_export_jobs_lookup` again, receives the `200 OK` manifest, and provides the NDJSON file URLs to the user.

**Result:** The user gets direct download links to the bulk FHIR data without writing a single line of polling or state management code.

## Security and Access Control

Giving AI agents access to [Protected Health Information (PHI)](https://truto.one/how-to-build-hipaa-compliant-integrations-for-healthcare-saas/) requires extreme precision. The Truto MCP architecture provides strict safeguards enforced at the server level, meaning the LLM physically cannot override them.

*   **Method Filtering (`config.methods`):** By setting the method filter to `["read"]` during server creation, Truto will only generate tools for `GET` and `LIST` endpoints. Write tools are entirely excluded from the schema.
*   **Tag Filtering (`config.tags`):** You can restrict the MCP server to specific functional areas of AdvancedMD by defining tags (e.g., `["clinical"]`). If a tool is not tagged appropriately, it is not served.
*   **Secondary Authentication (`require_api_token_auth`):** If enabled, possessing the MCP URL is not enough. The client connecting to the server must also pass a valid Truto API token in the `Authorization` header, preventing unauthorized usage if the URL leaks.
*   **Automated Expiration (`expires_at`):** You can provision short-lived MCP servers by passing an ISO datetime. Once the expiration hits, the server is aggressively purged from both the database and edge KV storage.

## Handling Rate Limits in Production

When connecting highly autonomous agents to AdvancedMD, you will eventually encounter API rate limits. 

**Factual note on rate limits:** Truto does not retry, throttle, or apply backoff on rate limit errors. When the upstream AdvancedMD API returns an HTTP 429 (Too Many Requests), Truto passes that error directly to the caller (Claude). However, Truto does normalize upstream rate limit information into standardized headers per the IETF specification (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`). 

Because Truto does not absorb rate limit errors, your client architecture or the AI agent loop itself is strictly responsible for inspecting these headers and implementing its own retry and backoff logic.

## Strategic Wrap-up

Connecting Claude to AdvancedMD transforms an LLM from a static text generator into an active clinical assistant. However, wrestling with FHIR R4 Bundles, asynchronous bulk polling, and context-sensitive authentication scopes is a massive drain on engineering resources.

By leveraging Truto to generate a managed MCP server, you eliminate the integration boilerplate. You define the access constraints, generate the URL, and instantly give your AI agents secure, schema-aware access to AdvancedMD's clinical data.
