Skip to Content
Luna AITools Reference

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:

ParamTypeRequiredDescription
productIdstringYesPeptide or supplement identifier
conditionsstring[]YesList 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:

  1. Resolves product synonyms via resolveSynonym('peptides', productId)
  2. Fetches contraindication data from getContraindicationsForPeptide()
  3. Matches user conditions against known contraindications
  4. 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:

ParamTypeRequiredDescription
biomarkerIdstringYesBiomarker identifier (e.g., testosterone-total)
agenumberNoPatient age for age-adjusted ranges
sex'M' | 'F' | 'male' | 'female'NoBiological 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:

ParamTypeRequiredDescription
protocolIdstringYesProtocol 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:

ParamTypeRequiredDescription
querystringYesSearch 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:

ParamTypeRequiredDescription
userIdstringYesClerk 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:

ParamTypeRequiredDescription
userIdstringYesClerk user ID
proposedMedicationstringYesMedication to check

What it does:

  1. Loads patient context to get current medications
  2. Checks against a built-in interaction database
  3. 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:

ParamTypeRequiredDescription
userIdstringYesClerk user ID
biomarkerCodestringNoFilter by specific biomarker
limitnumberNoNumber of results (default: 10)

What it does:

  1. Fetches lab results from the Patient Graph
  2. Optionally filters by biomarker code
  3. 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:

ParamTypeRequiredDescription
userIdstringYesClerk 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:

ParamTypeRequiredDescription
protocolNamestringYesName of the protocol
notesstringNoOptional notes about the check-in

What it does:

  1. Creates a note_added event in the Patient Graph
  2. Queries last 90 days of events to compute streak
  3. 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:

ParamTypeRequiredDescription
userIdstringYesClerk user ID
protocolIdstringNoSpecific protocol to analyze
weeksToAnalyzenumberNoAnalysis window (default: 12)

What it does:

  1. Gathers check-in data for the analysis period
  2. Collects biomarker trends during the protocol
  3. Sends data to GPT-4-turbo for clinical analysis
  4. 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:

ParamTypeRequiredDescription
fileUrlstringYesURL or data URL of the lab report PDF
userIdstringYesClerk user ID
patientSex'male' | 'female'NoBiological sex (default: 'male')

What it does:

  1. Downloads or decodes the lab report PDF
  2. Uses @loop/biomarker-parser with Anthropic to extract biomarkers
  3. Matches raw names to canonical codes
  4. Normalizes units to standard units
  5. Classifies values against sex-specific reference ranges
  6. Records a lab_parsed event in the Patient Graph
  7. 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:

ParamTypeRequiredDescription
metricTypestringNo'sleep', 'recovery', 'hrv', 'glucose', 'strain', or 'all'
fromDatestringNoISO date start (e.g., '2024-06-01')
toDatestringNoISO date end
includeProtocolCorrelationbooleanNoCorrelate with protocols (default: true)

What it does:

  1. Queries wearableData repository for the specified metrics and date range
  2. Computes summaries (averages, min, max) for each metric type
  3. Detects trends (improving, stable, declining)
  4. Generates metric-specific recommendations
  5. 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:

ParamTypeRequiredDescription
currentCheckInobjectYesCurrent week’s check-in data
previousCheckInobjectNoPrevious week’s data for comparison
protocolNamestringNoActive protocol name
weeknumberNoWeek number in protocol

Check-In Data Schema:

FieldTypeDescription
pain_levelnumber (0–10)Pain level
sleep_qualitynumber (0–10)Sleep quality
moodnumber (0–10)Overall mood
energynumber (0–10)Energy level
mobilitynumber (0–10)Physical mobility
side_effectsbooleanExperiencing side effects?
notesstringFree-text notes

What it does:

  1. Compares current metrics with previous check-in
  2. Identifies wins (improvements of 2+ points)
  3. Flags concerns (declines of 2+ points)
  4. Notes side effects if present
  5. Adds protocol-phase-specific suggestions
  6. 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…”