Clinical MCP
Leyr Clinical MCP Server
Give your AI assistant the ability to execute live Leyr API calls - not just read docs, but actually book appointments, look up patients, write clinical notes, and more.
Requires a Leyr account and API credentials.
Prerequisites: Create a Leyr account
The Clinical MCP calls the live Leyr API on your behalf. You need a Leyr account and an application with API credentials before you can use it.
Create your account
Register at leyr.io/auth/register - free Sandbox access is available to anyone.
Create an application
In the Developer Portal, register an application. This gives you a Client ID and lets you generate a Client Secret.
Save your credentials
You will need:
LEYR_CLIENT_ID- the Client ID from your applicationLEYR_CLIENT_SECRET- the Client Secret generated for that application
Keep the secret private. Never commit it to source control.
Setup
Providing credentials
The Clinical MCP supports two ways to pass credentials to every tool call:
Option A - Environment variables (recommended)
Set these in your shell or IDE environment before starting the MCP client:
export LEYR_CLIENT_ID=your_client_id
export LEYR_CLIENT_SECRET=your_client_secret
When both env vars are set, you never have to include credentials in individual tool calls.
Option B - Inline per call
Pass client_id and client_secret directly as parameters on each tool call. Useful for quickly testing with different accounts or in environments where env vars are not available.
Add to your IDE
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"leyr-health": {
"url": "https://api.leyr.io/mcp",
"env": {
"LEYR_CLIENT_ID": "your_client_id",
"LEYR_CLIENT_SECRET": "your_client_secret"
}
}
}
}
Restart your IDE after saving the config.
Available tools
Care Units & Scheduling
| Tool | What it does |
|---|---|
leyr_get_care_units | List all care units (clinic locations) for an EHR |
leyr_get_healthcare_services | List healthcare services available at a care unit |
leyr_get_resources | List schedulable resources - doctors, nurses, rooms - at a care unit |
leyr_get_resource | Get details of a single resource by ID |
leyr_get_timeslots | Get available booking slots; filter by date range, service, or resource |
Appointments
| Tool | What it does |
|---|---|
leyr_get_appointments | List appointments; filter by patient, resource, service, or date range |
leyr_get_appointment | Get a single appointment by ID |
leyr_create_appointment | Book a new appointment for a patient |
leyr_patch_appointment | Reschedule, reassign, add a comment, or cancel an appointment |
leyr_bulk_patch_appointments | Update multiple appointments at once by ID list |
Patients
| Tool | What it does |
|---|---|
leyr_get_patients | Search patients by name, birth date, phone, or email |
leyr_get_patient | Fetch a single patient record by ID |
leyr_create_patient | Register a new patient (upserts if the patient already exists) |
Clinical Records
| Tool | What it does |
|---|---|
leyr_get_medical_notes | List medical notes for a patient (paginated) |
leyr_get_medical_note | Fetch a single note with full content |
leyr_create_medical_note | Create an unsigned clinical note (signed later by a clinician) |
leyr_get_documents | List documents attached to a patient (paginated) |
leyr_get_document | Fetch a single document with full content |
leyr_create_document | Attach a base64-encoded document (PDF, image, report) to a patient |
leyr_get_measurements | List clinical measurements for a patient (paginated) |
leyr_get_measurement | Fetch a single measurement by ID |
leyr_create_measurement | Record a new clinical measurement for a patient |
Tool parameters reference
Every tool accepts two optional credential parameters:
| Parameter | Description |
|---|---|
client_id | Your Leyr Client ID. Omit if LEYR_CLIENT_ID env var is set. |
client_secret | Your Leyr Client Secret. Omit if LEYR_CLIENT_SECRET env var is set. |
If neither the env var nor the inline parameter is provided, the tool call will fail with a clear error message.
Most tools also require emr (the EHR identifier, e.g. webdoc, epic) and care_unit_id (from leyr_get_care_units).
Example prompts
Once connected, try asking your AI:
"List all care units for Webdoc and show their IDs"
"Find a patient named Anna Svensson born 1985-03-12 in Webdoc"
"Show available timeslots for Dr. Eriksson next Monday and book the first one for patient 42"
"Cancel appointment abc123 in care unit xyz"
"Write a short unstructured clinical note for patient 99 - the patient reported mild headache, no fever"
"Attach the lab result PDF (base64 string) to patient 77's record"
Typical workflow
The tools follow a natural dependency chain:
leyr_get_care_units
└─ leyr_get_resources / leyr_get_healthcare_services
└─ leyr_get_timeslots
└─ leyr_create_appointment (needs patient_id)
↑
leyr_get_patients / leyr_create_patient
Your AI assistant will walk through this chain automatically when you describe what you want in plain language.
Docs MCP
Give your AI coding assistant full context about the Leyr API - docs, endpoint reference, and use-case guides via MCP.
Setup Guides for our EHRs
Here we have prepared setup guides for EHRs supported by Leyr. These guides will help you to configure EHRs for integrations and get required credentials.