A Python implementation of a Model Context Protocol (MCP) server for accessing Oura Ring health data with OAuth2 authentication.
- OAuth2 Authentication - Secure authentication with automatic token refresh
- 9 MCP Tools - Access sleep, readiness, activity, heart rate, workouts, and more
- Token Encryption - AES-256 encryption for OAuth tokens at rest
- Health Insights - Aggregated health trend analysis
- Pure Python - Built with FastMCP and Starlette
- Python 3.11 or higher
- Oura Ring with an active Oura account
- Oura API access (OAuth application)
# Clone or download this repository
cd oura-mcp-python
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install the package
pip install -e .cd oura-mcp-python
uv pip install -e .- Go to Oura OAuth Applications
- Log in with your Oura account
- Click "New Application"
- Fill in:
- Application Name:
Personal MCP Server - Redirect URI:
http://localhost:8000/oauth/callback - Scopes: Select all available scopes
- Application Name:
- Save and copy your Client ID and Client Secret
cp .env.example .env # copy the template
# then edit .env with your credentialsNote:
.envis gitignored;.env.exampleis the committed template.
# Run this in Python to generate TOKEN_ENCRYPTION_KEY
import secrets
print("TOKEN_ENCRYPTION_KEY:", secrets.token_hex(32))Edit your .env file:
# Oura OAuth Credentials
OURA_CLIENT_ID=your_client_id_here
OURA_CLIENT_SECRET=your_client_secret_here
OURA_REDIRECT_URI=http://localhost:8000/oauth/callback
# Token Encryption
TOKEN_ENCRYPTION_KEY=<generated_encryption_key>
# Server Configuration (optional; defaults shown)
HOST=0.0.0.0
PORT=8000# Using the installed command
oura-mcp
# Or directly with Python
python -m oura_mcp.server
# Or with uvicorn for development
uvicorn oura_mcp.server:create_app --factory --reload --port 8000- Open your browser to:
http://localhost:8000/oauth/authorize - Log in to your Oura account
- Approve the requested permissions
- You'll see a success message when connected
Check the health endpoint:
curl http://localhost:8000/healthExpected response:
{
"status": "healthy",
"oauth_connected": true,
"server": "Oura MCP Server (Python)",
"version": "1.0.0"
}Add this to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"oura": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:8000/mcp"],
"env": {
"API_KEY": "YOUR_AUTH_TOKEN_HERE"
}
}
}
}Alternative: Direct stdio connection (if running locally)
{
"mcpServers": {
"oura": {
"command": "python",
"args": ["-m", "oura_mcp.server"],
"cwd": "/path/to/oura-mcp-python",
"env": {
"OURA_CLIENT_ID": "your_client_id",
"OURA_CLIENT_SECRET": "your_client_secret",
"OURA_REDIRECT_URI": "http://localhost:8000/oauth/callback"
}
}
}
}Restart Claude Desktop after saving.
Get user's personal information and ring details.
Get sleep data for a date range.
Parameters:
start_date(required): YYYY-MM-DDend_date(optional): YYYY-MM-DDinclude_detailed(optional): Include detailed sleep period data
Get daily readiness scores.
Parameters:
start_date(required): YYYY-MM-DDend_date(optional): YYYY-MM-DD
Get activity data for a date range.
Parameters:
start_date(required): YYYY-MM-DDend_date(optional): YYYY-MM-DD
Get heart rate data in 5-minute intervals.
Parameters:
start_datetime(required): ISO 8601 format (e.g., 2024-01-01T00:00:00)end_datetime(optional): ISO 8601 format
Get workout sessions.
Parameters:
start_date(required): YYYY-MM-DDend_date(optional): YYYY-MM-DD
Get user-created tags and notes.
Parameters:
start_date(required): YYYY-MM-DDend_date(optional): YYYY-MM-DD
Get guided and unguided session data.
Parameters:
start_date(required): YYYY-MM-DDend_date(optional): YYYY-MM-DD
Get aggregated health insights based on recent data.
Parameters:
days(optional): Number of days to analyze (default: 7)
Check if the Oura account is connected and tokens are valid.
GET /health
GET /oauth/authorize - Start OAuth flow
GET /oauth/callback - OAuth callback (automatic)
GET /oauth/status - Get connection status
POST /oauth/disconnect - Disconnect and clear tokens
POST /mcp - MCP JSON-RPC endpoint (Streamable HTTP)
Run on your machine with the server accessible at localhost.
- Push to a Git repository
- Deploy to Railway, Render, or similar
- Update
OURA_REDIRECT_URIto your deployed URL - Update your Oura OAuth application's redirect URI
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install -e .
EXPOSE 8000
CMD ["oura-mcp"]docker build -t oura-mcp-python .
docker run -p 8000:8000 --env-file .env oura-mcp-python- Visit
/oauth/authorizeto connect your Oura account - Check that your OAuth credentials are correct in
.env
- Ensure
TOKEN_ENCRYPTION_KEYhasn't changed - Try disconnecting (
POST /oauth/disconnect) and reconnecting
- Ensure your
OURA_REDIRECT_URIexactly matches what's configured in your Oura OAuth application - Include the full path:
http://localhost:8000/oauth/callback
- Verify the server is running:
curl http://localhost:8000/health - Check Claude Desktop logs: Help → Open Logs Folder
- Ensure
mcp-remoteis available:npx -y mcp-remote --help
pip install -e ".[dev]"
pytestruff format .
ruff check --fix .MIT
- Based on the meimakes/oura-mcp-server TypeScript implementation
- Built with MCP Python SDK
- Uses the Oura API V2