Luna AI Tools Reference
Luna has 13 specialized tools organized into 7 categories. Each tool is a function that Luna can call during a conversation to retrieve data, perform analysis, or record information.
Health Data Tools
checkContraindication
Check if a peptide or supplement is contraindicated for specific medical conditions.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
productId | string | Yes | Peptide or supplement identifier |
conditions | string[] | Yes | List of medical conditions to check |
Example interaction:
User: “Is BPC-157 safe for someone with type 2 diabetes?”
Luna calls:
checkContraindication({ productId: "bpc-157", conditions: ["type-2-diabetes"] })
What it does:
- Resolves product synonyms via
resolveSynonym('peptides', productId) - Fetches contraindication data from
getContraindicationsForPeptide() - Matches user conditions against known contraindications
- Returns allowed/blocked status with severity and reasoning
Returns:
{
"allowed": true,
"peptide": "bpc-157",
"matches": [],
"warnings": ["Monitor blood sugar levels closely"]
}getBiomarkerRange
Get normal and optimal reference ranges for a specific biomarker.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
biomarkerId | string | Yes | Biomarker identifier (e.g., testosterone-total) |
age | number | No | Patient age for age-adjusted ranges |
sex | 'M' | 'F' | 'male' | 'female' | No | Biological sex for sex-specific ranges |
Example interaction:
User: “What’s a normal testosterone level for a 35-year-old male?”
Luna calls:
getBiomarkerRange({ biomarkerId: "testosterone-total", age: 35, sex: "male" })
Returns:
{
"biomarker": "testosterone-total",
"name": "Total Testosterone",
"unit": "ng/dL",
"ranges": {
"low": 300,
"high": 1000,
"optimalLow": 500,
"optimalHigh": 900
},
"interpretation": "Optimal range for males aged 30-39: 500-900 ng/dL"
}getRequiredPanels
Get required lab panels for a specific protocol or peptide.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
protocolId | string | Yes | Protocol or peptide identifier |
Example interaction:
User: “What labs do I need before starting ipamorelin?”
Luna calls:
getRequiredPanels({ protocolId: "ipamorelin" })
Returns:
{
"protocolId": "ipamorelin",
"panels": [
{
"id": "gh-panel",
"name": "Growth Hormone Panel",
"biomarkers": [
{ "code": "igf-1", "name": "IGF-1", "required": true },
{ "code": "gh", "name": "Growth Hormone", "required": false }
]
},
{
"id": "comprehensive-metabolic",
"name": "Comprehensive Metabolic Panel",
"biomarkers": [...]
}
]
}searchBiomarkers
Search biomarkers by name, synonym, or description.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search query (name, alias, or description) |
Example interaction:
User: “What biomarker measures thyroid function?”
Luna calls:
searchBiomarkers({ query: "thyroid" })
Returns:
{
"results": [
{ "code": "tsh", "name": "TSH", "category": "thyroid" },
{ "code": "free-t3", "name": "Free T3", "category": "thyroid" },
{ "code": "free-t4", "name": "Free T4", "category": "thyroid" }
]
}Patient Graph Tools
getPatientContext
Fetch the complete patient context including profile, conditions, medications, labs, and protocols.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Clerk user ID |
What it returns:
- Patient profile (demographics, subscription tier)
- Active conditions
- Current medications
- Recent lab results
- Active protocols
- Emergency flags (if any)
- Consultation notes
Example interaction:
User: “Review my health profile and suggest improvements.”
Luna calls:
getPatientContext({ userId: "user_clerk_123" })
checkDrugInteractions
Check potential interactions between a proposed medication and the patient’s current medications.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Clerk user ID |
proposedMedication | string | Yes | Medication to check |
What it does:
- Loads patient context to get current medications
- Checks against a built-in interaction database
- Generates interaction warnings with severity levels
Returns:
{
"proposedMedication": "BPC-157",
"currentMedications": ["warfarin", "metformin"],
"interactions": [
{
"medication": "warfarin",
"severity": "moderate",
"description": "BPC-157 may affect platelet aggregation; use with caution alongside anticoagulants"
}
],
"safeToUse": true,
"warnings": ["Monitor INR levels more frequently"]
}getLabResults
Get recent lab results with optional biomarker filtering and trend analysis.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Clerk user ID |
biomarkerCode | string | No | Filter by specific biomarker |
limit | number | No | Number of results (default: 10) |
What it does:
- Fetches lab results from the Patient Graph
- Optionally filters by biomarker code
- Computes trends via
analyzeBiomarkerTrends()
Example interaction:
User: “How have my testosterone levels changed over time?”
Luna calls:
getLabResults({ userId: "user_clerk_123", biomarkerCode: "testosterone-total" })
getActiveProtocols
Get all active protocols for a patient with compound details.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Clerk user ID |
Returns:
{
"protocols": [
{
"id": "proto_abc",
"title": "BPC-157 Recovery Protocol",
"status": "active",
"startDate": "2024-06-01",
"items": [
{
"compound": "BPC-157",
"dosage": "250mcg",
"frequency": "2x daily",
"route": "subcutaneous"
}
]
}
]
}Protocol Tools
trackProtocol
Log a protocol adherence check-in and calculate the adherence streak.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
protocolName | string | Yes | Name of the protocol |
notes | string | No | Optional notes about the check-in |
What it does:
- Creates a
note_addedevent in the Patient Graph - Queries last 90 days of events to compute streak
- Returns current streak count and motivational feedback
Example interaction:
User: “Just took my BPC-157 this morning”
Luna calls:
trackProtocol({ protocolName: "BPC-157", notes: "Morning dose taken" })Luna responds: “Nice! That’s 14 days in a row. Keep it up!”
Protocol Analysis Tools
analyzeProtocol
Analyze protocol adherence trends and biomarker changes to suggest adjustments.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Clerk user ID |
protocolId | string | No | Specific protocol to analyze |
weeksToAnalyze | number | No | Analysis window (default: 12) |
What it does:
- Gathers check-in data for the analysis period
- Collects biomarker trends during the protocol
- Sends data to GPT-4-turbo for clinical analysis
- Returns adherence summary, biomarker changes, and AI-generated suggestions
Returns:
{
"adherence": {
"rate": 0.85,
"missedDays": 7,
"totalDays": 48,
"streak": 14
},
"biomarkerTrends": [
{
"code": "igf-1",
"startValue": 180,
"currentValue": 245,
"change": "+36%",
"trend": "improving"
}
],
"suggestions": [
"Consider maintaining current dosage — IGF-1 levels are responding well",
"Address the missed doses on weekends with reminders"
]
}Lab Analysis Tools
analyzeLabReport
Parse and interpret an uploaded lab report PDF.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
fileUrl | string | Yes | URL or data URL of the lab report PDF |
userId | string | Yes | Clerk user ID |
patientSex | 'male' | 'female' | No | Biological sex (default: 'male') |
What it does:
- Downloads or decodes the lab report PDF
- Uses
@loop/biomarker-parserwith Anthropic to extract biomarkers - Matches raw names to canonical codes
- Normalizes units to standard units
- Classifies values against sex-specific reference ranges
- Records a
lab_parsedevent in the Patient Graph - Returns interpreted results with reference ranges
Example interaction:
User: (uploads lab report PDF)
Luna calls:
analyzeLabReport({ fileUrl: "data:application/pdf;base64,...", userId: "user_123", patientSex: "male" })Luna responds: “I’ve analyzed your lab report. Here are the key findings: Your testosterone is at 650 ng/dL (optimal range), your TSH is slightly elevated at 4.2 mIU/L…”
Wearable Insights Tools
getWearableInsights
Get wearable data insights with trend analysis and optional protocol correlation.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
metricType | string | No | 'sleep', 'recovery', 'hrv', 'glucose', 'strain', or 'all' |
fromDate | string | No | ISO date start (e.g., '2024-06-01') |
toDate | string | No | ISO date end |
includeProtocolCorrelation | boolean | No | Correlate with protocols (default: true) |
What it does:
- Queries
wearableDatarepository for the specified metrics and date range - Computes summaries (averages, min, max) for each metric type
- Detects trends (improving, stable, declining)
- Generates metric-specific recommendations
- Optionally correlates with active protocols
Returns:
{
"metrics": {
"sleep": {
"average": 7.5,
"trend": "improving",
"dataPoints": 14,
"summary": "Sleep quality has improved 12% over the past 2 weeks",
"recommendations": ["Maintain current sleep schedule"]
},
"hrv": {
"average": 48,
"trend": "stable",
"dataPoints": 14,
"summary": "HRV is stable at 48ms",
"recommendations": ["Consider stress management techniques"]
}
},
"protocolCorrelation": {
"protocol": "BPC-157 Recovery",
"finding": "Recovery scores improved 15% since protocol start"
}
}Check-In Tools
analyzeCheckIn
Analyze weekly check-in data, celebrate progress, and troubleshoot issues.
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
currentCheckIn | object | Yes | Current week’s check-in data |
previousCheckIn | object | No | Previous week’s data for comparison |
protocolName | string | No | Active protocol name |
week | number | No | Week number in protocol |
Check-In Data Schema:
| Field | Type | Description |
|---|---|---|
pain_level | number (0–10) | Pain level |
sleep_quality | number (0–10) | Sleep quality |
mood | number (0–10) | Overall mood |
energy | number (0–10) | Energy level |
mobility | number (0–10) | Physical mobility |
side_effects | boolean | Experiencing side effects? |
notes | string | Free-text notes |
What it does:
- Compares current metrics with previous check-in
- Identifies wins (improvements of 2+ points)
- Flags concerns (declines of 2+ points)
- Notes side effects if present
- Adds protocol-phase-specific suggestions
- Builds a coaching-style response
Example interaction:
User: “Weekly check-in: pain 3, sleep 8, mood 7, energy 6”
Luna calls:
analyzeCheckIn({ currentCheckIn: { pain_level: 3, sleep_quality: 8, mood: 7, energy: 6 }, protocolName: "BPC-157", week: 4 })Luna responds: “Great progress this week! Your sleep quality improved from 6 to 8 — that’s a significant jump. Pain is down to 3 which is right on track for week 4 of BPC-157…”