oura-mcp-server
CLAUDE.md1 starsChanged 3 months agoApache-2.0View on GitHub
FastMCP server exposing one Oura Ring account's v2 API data as read-only MCP tools. Python >= 3.10, httpx, uv; runs locally over stdio or hosted on Railway over Streamable HTTP. CI runs lint, uv lock --check, and tests on Python 3.10 through 3.14, installing with uv sync --locked. Dev dependencies are a PEP 735 [dependency-groups] group, not an extra. </important> - Tools live on the single module-level FastMCP instance in server.py and get the Oura client through _get_client(), a lazy…
- Reads credentials
In this repositoryOne other file it gives its agents.
- ouraSkill
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
Update the allowed-tools list in skills/oura/SKILL.md when adding or renaming a tool.
- Very specific: line 74
Every Oura call is mocked with respx.
- Very specific: line 86
If the volume is ever lost, run login locally and re-seed OURA_REFRESH_TOKEN.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
FastMCP server exposing one Oura Ring account's v2 API data as read-only MCP tools. Python >= 3.10, httpx, uv; runs locally over stdio or hosted on Railway over Streamable HTTP.
Project map
src/oura_mcp_server/server.py- every@mcp.tool/@mcp.prompt, the/webhookroute, andrun()src/oura_mcp_server/client.py-OuraClient: bearer injection, refresh-on-401,next_tokenpagination, error mappingsrc/oura_mcp_server/auth.py- Oura token sources and the env/file precedence resolversrc/oura_mcp_server/oauth.py-loginsubcommand: loopback OAuth flow, default scopessrc/oura_mcp_server/mcp_auth.py- GitHub OAuth proxy that gates MCP clients on the hosted serversrc/oura_mcp_server/analytics.py- per-day metric records, trends, Pearson correlationsrc/oura_mcp_server/webhook.py,webhook_receiver.py- Oura push subscriptions and the in-memory event buffertests/- pytest + respx, no live Oura callsskills/oura/SKILL.md,.claude-plugin/- the/ouraskill and Claude Code plugin packagingDockerfile,docker-entrypoint.sh,.railway/railway.ts- hosted deployment (Railway service settings as IaC)
<important if="you need to run commands to set up, test, lint, or run the server">uv sync # first-time setup; dev group installs by default
uv run pytest -q # full suite, no Oura token needed
uv run pytest tests/test_client.py -k pagination # single file / single test
uv run pytest --cov=oura_mcp_server --cov-report=term-missing # coverage (CI does not gate on it)
uv run ruff check . && uv run ruff format --check . # CI gates on both
uv run ruff format . # apply formatting
uv lock --check # CI fails if uv.lock drifts from pyproject
uvx pre-commit install # optional: ruff + uv-lock hooks on commit
uv run oura-mcp-server login --client-id <ID> --client-secret <SECRET> # one-time OAuth login, writes ~/.oura-mcp/tokens.json
uv run oura-mcp-server # stdio server (what Claude Desktop/Code launch)
uv run oura-mcp-server serve --transport http --port 8000 # hosted mode; refuses to start without GitHub OAuth envCI runs lint, uv lock --check, and tests on Python 3.10 through 3.14, installing with uv sync --locked. Dev dependencies are a PEP 735 [dependency-groups] group, not an extra.
</important>
<important if="you are adding or modifying MCP tools or prompts">- Tools live on the single module-level
FastMCPinstance inserver.pyand get the Oura client through_get_client(), a lazy process-wide singleton. - Date-range tools delegate to
_collection(), which fills a 7-day default window; follow that pattern rather than computing dates per tool. - Return
{"error": ...}dicts onOuraErrorinstead of raising, so the assistant sees the message. - Update the
allowed-toolslist inskills/oura/SKILL.mdwhen adding or renaming a tool. Each tool is listed twice:mcp__oura__*for a directly registered server andmcp__plugin_oura_oura__*for the plugin install. - Date and datetime inputs go through
_parse_date/_parse_datetime(trailingZaccepted) and bad input returns an error dict, never raises.</important>
<important if="you are touching authentication, tokens, OuraClient construction, or the login flow">Two unrelated auth systems exist. auth.py/oauth.py is how this server reaches the Oura API. mcp_auth.py is how MCP clients prove they may use the hosted server, via GitHub OAuth plus a login allowlist, and it is fail-closed for --transport http.
Oura-side precedence, implemented in auth.default_token_source():
OURA_REFRESH_TOKEN+OURA_CLIENT_ID+OURA_CLIENT_SECRETin env yields a refreshable source. An existing token file wins over the env seed.OURA_ACCESS_TOKENalone is static and never refreshes.- Otherwise the token file written by
login.
OuraClient() with no arguments must always delegate to that resolver. A shortcut that checked OURA_ACCESS_TOKEN first once left the hosted server unable to refresh for a month; tests/test_client.py guards against it, and tests/test_auth.py covers the precedence rules. Add a case there when changing resolution.
Refresh is serialized with an asyncio.Lock because the refresh token is single-use; two concurrent callers must produce one POST. Refresh attempts, successes, and failures are logged on the oura_mcp_server.auth logger. Logging is configured in __main__.py to stderr, level from OURA_MCP_LOG_LEVEL.
Oura refresh tokens are single-use and rotate on every refresh. Access tokens expire after 30 days. The rotated pair is written to OURA_TOKEN_FILE, default ~/.oura-mcp/tokens.json.
The Oura OAuth app is managed in Oura's new developer portal at developer.ouraring.com. The legacy portal's move re-issued client secrets.
</important>
<important if="you are working on webhooks or the /webhook route">- Subscription management authenticates with the OAuth application credentials as
x-client-id/x-client-secretheaders, not the user bearer token. - The
/webhookroute is mounted outside the MCP auth layer and gated byOURA_WEBHOOK_VERIFICATION_TOKEN. Events go into a 200-entry in-memory buffer that is lost on restart. - POSTs are checked against Oura's
x-oura-signatureHMAC (client secret over timestamp + JSON body) perOURA_WEBHOOK_SIGNATURE_MODE:log(default, warn and keep),enforce(401 and drop),off. The logic lives inwebhook_receiver.verify_signature.</important>
<important if="you are writing or modifying tests">- Every Oura call is mocked with
respx; nothing hits the network. - Tool tests set
OURA_ACCESS_TOKENand resetserver._client = Nonein a fixture so the singleton picks up the env, then await the tool functions directly. See theserverfixture intests/test_server_tools.py.</important>
<important if="you are deploying, changing Railway config, the Dockerfile, the entrypoint, or environment variables">- Pushes to
maindeploy automatically from the connected GitHub source. Merging a PR is the release. - Railway service settings live in
.railway/railway.ts(IaC partialoura-mcp-server; SDK pinned in.railway/package.json). Change them there and runrailway config planthenrailway config applyfrom the repo root; IaC is not applied on deploy. Keep the/datavolume declared and mounted (omitting it makes apply detach it) andvariables: { managed: false }so secrets never enter the file. Don't reintroducerailway.json/railway.toml(Config as Code stops being read on 2026-12-01). - The
DockerfileCMD owns startup. Never set a start command (in IaC or the dashboard): it runs without a shell, so$PORTwill not expand. - A volume is mounted at
/data.OURA_TOKEN_FILEmust point inside it, currently/data/oura/tokens.json, or a restart falls back to an already-consumed env refresh token.docker-entrypoint.shcreates and chowns that directory before dropping toappuser. - Required service variables: the three Oura refresh credentials,
OURA_TOKEN_FILE,FASTMCP_HOME=/data/fastmcp, theOURA_MCP_GITHUB_*OAuth app settings,OURA_MCP_ALLOWED_GITHUB_USERS, and a stableOURA_MCP_JWT_SIGNING_KEY. Optional:OURA_WEBHOOK_VERIFICATION_TOKEN,OURA_WEBHOOK_SIGNATURE_MODE,OURA_MCP_LOG_LEVEL. - The image installs from
uv.lockwithuv sync --locked --no-dev; a dependency change needs a relock before it ships. - If the volume is ever lost, run
loginlocally and re-seedOURA_REFRESH_TOKEN.</important>
<important if="you are editing the Claude Code plugin, skill, or session hook">.claude-plugin/plugin.jsonlaunches the server over stdio from${CLAUDE_PLUGIN_ROOT}withuv run, so any installer uses their own Oura account. The hosted HTTP form is documented in the README as an alternative..claude/hooks/session-start.shrunsuv sync --lockedand ruff only whenCLAUDE_CODE_REMOTE=true. It is a no-op locally.</important>
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

