Connect Apple Health to opencode: Native MCP Setup
This walks through the exact config, the two values you type twice, and the tool-scoping glob that keeps 16 health tools out of your coding context until you actually ask for them. The config { "$schema" : "https://opencode.ai/config.json" , "mcp" : { "health-export" : { "type" : "local" , "command" : [ "npx" , "-y" , "health-export-mcp" ], "enabled" : true , "environment" : { "HEALTH_DATA_DIR" :…
This guide explains how to connect Apple Health to opencode using the MCP setup. The config file specifies that the health-export tool should be local and enabled, with a specific directory for storing health data. The command to run the health-export-mcp tool is npx -y health-export-mcp, and it must be provided as an array, not a shell string.
The HEALTH_DATA_DIR environment variable points to the folder containing the .health-cache.json file, which the server reads without making any network calls. The server names the opencode tools with a prefix, so health-export becomes health_export_get_trends, health_export_compare_periods, etc. If you use opencode for real code work, disable health tools globally and enable them for one agent.
To verify the setup, run opencode mcp list health-export local connected, which should output 16 tools. If the output says disconnected, it is likely that npx is missing from the PATH. Once the server is connected, you can ask specific questions, such as getting the trends on resting heart rate over 14 days, naming the server so the intent is clear.
The main difference between on-device and cloud architectures is where the computation occurs, not how the chart looks. In a cloud health AI, the answer is computed on the vendor's servers where the model lives, and an account is usually required. With a local MCP bridge, the answer is computed on your device, and the vendor's servers never hold the data, eliminating the need for an account.
The MCP setup is open-source and read-only, allowing the same data to be used with various tools like opencode, Claude, or Cursor. For a full setup guide, including pairing options and timeout details, visit https://www.healthexport.dev/blog/connect-apple-health-to-opencode-mcp.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.