{"slug": "using-a-local-iphone-mcp-server-to-plan-apple-watch-workouts-with-codex", "title": "Using a local iPhone MCP server to plan Apple Watch workouts with Codex", "summary": "A developer created Ask My Health, a local MCP server that lets AI agents like Codex read Apple Health data and schedule Apple Watch workouts via an iPhone bridge. The tool exposes HealthKit and WorkoutKit tools over the local network, requiring bearer token authentication and user approval for scheduling. It enables agents to query recent workouts, training load, and missing data without sending health information to the cloud.", "body_md": "I had a problem explaining Ask My Health in one sentence. \"An MCP server for HealthKit\" is true, but it only makes sense if you already care about MCP. The clearer version is this: it lets an agent use your iPhone as a local, permissioned bridge to Apple Health training data.\n\nThat matters because Apple Health already has the useful context: workouts, duration, distance, heart rate, power, cadence, HRV, VO2max and recovery signals. Normally, an agent cannot read that data. Ask My Health runs a local server on the iPhone and exposes a small set of tools to trusted clients on the same network.\n\n## The setup\n\nThe server is local network only. Codex connects to the iPhone endpoint over Streamable HTTP with bearer token authentication. Codex supports HTTP MCP servers and bearer tokens in its MCP configuration, so the app can be added without a cloud account or custom backend.\n\n```\n[mcp_servers.ask_my_health]\nurl = \"http://<iphone-local-ip>:8787/mcp\"\nbearer_token_env_var = \"ASK_MY_HEALTH_TOKEN\"\ndefault_tools_approval_mode = \"prompt\"\n```\n\nThe token comes from the iPhone app. I do not put it into screenshots, commits or blog posts. After a demo, I rotate it.\n\n## The prompt\n\nThe useful prompt is not \"make me fitter\". It should tell the agent what data to read, what to avoid guessing, and when to stop for approval.\n\n```\nUse my local Ask My Health MCP server.\n\nLook at my recent cycling workouts and training load.\nUse HealthKit as the source.\nSay which fields are missing instead of guessing.\n\nThen suggest one structured Apple Watch workout for tomorrow.\nValidate it with WorkoutKit.\nDo not schedule it until I approve it on the iPhone.\n```\n\nThat prompt gives Codex enough shape to use the tools in the right order. First authorization and read status. Then recent workouts. Then derived load metrics if the required inputs are available. Only after that should it produce a WorkoutKit plan.\n\n## What Codex can read\n\nFor a workout planning session, the agent usually starts with these tools:\n\n`healthkit_get_authorization_status`\n\nchecks whether HealthKit read access can be requested.`healthkit_request_read_authorization`\n\ntriggers the native iPhone permission sheet when needed.`healthkit_query_workouts`\n\nreads recent workouts, filtered by sport and date range.`training_compute_load_metrics`\n\ncomputes derived load values when the required HealthKit inputs exist.\n\nThe important part is what happens when data is missing. If there is no readable cycling power, the agent should not invent TSS. If there is no recent HRV, it should say so. Health data is useful, but it gets noisy fast when software starts filling gaps with confidence.\n\n## Creating the workout\n\nWriting is narrower than reading. The app does not write arbitrary HealthKit values. It can prepare and schedule WorkoutKit workouts, which means structured sessions for the Apple Watch Workout app.\n\nThe agent should validate the workout before scheduling it:\n\n```\nworkoutkit_get_capabilities\nworkoutkit_get_authorization_status\nworkoutkit_validate_workout_plan\nworkoutkit_schedule_workout\n```\n\nThe final scheduling call still requires iPhone approval. That is intentional. An agent may suggest the workout, but the phone remains the place where the user grants HealthKit and WorkoutKit permissions.\n\n## Why this is useful\n\nThe product is not another dashboard. It is a small local bridge. The app lets an agent answer questions that are hard to answer from a generic chat window:\n\n- What did my last three rides look like?\n- Did I increase volume too quickly?\n- What is a sensible next interval workout?\n- Which data is missing from HealthKit?\n- Can you prepare that workout for my Apple Watch?\n\nThis is where MCP makes sense to me. Not as a buzzword. As a narrow, local interface between an agent and data that should stay on the device unless the user explicitly opens it up.\n\n## The tradeoff\n\nThe local setup is slightly more work than a cloud login. You need the iPhone and the Mac on the same network. You need to copy a token. You need to approve HealthKit and WorkoutKit prompts on the phone.\n\nI think that is the right tradeoff for this category. Health data should not quietly become another remote account. The agent can help, but it should stay obvious when it reads private data and when it writes a workout.", "url": "https://wpnews.pro/news/using-a-local-iphone-mcp-server-to-plan-apple-watch-workouts-with-codex", "canonical_source": "https://bernhardhering.de/blog/ask-my-health-codex-workout-plan/", "published_at": "2026-07-01 09:46:07+00:00", "updated_at": "2026-07-01 10:20:53.399899+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Apple", "HealthKit", "WorkoutKit", "Codex", "Ask My Health", "MCP", "Apple Watch", "iPhone"], "alternates": {"html": "https://wpnews.pro/news/using-a-local-iphone-mcp-server-to-plan-apple-watch-workouts-with-codex", "markdown": "https://wpnews.pro/news/using-a-local-iphone-mcp-server-to-plan-apple-watch-workouts-with-codex.md", "text": "https://wpnews.pro/news/using-a-local-iphone-mcp-server-to-plan-apple-watch-workouts-with-codex.txt", "jsonld": "https://wpnews.pro/news/using-a-local-iphone-mcp-server-to-plan-apple-watch-workouts-with-codex.jsonld"}}