Skip to main content

Function Taxonomy

Authoritative classification of every function in syntropy_journals/app/functions/ by scope. This taxonomy drives MCP tool selection, API surface design, and refactoring priorities. Updated: 2026-03-25 | PRD: PRD-20 (Consumer MCP)

Scope Definitions

ScopeCode LocationDescriptionMCP Exposure
Internalstates/ (vars, ui_handlers)UI state management, Reflex rendering, component logicNever
User-Datafunctions/db_utils/CRUD operations on user attributes, profile, settingsMCP Resources (read), MCP Tools (write)
User-Applicationfunctions/diet/, functions/llm/, functions/checkins/Business logic workflows — scoring, analysis, AI chatMCP Tools
Partnerfunctions/partner/, functions/db_utils/integration_analytics.pyPartner-scoped operations, adherence analyticsSeparate Partner MCP
Consumer-Integrationfunctions/consumer/Shopify order sync, protocol extraction for end usersInternal (triggered by webhooks)
Infrastructurefunctions/llm/middleware/, functions/llm/checkpoints/Agent middleware, checkpointers, embedding pipelinesNever (internal plumbing)

Function Catalog

User-Data (Profile, Settings, Auth)

These functions read/write user attributes. Candidates for MCP Resources (read) and Tools (write).
FunctionFileOperationMCP Candidate
get_user_profile_syncdb_utils/profile.pyRead user profileget_health_profile resource
get_health_profile_syncdb_utils/profile.pyRead health profileget_health_profile resource
update_user_profile_syncdb_utils/profile.pyWrite user profileFuture: update_profile tool
update_health_profile_syncdb_utils/profile.pyWrite health profileFuture: update_health_profile tool
get_user_profile_by_username_syncdb_utils/profile.pyLookup by usernameNo (internal lookup)
is_username_available_syncdb_utils/profile.pyCheck availabilityNo (UI only)
update_user_referral_source_syncdb_utils/auth.pyWrite referralNo (onboarding only)
get_user_protocols_syncdb_utils/protocols.pyRead subscribed protocolsget_my_protocols resource
adopt_protocol_syncdb_utils/protocols.pySubscribe to protocolFuture: subscribe_protocol tool
update_user_protocol_syncdb_utils/protocols.pyUpdate subscriptionNo (UI-driven)
get_chat_sessions_syncdb_utils/chat.pyRead chat sessionsget_my_chats resource
get_or_create_chat_session_syncdb_utils/chat.pyCreate chat sessionInternal (via chat tool)
delete_chat_session_syncdb_utils/chat.pyDelete chat sessionNo (destructive, UI only)

User-Application (Diet Intelligence)

Business logic workflows. Primary MCP tool candidates.
FunctionFileOperationMCP Tool
compute_diet_fulfillment_scorediet/scoring.pyOverall diet scoreget_diet_score
build_health_snapshotdiet/scoring.pyAggregated health dataget_health_snapshot
compute_ideal_diet_targetsdiet/ideal_diet.pyHeuristic macro targetsget_diet_targets
compute_diet_gapdiet/ideal_diet.pyActual vs target comparisonget_diet_gap
analyze_food_textdiet/agent.pyLLM food text extractionanalyze_food
score_dietdiet/agent.pyDiet score wrapperVia get_diet_score
get_diet_recommendationdiet/agent.pyLLM diet recommendationsrecommend_targets
analyze_diet_gapdiet/agent.pyGap analysis wrapperVia get_diet_gap
compute_dietary_sub_scorediet/alignment.pySub-score computationInternal (part of alignment)
compute_consistency_sub_scorediet/alignment.pySub-score computationInternal (part of alignment)
compute_checkin_sub_scorediet/alignment.pySub-score computationInternal (part of alignment)
compute_health_alignmentdiet/alignment.pyComposite alignment scoreget_health_alignment
generate_score_insightsdiet/insights.pyLLM score explanationsPart of get_health_snapshot
get_personalized_targetsdiet/profiler.pyLLM macro targetsrecommend_targets

User-Application (Health Entries & Check-ins)

Data entry operations. MCP write tools.
FunctionFileOperationMCP Tool
create_food_log_syncdb_utils/health_entries.pyLog food entrylog_food
get_food_logs_syncdb_utils/health_entries.pyRead food historyget_food_logs
get_symptom_entries_syncdb_utils/health_entries.pyRead symptomsPart of get_health_snapshot
get_medication_entries_syncdb_utils/health_entries.pyRead medicationsPart of get_health_snapshot
get_macro_summary_syncdb_utils/health_entries.pyMacro totalsInternal (used by scoring)
create_checkin_syncdb_utils/checkins.pyCreate check-in recordlog_checkin
get_checkins_for_user_syncdb_utils/checkins.pyRead check-in historyget_my_checkins
update_checkin_syncdb_utils/checkins.pyUpdate check-inNo (UI-driven edits)
delete_checkin_syncdb_utils/checkins.pyDelete check-inNo (destructive)
save_health_entries_syncdb_utils/checkins.pyBatch save entriesInternal (check-in processing)
intake_and_process_checkincheckins/intake.pyFull check-in pipelinelog_checkin (high-level)

User-Application (AI Chat)

ShrineAI conversational interface. Core MCP tool.
FunctionFileOperationMCP Tool
create_shrine_agentllm/agent.pyCreate agent instanceInternal (factory)
get_compiled_graphllm/agent.pyGet LangGraph agentInternal (factory)
get_chat_modelllm/client.pyGet LLM clientInternal (factory)
extract_food_entries_llmllm/extraction.pyLLM food extractionInternal (via analyze_food)
extract_notes_events_llmllm/extraction.pyLLM event extractionInternal (via check-in processing)
get_relevant_contextllm/retrieval/scored_retriever.pyRAG context retrievalInternal (agent middleware)
Note: The MCP chat_with_shrine tool invokes the full agent pipeline (agent.py + middleware + retrieval). Individual LLM functions are internal plumbing, not exposed directly.

User-Application (Marketplace & Catalog)

Protocol browsing and scoring.
FunctionFileOperationMCP Tool
get_catalog_protocols_syncdb_utils/catalog.pyBrowse protocol catalogbrowse_catalog resource
get_catalog_categories_syncdb_utils/catalog.pyList categoriesPart of browse_catalog
compute_confidence_tiermarketplace/confidence.pyProtocol confidence scorePart of catalog enrichment
check_safetymarketplace/safety.pySafety checkInternal (always runs)

Partner (Separate MCP)

Partner-scoped operations. NOT exposed in consumer MCP.
FunctionFileScope
get_partner_protocols_syncpartner/db_utils.pyPartner portal
get_adherence_data_syncpartner/db_utils.pyPartner analytics
get_partner_metrics_syncpartner/db_utils.pyPartner dashboard
calculate_pdcpartner/adherence.pyAdherence calculation
calculate_streakpartner/adherence.pyStreak calculation
generate_oauth_urlpartner/shopify_oauth.pyShopify OAuth
exchange_code_for_tokenpartner/shopify_oauth.pyShopify OAuth
fetch_shopify_productspartner/shopify_products.pyShopify sync
get_partner_summary_syncdb_utils/integration_analytics.pyPartner analytics
get_protocol_adherence_syncdb_utils/integration_analytics.pyPer-protocol stats
get_protocol_feedback_syncdb_utils/integration_analytics.pyUser feedback
get_protocol_retention_syncdb_utils/integration_analytics.pyRetention funnel
create_protocol_syncdb_utils/protocols.pyProtocol CRUD
update_protocol_syncdb_utils/protocols.pyProtocol CRUD

Consumer-Integration (Webhooks, Internal)

Triggered by external systems but not directly exposed via MCP.
FunctionFileScope
fetch_customer_ordersconsumer/shopify_orders.pyShopify data pull
extract_protocols_from_ordersconsumer/protocol_extractor.pyOrder → protocol extraction
extract_events_from_checkinconsumer/event_extractor.pyCheck-in → health events
get_user_integrations_syncconsumer/db_utils.pyIntegration status
save_user_integration_syncconsumer/db_utils.pyStore integration records

Infrastructure (Never Exposed)

FunctionFilePurpose
build_middleware_stackllm/agent.pyAgent middleware assembly
get_checkpointerllm/checkpoints/postgres_saver.pyLangGraph persistence
get_thread_idllm/checkpoints/thread_id.pyThread ID generation
create_summarization_middlewarellm/memory/summarization.pyMemory management
get_embedding_modelllm/retrieval/embedding.pyEmbedding pipeline
create_vectorstorellm/retrieval/vectorstore.pyVector DB setup

Refactoring Backlog

Processing logic that currently lives in states/ and should be extracted to functions/:
State FileIssueTarget LocationPriority
states/partner/adherence.py:136Inline rx.session() + adherence loopfunctions/partner/adherence.pyHigh (blocks partner MCP)
states/shared/clerk_auth.py:343Direct session query for profilefunctions/db_utils/auth.pyMedium
states/shared/mock_auth.py:101Direct session queryfunctions/db_utils/auth.pyLow (dev-only)
states/base.py:41ConfigurableState session queriesKeep (intentional — admin config)N/A

MCP Tool Summary (Consumer MCP v1)