MCP Setup Guide
Connect AI clients to Syntropy Health via the Model Context Protocol (MCP). Audience: End users (longevitians) and developers adding new tools.
Quick Start (Users)
1. Generate an API Token
- Open Settings in the Syntropy Health app
- Expand Admin Tokens
- Click Create New Token
- Name it (e.g., “Claude Desktop”) and set an expiration
- Copy the token immediately — it’s shown only once
2. Connect Your AI Client
For detailed connection config (Claude Desktop, VS Code, cURL examples), see the MCP Developer Guide.3. Test the Connection
Ask your AI client:“What’s my diet score this week?”If connected, ShrineAI will respond with your actual health data.
Available Tools
| Tool | Description | Type |
|---|---|---|
chat_with_shrine | Chat with ShrineAI health assistant | Write |
log_food | Log a food entry to your health journal | Write |
log_checkin | Record a daily health check-in | Write |
get_diet_score | Get diet fulfillment score (0-100) | Read |
get_diet_gap | Compare macro intake vs targets | Read |
get_health_snapshot | Aggregated health data (food, symptoms, meds) | Read |
get_health_profile | Dietary preferences, goals, conditions | Read |
get_my_protocols | Subscribed wellness protocols | Read |
analyze_food | Extract nutrition from food text | Read |
get_my_checkins | Recent check-in history | Read |
Rate Limits
| Operation | Limit |
|---|---|
| Read tools | 60 requests/minute |
| Write tools | 20 requests/minute |
Developer Guide: Adding New MCP Tools
Architecture
Step-by-Step
-
Ensure the function exists in
functions/Check FUNCTION_TAXONOMY.md for the scope classification. Only User-Application and User-Data functions should be exposed via MCP. -
Ensure a service method exists
If the function isn’t wrapped by a service in
api/services/, add a method. See INTEGRATION_SURFACES.md for the service layer pattern. -
Add the tool to
api/mcp/server.py -
Add a contract test
In
tests/unit/test_mcp_server_contracts.py, add the tool name to themust_toolsorshould_toolslist. - Update this document Add the tool to the Available Tools table above.
Tool Design Guidelines
- Descriptions are for LLMs, not humans. Be specific about what the tool returns.
- Use
ctx: Context = ...— never= None. FastMCP injects Context via type annotation. - Always call
_check_ratebefore any service call. - Always call
_log_callfor observability. - Return
_error()dicts on failure, not exceptions. MCP tools should not raise. - Use “read” rate limit for data retrieval, “write” for data mutation and LLM calls.
What NOT to Expose
- Internal UI state management (
states/) - Partner operations (
functions/partner/) - Admin config (
states/base.pyConfigurableState) - Shopify sync operations (
functions/consumer/shopify_*) - Infrastructure (embeddings, checkpointers, middleware)
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| ”Authentication required” | Missing or invalid token | Regenerate token in Settings |
| ”Rate limit exceeded” | Too many requests | Wait 60 seconds, reduce frequency |
| ”Service temporarily unavailable” | Backend service down | Check /api/health endpoint |
| Tools not showing | MCP server not mounted | Check logs for “MCP server mount failed” |
| Connection refused | Wrong URL | Verify URL ends with /mcp |
Environment Variables
| Variable | Required | Description |
|---|---|---|
CLERK_API_URL | For auth | Clerk JWKS endpoint URL (e.g., https://your-clerk.clerk.accounts.dev) |
MCP_RESOURCE_URL | Optional | OAuth resource server URL (default: https://api.syntropyhealth.com) |