# Release Notes - v1.1.2
**Release Date:** 2025-12-22
## 🚀 Features
### Automatic Token Refresh
The server now automatically refreshes expired access tokens when the Withings API returns a 401 error.
**How it works:**
1. API request receives 401 (invalid_token) error
2. Server automatically calls token refresh endpoint
3. Saves new tokens to `.env` file
4. Retries the original request with fresh token
5. User sees no interruption
**Benefits:**
- No more manual token generation
- Seamless user experience
- Tokens stay fresh automatically
## 🔧 Improvements
### Simplified Configuration
**Before (v1.1.1):**
```json
{
"mcpServers": {
"withings": {
"command": "/path/to/.venv/bin/python",
"args": ["-m", "withings_mcp_server"],
"env": {
"WITHINGS_CLIENT_ID": "...",
"WITHINGS_CLIENT_SECRET": "...",
"WITHINGS_ACCESS_TOKEN": "...",
"WITHINGS_REFRESH_TOKEN": "..."
}
}
}
}
```
**Now (v1.1.2):**
```json
{
"mcpServers": {
"withings": {
"command": "/path/to/withings-mcp-server/.venv/bin/python",
"args": ["-m", "withings_mcp_server"]
}
}
}
```
All credentials are loaded from `.env` file automatically!
### Enhanced Token Handling
- **Automatic .env loading** via `python-dotenv` at startup
- **Graceful handling** of tokens loaded without expiry time
- **Persistent token storage** in `.env` survives restarts
- **No more token duplication** between config and .env
## 📝 Changes
### Code Changes
- `server.py`: Added dotenv loading at module level
- `server.py`: Implemented 401 auto-retry with token refresh in `_make_request()`
- `auth.py`: Handle `token_expires_at=None` gracefully for env-loaded tokens
- `pyproject.toml`: Version bump `1.1.1` → `1.1.2`
### Documentation Updates
- Simplified Claude Desktop configuration example
- Added automatic token refresh documentation
- Updated troubleshooting guide for token errors
- Clarified `.env` vs config token management
## ⚠️ Breaking Changes
None. Existing configurations will continue to work, but using `.env` is now recommended.
## 🔧 Migration Guide
### Recommended Setup (Simplified Config)
1. **Ensure `.env` file has all credentials:**
```bash
cd /path/to/withings-mcp-server
cat .env
```
Should contain:
```
WITHINGS_CLIENT_ID=...
WITHINGS_CLIENT_SECRET=...
WITHINGS_REDIRECT_URI=http://localhost:8080/callback
WITHINGS_ACCESS_TOKEN=...
WITHINGS_REFRESH_TOKEN=...
```
2. **Update Claude Desktop config** (remove `env` section):
```json
{
"mcpServers": {
"withings": {
"command": "/path/to/withings-mcp-server/.venv/bin/python",
"args": ["-m", "withings_mcp_server"]
}
}
}
```
3. **Restart Claude Desktop**
The server will now:
- ✅ Load tokens from `.env` automatically
- ✅ Refresh tokens when they expire
- ✅ Save refreshed tokens back to `.env`
## 📦 Installation
```bash
# Clone the repository
git clone https://github.com/schimmmi/withings-mcp-server.git
cd withings-mcp-server
# Create virtual environment with Python 3.12 or lower
python3.12 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -e .
# Generate initial tokens
python generate_tokens.py
```
## 🐛 Fixes
- Fixed issue where expired tokens would cause persistent 401 errors
- Fixed token refresh not being triggered when `token_expires_at` is None
- Fixed tokens not persisting across server restarts when stored in config
## 🙏 Credits
Thanks for the bug report that led to this improvement!
---
**Full Changelog:** https://github.com/schimmmi/withings-mcp-server/compare/v1.1.1...v1.1.2