Metadata-Version: 2.4
Name: strava-activity-mcp-server
Version: 0.2.2
Summary: STRAVA ACTIVITY MCP SERVER
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: build>=1.3.0
Requires-Dist: mcp[cli]>=1.16.0
Requires-Dist: twine>=6.2.0
Description-Content-Type: text/markdown

# Strava Activity MCP Server
![Python Package](https://github.com/tomekkorbak/strava-mcp-server/actions/workflows/python-package.yml/badge.svg)
[![License: GNU](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://opensource.org/licenses/gpl-3-0)
[![Python 3.13](https://img.shields.io/badge/python-3.13-blue?logo=python&logoColor=white)](https://www.python.org/downloads/release/python-3130/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/strava-activity-mcp-server)](https://pypistats.org/packages/strava-activity-mcp-server)

![image](https://github.com/user-attachments/assets/4bb214ca-1132-4e63-9390-d6eaddab50be)



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):

```powershell
pip install strava-activity-mcp-server
```

## Requirements

- Python >= 3.13 (see `pyproject.toml`)
- The package depends on `mcp[cli]` and `requests` (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`):

```cmd
strava-activity-mcp-server
```

Or, from Python:

```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:

1. Create a Strava API application at https://www.strava.com/settings/api and note your Client ID and Client Secret. Use `localhost` as the Authorization Callback Domain.
2. Open the authorization URL produced by the `strava://auth/url` tool (see IMAGE below) in a browser to obtain an authorization code.

   ![auth](https://github.com/user-attachments/assets/a348ccc7-a4be-49fb-8f79-b88f9d80cfc9)

3. Copy the code from the redirected URL (Image below) or use the included helper to save refresh/access tokens to your environment.

   ![code](https://github.com/user-attachments/assets/0bb54edb-c9f9-4416-8fb2-c7e0a38d11c9)


## 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://athlete/stats` — Fetch recent athlete activities. Input: `client_id` (int), `client_secret` (str), `access_token` (str) and obtained `code` from URL generated by `strava://auth/url`. 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

1) Get an authorization URL and retrieve tokens

- Call `strava://auth/url` with your `client_id` and open the returned URL in your browser.
- After authorizing, Strava will provide a `code`.

2) Fetch recent activities

- Use `strava://athlete/stats` with 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):

```json
{
  "command": "uvx",
  "args": [
    "strava-activity-mcp-server"
  ],
  "env": {
    "STRAVA_CLIENT_ID": "12345",
    "STRAVA_CLIENT_SECRET": "e1234a12d12345f12c1f12345a123bba1d12c1",
    "STRAVA_REFRESH_TOKEN": "1a123eda1cfd12345678987db2db1bda234c38"
  }
}
```

To quickly test the server using the Model Context Protocol inspector tool, run:

```powershell
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

![chat_1](https://github.com/user-attachments/assets/460cced5-15b3-41eb-9805-72966826ede8)
![chat_2](https://github.com/user-attachments/assets/9ded03f3-0f86-400e-8ebc-c414d0346257)
![chat_3](https://github.com/user-attachments/assets/d793c9a5-8fb2-430e-a0bf-679903cf3f97)
![chat_4](https://github.com/user-attachments/assets/4a459c31-3b42-4c32-8685-e6dd851dadca)


## 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.md` for an example MCP configuration





