Strava MCP server: one-time browser auth, then automatic refresh-token login
Project description
Strava Activity MCP Server
A small Model Context Protocol (MCP) server that exposes your Strava athlete data to language-model tooling.
After the first browser-based authorization, the server uses the saved refresh_token to automatically refresh your session; no further URL-redirected logins are required on subsequent runs.
This package provides a lightweight MCP server which communicates with the Strava API and exposes a few helper tools (authorization URL, token exchange/refresh, and fetching athlete activities) that language models or other local tools can call.
The project is intended to be used locally (for example with Claude MCP integrations) and is published on PyPI as strava-activity-mcp-server.
Installation
Install from PyPI with pip (recommended inside a virtual environment):
pip install strava-activity-mcp-server
Requirements
- Python >= 3.13 (see
pyproject.toml) - The package depends on
mcp[cli]andrequests(installed from PyPI).
Quick start
After installing, you can run the MCP server using the provided console script or by importing and calling main().
Run via the console script (entry point defined in pyproject.toml):
strava-activity-mcp-server
Or, from Python:
from strava_activity_mcp_server import main
main()
By default the server starts the MCP runtime; when used with an MCP-aware client (for example Msty MCP orsome other MCP integrations such Claude, LM Tool and etc.) the exposed tools become callable.
Authentication (Strava OAuth)
This server requires Strava OAuth credentials to access athlete data. You will need:
- STRAVA_CLIENT_ID
- STRAVA_CLIENT_SECRET
Steps:
-
Create a Strava API application at https://www.strava.com/settings/api and note your Client ID and Client Secret. Use
localhostas the Authorization Callback Domain. -
Initial authorization: call the
strava://auth/urltool to generate an authorization URL (see IMAGE below), open it in your browser, and grant access. This step is only needed the first time to obtain an authorization code. -
Copy the
codefrom the redirected URL (Image below). Use the provided tools to exchange it for access/refresh tokens. -
After the initial authorization, a token file named
strava_mcp_tokens.jsonis created and stored in your home directory (for example on Windows:C:\\Users\\<YourUserName>\\strava_mcp_tokens.json). This file contains yourrefresh_token, which will be used automatically for subsequent logins. After the first authorization you do not need to open the browser flow again; future runs refresh the access token from the locally storedrefresh_token.
Exposed Tools (what the server provides)
The MCP server exposes the following tools (tool IDs shown). These map to functions in src/strava_activity_mcp_server/strava_activity_mcp_server.py and cover both initial authorization and subsequent refresh flows:
strava://auth/url— Build the Strava OAuth authorization URL.- Inputs:
client_id(int, optional; readsSTRAVA_CLIENT_IDif omitted) - Output: Authorization URL string
- Inputs:
strava://auth/refresh— Refresh an access token using a refresh token.- Inputs:
refresh_token(str),client_id(int, optional),client_secret(str, optional) - Output:
{ access_token, refresh_token, expires_at, expires_in }
- Inputs:
strava://athlete/stats— Exchange an authorizationcodefor tokens and then fetch recent activities.- Inputs:
code(str),client_id(int, optional),client_secret(str, optional) - Output:
{ activities, tokens, save }
- Inputs:
strava://athlete/stats-with-token— Fetch recent activities using an existing access token.- Inputs:
access_token(str) - Output: Activity list (JSON)
- Inputs:
strava://auth/save— Save tokens to~\strava_mcp_tokens.json.- Inputs:
tokens(dict) - Output:
{ ok, path }or error
- Inputs:
strava://auth/load— Load tokens from~\strava_mcp_tokens.json.- Inputs: none
- Output:
{ ok, tokens, path }or error
strava://athlete/refresh-and-stats— Load saved refresh token, refresh access token, save it, and fetch activities.- Inputs:
client_id(int, optional),client_secret(str, optional) - Output:
{ activities, tokens }
- Inputs:
strava://session/start— Convenience entry: if tokens exist, refresh and fetch; otherwise return an auth URL to begin initial authorization.- Inputs:
client_id(int, optional),client_secret(str, optional) - Output: Either
{ activities, tokens }or{ auth_url, token_file_checked }
- Inputs:
These tools are intended to be called by MCP clients.
Example flows
- Get an authorization URL and retrieve tokens
- Call
strava://auth/urlwith yourclient_idand open the returned URL in your browser. - After authorizing, Strava will provide a
code.
- Fetch recent activities
- Use
strava://athlete/statswith a valid access token. If the access token is expired, use the refresh flow to get a new access token.
Client config example and quick inspector test
Any MCP-capable client can launch the server using a config similar to the following (example file often called config.json. Be sure to enter your values here):
{
"command": "uvx",
"args": [
"strava-activity-mcp-server"
],
"env": {
"STRAVA_CLIENT_ID": "12345",
"STRAVA_CLIENT_SECRET": "e1234a12d12345f12c1f12345a123bba1d12c1"
}
}
To quickly test the server using the Model Context Protocol inspector tool, run:
npx @modelcontextprotocol/inspector uvx strava-activity-mcp-server
This will attempt to start the server with the uvx transport and connect the inspector to the running MCP server instance named strava-activity-mcp-server.
Chat example using MCP in Msty Studio
Contributing
Contributions are welcome. Please open issues or pull requests that include a clear description and tests where applicable.
License
This project is licensed under the GNU GENERAL PUBLIC LICENSE — see the LICENSE file for details.
Links
- Source: repository root
- Documentation note: see
README.mdfor an example MCP configuration
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strava_activity_mcp_server-0.2.4.tar.gz.
File metadata
- Download URL: strava_activity_mcp_server-0.2.4.tar.gz
- Upload date:
- Size: 476.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed036555bdfd1e61864b2da049e2435eae3220c36681f49f6a5edaea613642a4
|
|
| MD5 |
1812f2a1cde58e36d56c175a7dee82de
|
|
| BLAKE2b-256 |
078c7731b9e45a958c96e184fd1c3089ccd86b3da3d18e8a37ca4af880373445
|
File details
Details for the file strava_activity_mcp_server-0.2.4-py3-none-any.whl.
File metadata
- Download URL: strava_activity_mcp_server-0.2.4-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39341d082aceb24713f34ec57dd1186657c21873169d7e8935c05eb220773a63
|
|
| MD5 |
fc023be77655a44d2ae16213b4ae310e
|
|
| BLAKE2b-256 |
339ef998a8f49aaac4e90e79929e604ed22919dbf5447a72164d8a80bbc50ba1
|