Skip to main content

What are Tools?

Tools are Python functions that enable AI agents to interact with health data, perform actions, and access external services. Mirobody Health’s tool system makes it incredibly easy to add custom functionality without complex configuration.
Tools are automatically discovered from the tools/ directory in your project root and exposed via the MCP protocol.

Tool Architecture

Simple to Add

Write Python functions - no JSON schemas required

Auto-Discovery

Tools are automatically detected and registered

MCP Native

Instantly available via Model Context Protocol

Built-in Tools

Mirobody Health includes two essential health tools out of the box:

1. get_user_health_profile

Retrieves comprehensive user health profile information.
async def get_user_health_profile(user_info: UserInfo) -> Dict:
    """
    Get user health profile including connected devices and summary data
    
    Args:
        user_info: User authentication information (automatically provided)
        
    Returns:
        Dict containing user profile, connected providers, and health summary
    """
    pass
Returns:
  • User profile information
  • Connected health devices/providers
  • Health data summary and statistics

2. get_health_indicator

Retrieves specific health indicators for analysis.
async def get_health_indicator(
    user_info: UserInfo,
    indicator: str,
    start_time: Optional[str] = None,
    end_time: Optional[str] = None
) -> List[Dict]:
    """
    Get health indicator data for a specific metric
    
    Args:
        user_info: User authentication information (automatically provided)
        indicator: Health indicator name (e.g., "HEART_RATE", "STEPS")
        start_time: Optional start time filter (ISO format)
        end_time: Optional end time filter (ISO format)
        
    Returns:
        List of health indicator records
    """
    pass
Use Cases:
  • Query heart rate data over time
  • Retrieve sleep patterns
  • Analyze activity trends
  • Compare biomarkers
These built-in tools query the theta_ai.th_series_data table which contains all standardized health indicators.

Tool Categories

Private data tools that require authentication:
  • Access user’s health indicators
  • Query personal profiles
  • Retrieve device data
  • Analyze personal trends
Requirements:
  • Must include user_info: UserInfo parameter
  • OAuth authentication enforced automatically
  • Data scoped to authenticated user only

How Tools Work

1

Tool Discovery

On startup, Mirobody Health scans the tools/ directory for Python files containing Service classes.
# tools/my_tool.py
class MyToolService:
    # All public methods become tools
    pass
2

Auto-Registration

Each public method in a Service class is automatically registered as a tool.
class WeatherService:
    async def get_weather(self, location: str) -> Dict:
        """Get weather for location"""
        # This becomes a tool automatically
        pass
3

MCP Exposure

Tools are exposed via the MCP protocol at http://localhost:18080/mcp for AI agents to discover and call.
4

Agent Invocation

AI agents (Claude, Cursor, ChatGPT) can discover and call your tools through the MCP interface.

Tool Configuration

Tools are configured in config.yaml:
config.yaml
# Tool Directories
MCP_TOOL_DIRS:
  - mirobody/pub/tools    # Built-in tools
  - tools                 # Your custom tools

# Tool Access Control
ALLOWED_TOOLS_SYNERGY:
  - get_user_health_profile
  - get_health_indicator
  - your_custom_tool

DISALLOWED_TOOLS_SYNERGY:
  - dangerous_tool
Leave ALLOWED_TOOLS_SYNERGY empty to allow all tools by default. Use DISALLOWED_TOOLS_SYNERGY to block specific tools.

Database Schema for Health Data

Tools can query standardized health data from these tables:

theta_ai.th_series_data

Primary table for time-series health indicators:
ColumnTypeDescription
idintegerPrimary key
user_idvarcharUser identifier
indicatorvarcharIndicator code/name
valuetextOriginal indicator value
value_standardizedtextStandardized indicator value
start_timetimestampIndicator start time
end_timetimestampIndicator end time
sourcevarcharData source (system/device/manual)
source_tablevarcharOriginal source table
source_table_idvarcharSource record ID
indicator_idtextUnique indicator identifier
deletedintegerDeletion flag (0: active, 1: deleted)
create_timetimestamptzCreation timestamp
update_timetimestamptzLast update timestamp
task_idvarcharTask ID
full_dim_idbigintFull dimension ID
fhir_idbigintFHIR resource ID
fhir_mapping_infojsonbFHIR mapping information
is_standardizedbooleanStandardization flag
commenttextAdditional notes

theta_ai.health_user_profile_by_system

User profile storage:
ColumnTypeDescription
idintegerPrimary key
user_idvarcharUser identifier
versionintegerVersion number
namevarcharProfile name
last_execute_doc_idintegerLast executed document ID
common_partvarcharProfile content (JSON)
create_timetimestampCreation timestamp
last_update_timetimestampLast update timestamp
is_deletedbooleanDeletion flag

Next Steps