# Terra AI

Our AI suite allows your AI agents to interface with Terra's health data directly. Your AI agents can do this through our MCP (Model Context Protocol) which gives your AI agent the necessary tools and data. \
\
Our MCP allows you to:

1. Request only specific, relevant data sets&#x20;
2. Access a user’s health memory&#x20;
3. Access aggregated stats, trends and baselines&#x20;
4. Access semantic meaning of health data &#x20;

### Why we built Terra AI&#x20;

We built Terra AI so that your AI agents can retrieve and reason over health data in the most token efficient way.&#x20;

This means that you don't have to make API calls, handle webhooks, trigger backfills, store or parse data. It ensures that your agent only retrieves meaningful, relevant data for reasoning, without having to overfetch or bloat their context limits.&#x20;

### Quick install

You need to add the MCP configuration to your client to get started. Below is the setup guide for some example AI IDEs to test the responses you would get for example prompts, but you can use Terra's AI suite with any system that supports an MCP.&#x20;

You will need to include your `dev-id` and `x-api-key` in the HTTP headers. You can find these on Terra's dashboard under **API keys.** The `user_id` is passed as part of the server URL.

{% tabs %}
{% tab title="Claude Code" %}
In your terminal, run the following command:

```
claude mcp add --transport http terra-mcp https://access.tryterra.co/api/v2/mcp/<user_id> \
  --header "dev-id: <YOUR_DEV_ID>" \
  --header "x-api-key: <YOUR_API_KEY>"
```

{% endtab %}

{% tab title="Claude desktop" %}

1. On Claude Dektop, navigate to **Settings > Developer**
2. Select **Edit Config** to open the configuration file
3. Copy paste the following code snippet to update the **claude\_desktop\_config.json**

```
{
  "mcpServers": {
    "terra": {
      "url": "https://access.tryterra.co/api/v2/mcp/<user_id>",
      "headers": {
        "dev-id": "YOUR_DEV_ID",
        "x-api-key": "YOUR_API_KEY"
      }
    }
  }
}
```

{% endtab %}

{% tab title="Cursor" %}

1. Open Cursor, then navigate to **Cursor Settings** > **Tools & Integrations**
2. Select **New MCP Server**
3. Copy paste the following code snippet to update the **mcp.json**

```
{
  "mcpServers": {
    "terra": {
      "url": "https://access.tryterra.co/api/v2/mcp/<user_id>",
      "headers": {
        "dev-id": "YOUR_DEV_ID",
        "x-api-key": "YOUR_API_KEY"
      }
    }
  }
}
```

{% endtab %}

{% tab title="VS code" %}

1. Open VS Code, then open the configuration file by running `MCP: Open User Configuration` in the command palette.&#x20;
2. Copy paste the following code snippet to update the **mcp.json**

```
{
  "mcpServers": {
    "terra": {
      "url": "https://access.tryterra.co/api/v2/mcp/<user_id>",
      "headers": {
        "dev-id": "YOUR_DEV_ID",
        "x-api-key": "YOUR_API_KEY"
      }
    }
  }
}
```

{% endtab %}

{% tab title="Windsurf" %}

1. Open Windsurf, then navigate to **Windsurf Settings** > **Cascade** > **MCP servers**
2. Select **Manage MCP Servers**
3. Select **View raw config**
4. Copy paste the following code snippet to update the **mcp\_config.json**

```
{
  "mcpServers": {
    "terra": {
      "url": "https://access.tryterra.co/api/v2/mcp/<user_id>",
      "headers": {
        "dev-id": "YOUR_DEV_ID",
        "x-api-key": "YOUR_API_KEY"
      }
    }
  }

```

{% endtab %}

{% tab title="Replit" %}

1. Open Replit, navigate to **Integrations page**, and scroll down to MCP Servers for **Replit Agent**
2. Select **Add MCP server**&#x20;
3. Enter the server URL `https://access.tryterra.co/api/v2/mcp/<user_id>` &#x20;
4. Add customer headers: `your dev-id` and your `x-api-key`&#x20;
5. Select **Test & Save**
   {% endtab %}
   {% endtabs %}

### Available tools

Tools are functions that your AI agent can call to get specific health data. They can be used to query specific data and perform aggregations.&#x20;

Once connected, you can use the below tools. Each tool uses parameters such as user\_id, list of data fields, and optional filter conditions. To see the full list of available data fields for each tool, visit our [data models](https://app.gitbook.com/s/eJJpVMsUARUJq9lYmL6t/health-and-fitness-api/data-models).&#x20;

<table><thead><tr><th valign="top">Tool</th><th valign="top">Purpose</th><th>Examples</th></tr></thead><tbody><tr><td valign="top">get_sleep_data</td><td valign="top">Gets sleep data including quality and quantity of sleep </td><td><ul><li>Sleep end time</li><li>Sleep start time</li><li>Total sleep</li><li>REM sleep</li><li>Deep sleep</li><li>Light sleep</li><li>Sleep latency</li><li>Average HR</li><li>Resting HR</li><li>Average HRV</li><li>Respiratory rate</li><li>Average SpO2</li><li>Sleep score</li></ul><p>full list <a href="https://docs.tryterra.co/reference/health-and-fitness-api/data-models#sleep">here</a></p></td></tr><tr><td valign="top">get_activity_data</td><td valign="top">Gets activity and workout session data </td><td><ul><li>Activity start time</li><li>Activity end time</li><li>Activity type (running, cycling)</li><li>Location</li><li>Active time</li><li>Inactive time</li><li>Rest time</li><li>Low intensity time</li><li>Moderate intensity time</li><li>Vigorous intensity time</li><li>Total distance</li><li>Step count</li><li>Floors climbed</li><li>Swimming laps </li></ul><p>full list <a href="https://docs.tryterra.co/reference/health-and-fitness-api/data-models#activity">here</a></p></td></tr><tr><td valign="top">get_daily_data </td><td valign="top">Gets health data summaries throughout a given day </td><td><ul><li>Average heart rate</li><li>Maximum heart rate</li><li>Minimum heart rate</li><li>Average HRV</li><li>Minimum HRV</li><li>Max heart rate</li><li>Resting heart rate</li><li>Average SpO2</li><li>Total calories burned</li><li>Net active calories</li><li>Activity time</li><li>Daily distance</li><li>Daily step count</li><li>Total stress duration</li><li>Activity stress duration</li><li>Strain level</li><li>Recovery score</li><li>Activity score</li></ul><p>full list <a href="https://docs.tryterra.co/reference/health-and-fitness-api/data-models#daily">here</a></p></td></tr><tr><td valign="top">get_body_data </td><td valign="top">Gets body measurements </td><td><ul><li>Water consumption</li><li>VO2 max estimate</li><li>Average SpO2</li><li>Blood pressure</li><li>Measurements</li><li>Temperature</li><li>Ketones</li><li>ECG data</li></ul><p>full list <a href="https://docs.tryterra.co/reference/health-and-fitness-api/data-models#body">here</a></p></td></tr><tr><td valign="top">get_nutrition_data </td><td valign="top">Gets nutrients and calorie consumption </td><td><ul><li>Total calories</li><li>Protein</li><li>CArbohydrates</li><li>Total fat</li><li>Trans fat</li><li>Saturated fat</li><li>Sugar</li><li>Cholesterol</li><li>Fiber</li><li>Vitamins</li><li>Micronutrients</li><li>Amino Acids</li></ul><p>full list <a href="https://docs.tryterra.co/reference/health-and-fitness-api/data-models#nutrition">here</a></p></td></tr><tr><td valign="top">get_menstruation_data</td><td valign="top">Gets menstrual cycle and fertility data </td><td><ul><li>Cycle start time</li><li>Cycle end time</li><li>Period start date</li><li>Current phase</li><li>Length of current phase</li><li>Days until next phase</li><li>Predicted cycle length</li><li>Actual cycle length</li><li>Fertility widnow start</li><li>Fertility window end </li><li>Predicted ovulation day</li></ul><p>full list <a href="https://docs.tryterra.co/reference/health-and-fitness-api/data-models#menstruation">here</a></p></td></tr></tbody></table>

### Example scenarios&#x20;

To help you understand how to use our MCP, here is a list of scenarios and prompts that your AI agent get respond to using Terra's MCP:

\
**Health insights and analysis**

* Give me a complete health snapshot: sleep, activity, stress, and recovery for this week
* Show me the relationship between my sleep quality and next-day performance
* What's my longest streak of days with at least 7 hours of sleep?

**Pattern recognition and correlations**

* Show me the correlation between my sleep latency and my stress level
* What's my average resting heart rate on days after poor sleep vs good sleep?

**Training and recovery optimization**

* What's my optimal recovery time between high-intensity workouts?
* Find all days where I had low recovery score but still did intense workouts

**Predictive and proactive insights**

* What's my predicted recovery time for tomorrow based on today's workout?
* Based on my HRV trends, should I train hard or take it easy today?

### What Terra's MCP includes&#x20;

Terra's MCP includes three primitives:

1. Tools: These are functions that your AI agent can call to get specific health data. They can be used to query specific data and perform aggregations. *Example: The sleep tool can be used to perform an analysis of a user's sleep architecture between the 12th November 2025 and 30th November 2025.*&#x20;
2. Resources: These provide context about the available data and how the data schema is structured.
3. Prompts: These are text based templates that help your AI agent understand how to use the tools and how to get data from our resources.
