Trying to implement environment variables for client_id
Project description
Strava Activity MCP Server
A small Model Context Protocol (MCP) server that exposes your Strava athlete data to language-model tooling.
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 Claude MCP integrations) 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
- STRAVA_REFRESH_TOKEN (or a short-lived access token obtained from the authorization flow)
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. - Open the authorization URL produced by the
strava://auth/urltool (see Tools below) in a browser to obtain an authorization code. - Exchange the code for tokens using
strava://auth/tokenor use the included helper to save refresh/access tokens to your environment.
For local testing you can also manually set the environment variables before running the server:
$env:STRAVA_CLIENT_ID = "<your client id>";
$env:STRAVA_CLIENT_SECRET = "<your client secret>";
$env:STRAVA_REFRESH_TOKEN = "<your refresh token>";
strava-activity-mcp-server
Note: Keep secrets out of version control. Use a .env file and a tool such as direnv or your system secrets manager for convenience.
Exposed Tools (what the server provides)
The MCP server exposes the following tools (tool IDs shown):
strava://auth/url— Build the Strava OAuth authorization URL. Input:client_id(int). Output: URL string to open in a browser.strava://auth/token— Exchange an authorization code for access + refresh tokens. Inputs:code(str),client_id(int),client_secret(str). Output: token dict (withaccess_token,refresh_token).strava://athlete/stats— Fetch recent athlete activities. Input:token(str). Output: JSON with activity list.
These tools map to the functions implemented in src/strava_activity_mcp_server/strava_activity_mcp_server.py and 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. Callstrava://auth/tokenwithcode,client_id, andclient_secretto receiveaccess_tokenandrefresh_token.
- 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.
Developer notes
- The package entry point calls
mcp.run()which runs the MCP server. If you want to change transport or logging settings, modifysrc/strava_activity_mcp_server/__init__.pyorstrava_activity_mcp_server.py. - The code uses the
requestslibrary for HTTP calls.
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):
{
"command": "uvx",
"args": [
"strava-activity-mcp-server"
]
}
To quickly test the server using the Model Context Protocol inspector tool, run:
npx @modelcontextprotocol/inspector uvx strava-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-mcp-server.
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.1.2.tar.gz.
File metadata
- Download URL: strava_activity_mcp_server-0.1.2.tar.gz
- Upload date:
- Size: 55.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96e1e525f5f42b6e715f4a720208a47cf899e08fe27117d7bbe5943da4f4ebd0
|
|
| MD5 |
4ace2da07cc600238298ccc4959ff30d
|
|
| BLAKE2b-256 |
9819d3cb84ad344a9f2956f01412ea3fce93c5e1cf14d69efbf2f820ffa8f630
|
File details
Details for the file strava_activity_mcp_server-0.1.2-py3-none-any.whl.
File metadata
- Download URL: strava_activity_mcp_server-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.4 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 |
b32a249cbb6112e8ff6e15fabcb7c3329cf21d4277721d26944d645b9db10fec
|
|
| MD5 |
f96023daf8b0f6b96ca60e6690e5db27
|
|
| BLAKE2b-256 |
951a990e7cbb6a17690f6856cb22a86b4d3171da358d2adda49c0b6a541e9622
|