Integration Surfaces
How the same business logic is exposed to different consumers.
This document maps every integration surface to the underlying functions/ layer
and defines which surface serves which audience.
Updated: 2026-03-25 | PRD: PRD-20
Surface Architecture
Surface Comparison
| Surface | Audience | Auth | Transport | Location | Status |
|---|---|---|---|---|---|
| REST API — Extension | Chrome extension users | Clerk JWT | HTTPS JSON | api/routes/extension_api.py | Production |
| REST API — Diet | Web app + extension | Clerk JWT | HTTPS JSON | api/routes/diet.py | Production |
| REST API — Integration | Partner apps (Shopify) | Clerk JWT + scopes | HTTPS JSON | api/routes/integration.py | Production |
| REST API — Consumer Shopify | End users (order sync) | Clerk JWT | HTTPS JSON | api/routes/consumer_shopify.py | Production |
| REST API — Pairing | Device pairing | Pairing code | HTTPS JSON | api/routes/pairing.py | Production |
| REST API — Health | Monitoring | None | HTTPS JSON | api/routes/health.py | Production |
| REST API — Slack | Slack bot | Slack signing | HTTPS JSON | api/routes/slack.py | Beta |
| REST API — Stripe | Stripe webhooks | Stripe signature | HTTPS JSON | api/routes/stripe_webhook.py | Production |
| REST API — Tokens | Token management | Clerk JWT | HTTPS JSON | api/routes/tokens.py | Beta |
| MCP Server — Consumer | AI clients (Claude, ChatGPT, VS Code) | Clerk JWT (OAuth 2.1) | Streamable HTTP | api/mcp/server.py (NEW) | Planned (PRD-20) |
| Reflex States | Web app users | Clerk session | WebSocket | states/ | Production |
Consumer MCP vs REST API
The consumer MCP and REST API serve different interaction patterns:| Aspect | REST API | Consumer MCP |
|---|---|---|
| Consumer | Chrome extension, web app, scripts | AI assistants (Claude, ChatGPT, Copilot) |
| Interaction | Programmatic, structured requests | Natural language → tool selection by LLM |
| Auth | Authorization: Bearer <jwt> header | MCP OAuth 2.1 (same Clerk JWT underneath) |
| Discovery | OpenAPI spec (docs/api/openapi.json) | MCP tools/list + tool descriptions |
| Tool design | REST conventions (GET/POST/PUT/DELETE) | LLM-optimized descriptions, fewer but richer tools |
| Streaming | SSE for chat endpoints | SSE via MCP Streamable HTTP transport |
Overlap
Several operations are available on both surfaces. This is intentional — different clients need different access patterns:| Operation | REST Endpoint | MCP Tool | Same functions/ call |
|---|---|---|---|
| Get health profile | GET /api/ext/profile | get_health_profile | get_health_profile_sync() |
| Log food | POST /api/ext/food-log | log_food | create_food_log_sync() |
| Diet score | GET /api/diet/score | get_diet_score | compute_diet_fulfillment_score() |
| Diet gap | GET /api/diet/gap | get_diet_gap | compute_diet_gap() |
| Analyze food | POST /api/ext/diet/analyze | analyze_food | analyze_food_text() |
| Health snapshot | GET /api/diet/snapshot | get_health_snapshot | build_health_snapshot() |
MCP-Only Operations
These operations only make sense in the MCP context:| MCP Tool | Why MCP-only |
|---|---|
chat_with_shrine | Conversational AI — requires agent loop, not a single REST call |
get_my_checkins | Browsing context for ShrineAI — REST equivalent exists but MCP version is optimized for LLM consumption |
Partner MCP (Future, Separate)
Partner operations are scoped to a separate MCP server on the Shopify tech stack. This is not part of PRD-20.| Scope | Consumer MCP | Partner MCP |
|---|---|---|
| User | Individual longevitian | DTC brand / wellness partner |
| Auth | Clerk JWT (user role) | Clerk JWT (partner role) + Shopify OAuth |
| Tools | Health data, ShrineAI, diet | Protocol CRUD, adherence analytics, feedback |
| Data boundary | User’s own data only | Partner’s protocols + anonymized aggregate data |
| Deployment | Journals app (/mcp) | Shopify app (separate) |
Adding a New Surface
When exposing business logic to a new integration surface:- Ensure logic is in
functions/— not instates/orapi/routes/ - Add or extend a service in
api/services/that wraps the function calls - Create the surface adapter (route, MCP tool, Reflex state method)
- Auth: All surfaces must authenticate via Clerk JWT or equivalent
- Update this document with the new surface entry
- Update FUNCTION_TAXONOMY.md with any new MCP tool mappings
Agent Policy
Syntropy Health adopts an ultra-open stance toward external AI agents:- All user-facing business logic in
functions/is available to authenticated agents - We do not restrict based on which AI client is connecting
- Only internal UI state and partner operations are excluded from consumer MCP
- The value is in health data and ShrineAI intelligence, not interface control