Skip to content

Example health AI agent using TruthStack API — Python, Node.js, cURL, MCP config

Notifications You must be signed in to change notification settings

TruthStack1/truthstack-example-health-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

TruthStack Example Health Agent

A complete example showing how to build a health AI agent with real-time supplement-drug interaction checking using TruthStack.

This agent checks every supplement recommendation against TruthStack's database of 1,008+ interactions, 805 FAERS adverse event signals, and 25 drug profiles — before giving advice.

Why This Exists

Health AI agents should not recommend supplements without checking for interactions. A user on blood thinners asking about vitamin K, or someone on SSRIs asking about St. John's Wort — these are real safety risks.

TruthStack provides the safety infrastructure. This repo shows how to use it.

Three Integration Approaches

1. MCP Server (Claude Desktop / Any MCP Client)

# Already installed? Just configure Claude Desktop:
# ~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "truthstack": {
      "command": "node",
      "args": ["/path/to/truthstack-mcp/index.js"]
    }
  }
}

2. LangChain Agent (Python)

cd langchain-agent
pip install -r requirements.txt
export TRUTHSTACK_API_KEY="your-key"
export ANTHROPIC_API_KEY="your-key"
python agent.py

3. Direct REST API (Any Language)

# Check a supplement stack
curl -X POST https://api.truthstack.co/api/stack/check \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"compounds": ["magnesium", "vitamin D", "lisinopril"]}'

# Search for a compound
curl "https://api.truthstack.co/api/compounds/search?q=ashwagandha" \
  -H "x-api-key: YOUR_API_KEY"

Project Structure

truthstack-example-health-agent/
├── README.md
├── langchain-agent/
│   ├── agent.py              # Full LangChain agent with TruthStack
│   ├── truthstack_toolkit.py # LangChain toolkit (5 tools)
│   └── requirements.txt
├── direct-api/
│   ├── check_stack.py        # Simple REST API example
│   ├── check_stack.js        # Node.js version
│   └── check_stack.sh        # cURL example
└── mcp-config/
    └── claude_desktop_config.json  # Drop-in MCP config

Quick Start: Direct API

import requests

API_KEY = "your-truthstack-api-key"
BASE = "https://api.truthstack.co/api"
headers = {"x-api-key": API_KEY}

# Search for a compound
r = requests.get(f"{BASE}/compounds/search", params={"q": "magnesium"}, headers=headers)
print(r.json())

# Check a full stack
r = requests.post(f"{BASE}/stack/check",
    json={"compounds": ["magnesium", "vitamin D", "zinc", "lisinopril"]},
    headers=headers)

for interaction in r.json().get("data", []):
    if interaction["severity"] != "none":
        print(f"⚠️  {interaction['compound_a']}{interaction['compound_b']}: {interaction['severity']}")

What's In the Database

Data Count
Directed interactions 1,008+
FAERS adverse event signals 805
Research findings 235
Compounds 95
Compound aliases 584
Drug profiles 25

Every interaction includes:

  • Severity score (none, low, moderate, high, critical)
  • Evidence quality rating
  • Mechanism description
  • Source (FAERS, PubMed, ClinicalTrials.gov)

API Endpoints

Endpoint Method Description
/api/compounds/search?q= GET Fuzzy compound search
/api/compounds/:id GET Full compound profile
/api/compounds/:id/interactions GET Compound interactions
/api/stack/check POST Check entire stack
/api/drugs/:name GET Drug interaction profile
/api/stats GET Database statistics
/api/health GET API health check

Full docs: api.truthstack.co/docs

Get an API Key

Visit api.truthstack.co to get your free API key.

Links

License

MIT

About

Example health AI agent using TruthStack API — Python, Node.js, cURL, MCP config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published