strava-activity-mcp-server 0.1.0__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.4
2
+ Name: strava-activity-mcp-server
3
+ Version: 0.1.2
4
+ Summary: Trying to implement environment variables for client_id
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.13
7
+ Requires-Dist: build>=1.3.0
8
+ Requires-Dist: mcp[cli]>=1.16.0
9
+ Requires-Dist: twine>=6.2.0
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Strava Activity MCP Server
13
+ ![Image 1: Python Package](https://pypi-camo.freetls.fastly.net/0ecf904318113383d77ec39a9c48b8ba0d2baf38/68747470733a2f2f6769746875622e636f6d2f746f6d656b6b6f7262616b2f7374726176612d6d63702d7365727665722f776f726b666c6f77732f507974686f6e2532305061636b6167652f62616467652e737667)[![Image 2: License: GNU](https://pypi-camo.freetls.fastly.net/8de17537dd1659a5a076ce547de301e27c839e67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76332d626c75652e737667)](https://opensource.org/licenses/gpl-3-0)[![Image 3: Python 3.13](https://pypi-camo.freetls.fastly.net/e4930d5d2a7b16dfd9891ecb7396975ef462cff3/68747470733a2f2f696d672e736869656c64732e696f2f707970692f707976657273696f6e732f696e6a782e7376673f6c6f676f3d707974686f6e266c6f676f436f6c6f723d7768697465)](https://www.python.org/downloads/release/python-3130/)
14
+
15
+ A small Model Context Protocol (MCP) server that exposes your Strava athlete data to language-model tooling.
16
+
17
+ 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.
18
+
19
+ The project is intended to be used locally (for example with Claude MCP integrations) and is published on PyPI as `strava-activity-mcp-server`.
20
+
21
+ ## Installation
22
+
23
+ Install from PyPI with pip (recommended inside a virtual environment):
24
+
25
+ ```powershell
26
+ pip install strava-activity-mcp-server
27
+ ```
28
+
29
+ ## Requirements
30
+
31
+ - Python >= 3.13 (see `pyproject.toml`)
32
+ - The package depends on `mcp[cli]` and `requests` (installed from PyPI).
33
+
34
+ ## Quick start
35
+
36
+ After installing, you can run the MCP server using the provided console script or by importing and calling `main()`.
37
+
38
+ Run via the console script (entry point defined in `pyproject.toml`):
39
+
40
+ ```powershell
41
+ strava-activity-mcp-server
42
+ ```
43
+
44
+ Or, from Python:
45
+
46
+ ```python
47
+ from strava_activity_mcp_server import main
48
+ main()
49
+ ```
50
+
51
+ 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.
52
+
53
+ ## Authentication (Strava OAuth)
54
+
55
+ This server requires Strava OAuth credentials to access athlete data. You will need:
56
+
57
+ - STRAVA_CLIENT_ID
58
+ - STRAVA_CLIENT_SECRET
59
+ - STRAVA_REFRESH_TOKEN (or a short-lived access token obtained from the authorization flow)
60
+
61
+ Steps:
62
+
63
+ 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.
64
+ 2. Open the authorization URL produced by the `strava://auth/url` tool (see Tools below) in a browser to obtain an authorization code.
65
+ 3. Exchange the code for tokens using `strava://auth/token` or use the included helper to save refresh/access tokens to your environment.
66
+
67
+ For local testing you can also manually set the environment variables before running the server:
68
+
69
+ ```powershell
70
+ $env:STRAVA_CLIENT_ID = "<your client id>";
71
+ $env:STRAVA_CLIENT_SECRET = "<your client secret>";
72
+ $env:STRAVA_REFRESH_TOKEN = "<your refresh token>";
73
+ strava-activity-mcp-server
74
+ ```
75
+
76
+ Note: Keep secrets out of version control. Use a `.env` file and a tool such as `direnv` or your system secrets manager for convenience.
77
+
78
+ ## Exposed Tools (what the server provides)
79
+
80
+ The MCP server exposes the following tools (tool IDs shown):
81
+
82
+ - `strava://auth/url` — Build the Strava OAuth authorization URL. Input: `client_id` (int). Output: URL string to open in a browser.
83
+ - `strava://auth/token` — Exchange an authorization code for access + refresh tokens. Inputs: `code` (str), `client_id` (int), `client_secret` (str). Output: token dict (with `access_token`, `refresh_token`).
84
+ - `strava://athlete/stats` — Fetch recent athlete activities. Input: `token` (str). Output: JSON with activity list.
85
+
86
+ 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.
87
+
88
+ ## Example flows
89
+
90
+ 1) Get an authorization URL and retrieve tokens
91
+
92
+ - Call `strava://auth/url` with your `client_id` and open the returned URL in your browser.
93
+ - After authorizing, Strava will provide a `code`. Call `strava://auth/token` with `code`, `client_id`, and `client_secret` to receive `access_token` and `refresh_token`.
94
+
95
+ 2) Fetch recent activities
96
+
97
+ - 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.
98
+
99
+ ## Developer notes
100
+
101
+ - The package entry point calls `mcp.run()` which runs the MCP server. If you want to change transport or logging settings, modify `src/strava_activity_mcp_server/__init__.py` or `strava_activity_mcp_server.py`.
102
+ - The code uses the `requests` library for HTTP calls.
103
+
104
+
105
+ ### Client config example and quick inspector test
106
+
107
+ Any MCP-capable client can launch the server using a config similar to the following (example file often called `config.json`):
108
+
109
+ ```json
110
+ {
111
+ "command": "uvx",
112
+ "args": [
113
+ "strava-activity-mcp-server"
114
+ ]
115
+ }
116
+ ```
117
+
118
+ To quickly test the server using the Model Context Protocol inspector tool, run:
119
+
120
+ ```powershell
121
+ npx @modelcontextprotocol/inspector uvx strava-mcp-server
122
+ ```
123
+
124
+ 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`.
125
+
126
+
127
+ ## Contributing
128
+
129
+ Contributions are welcome. Please open issues or pull requests that include a clear description and tests where applicable.
130
+
131
+ ## License
132
+
133
+ This project is licensed under the GNU GENERAL PUBLIC LICENSE — see the `LICENSE` file for details.
134
+
135
+ ## Links
136
+
137
+ - Source: repository root
138
+ - Documentation note: see `README.md` for an example MCP configuration
139
+
140
+
@@ -0,0 +1,129 @@
1
+ # Strava Activity MCP Server
2
+ ![Image 1: Python Package](https://pypi-camo.freetls.fastly.net/0ecf904318113383d77ec39a9c48b8ba0d2baf38/68747470733a2f2f6769746875622e636f6d2f746f6d656b6b6f7262616b2f7374726176612d6d63702d7365727665722f776f726b666c6f77732f507974686f6e2532305061636b6167652f62616467652e737667)[![Image 2: License: GNU](https://pypi-camo.freetls.fastly.net/8de17537dd1659a5a076ce547de301e27c839e67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c76332d626c75652e737667)](https://opensource.org/licenses/gpl-3-0)[![Image 3: Python 3.13](https://pypi-camo.freetls.fastly.net/e4930d5d2a7b16dfd9891ecb7396975ef462cff3/68747470733a2f2f696d672e736869656c64732e696f2f707970692f707976657273696f6e732f696e6a782e7376673f6c6f676f3d707974686f6e266c6f676f436f6c6f723d7768697465)](https://www.python.org/downloads/release/python-3130/)
3
+
4
+ A small Model Context Protocol (MCP) server that exposes your Strava athlete data to language-model tooling.
5
+
6
+ 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.
7
+
8
+ The project is intended to be used locally (for example with Claude MCP integrations) and is published on PyPI as `strava-activity-mcp-server`.
9
+
10
+ ## Installation
11
+
12
+ Install from PyPI with pip (recommended inside a virtual environment):
13
+
14
+ ```powershell
15
+ pip install strava-activity-mcp-server
16
+ ```
17
+
18
+ ## Requirements
19
+
20
+ - Python >= 3.13 (see `pyproject.toml`)
21
+ - The package depends on `mcp[cli]` and `requests` (installed from PyPI).
22
+
23
+ ## Quick start
24
+
25
+ After installing, you can run the MCP server using the provided console script or by importing and calling `main()`.
26
+
27
+ Run via the console script (entry point defined in `pyproject.toml`):
28
+
29
+ ```powershell
30
+ strava-activity-mcp-server
31
+ ```
32
+
33
+ Or, from Python:
34
+
35
+ ```python
36
+ from strava_activity_mcp_server import main
37
+ main()
38
+ ```
39
+
40
+ 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.
41
+
42
+ ## Authentication (Strava OAuth)
43
+
44
+ This server requires Strava OAuth credentials to access athlete data. You will need:
45
+
46
+ - STRAVA_CLIENT_ID
47
+ - STRAVA_CLIENT_SECRET
48
+ - STRAVA_REFRESH_TOKEN (or a short-lived access token obtained from the authorization flow)
49
+
50
+ Steps:
51
+
52
+ 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.
53
+ 2. Open the authorization URL produced by the `strava://auth/url` tool (see Tools below) in a browser to obtain an authorization code.
54
+ 3. Exchange the code for tokens using `strava://auth/token` or use the included helper to save refresh/access tokens to your environment.
55
+
56
+ For local testing you can also manually set the environment variables before running the server:
57
+
58
+ ```powershell
59
+ $env:STRAVA_CLIENT_ID = "<your client id>";
60
+ $env:STRAVA_CLIENT_SECRET = "<your client secret>";
61
+ $env:STRAVA_REFRESH_TOKEN = "<your refresh token>";
62
+ strava-activity-mcp-server
63
+ ```
64
+
65
+ Note: Keep secrets out of version control. Use a `.env` file and a tool such as `direnv` or your system secrets manager for convenience.
66
+
67
+ ## Exposed Tools (what the server provides)
68
+
69
+ The MCP server exposes the following tools (tool IDs shown):
70
+
71
+ - `strava://auth/url` — Build the Strava OAuth authorization URL. Input: `client_id` (int). Output: URL string to open in a browser.
72
+ - `strava://auth/token` — Exchange an authorization code for access + refresh tokens. Inputs: `code` (str), `client_id` (int), `client_secret` (str). Output: token dict (with `access_token`, `refresh_token`).
73
+ - `strava://athlete/stats` — Fetch recent athlete activities. Input: `token` (str). Output: JSON with activity list.
74
+
75
+ 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.
76
+
77
+ ## Example flows
78
+
79
+ 1) Get an authorization URL and retrieve tokens
80
+
81
+ - Call `strava://auth/url` with your `client_id` and open the returned URL in your browser.
82
+ - After authorizing, Strava will provide a `code`. Call `strava://auth/token` with `code`, `client_id`, and `client_secret` to receive `access_token` and `refresh_token`.
83
+
84
+ 2) Fetch recent activities
85
+
86
+ - 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.
87
+
88
+ ## Developer notes
89
+
90
+ - The package entry point calls `mcp.run()` which runs the MCP server. If you want to change transport or logging settings, modify `src/strava_activity_mcp_server/__init__.py` or `strava_activity_mcp_server.py`.
91
+ - The code uses the `requests` library for HTTP calls.
92
+
93
+
94
+ ### Client config example and quick inspector test
95
+
96
+ Any MCP-capable client can launch the server using a config similar to the following (example file often called `config.json`):
97
+
98
+ ```json
99
+ {
100
+ "command": "uvx",
101
+ "args": [
102
+ "strava-activity-mcp-server"
103
+ ]
104
+ }
105
+ ```
106
+
107
+ To quickly test the server using the Model Context Protocol inspector tool, run:
108
+
109
+ ```powershell
110
+ npx @modelcontextprotocol/inspector uvx strava-mcp-server
111
+ ```
112
+
113
+ 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`.
114
+
115
+
116
+ ## Contributing
117
+
118
+ Contributions are welcome. Please open issues or pull requests that include a clear description and tests where applicable.
119
+
120
+ ## License
121
+
122
+ This project is licensed under the GNU GENERAL PUBLIC LICENSE — see the `LICENSE` file for details.
123
+
124
+ ## Links
125
+
126
+ - Source: repository root
127
+ - Documentation note: see `README.md` for an example MCP configuration
128
+
129
+
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "strava-activity-mcp-server"
3
- version = "0.1.0"
4
- description = "Add your description here"
3
+ version = "0.1.2"
4
+ description = "Trying to implement environment variables for client_id"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
7
7
  dependencies = [
@@ -0,0 +1,195 @@
1
+ Title: strava-mcp-server
2
+
3
+ URL Source: http://pypi.org/project/strava-mcp-server/
4
+
5
+ Markdown Content:
6
+ Project description
7
+ -------------------
8
+
9
+ ![Image 1: Python Package](https://pypi-camo.freetls.fastly.net/0ecf904318113383d77ec39a9c48b8ba0d2baf38/68747470733a2f2f6769746875622e636f6d2f746f6d656b6b6f7262616b2f7374726176612d6d63702d7365727665722f776f726b666c6f77732f507974686f6e2532305061636b6167652f62616467652e737667)[![Image 2: License: MIT](https://pypi-camo.freetls.fastly.net/8645b002dd7ec1b54275a80574942e7a318e03c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Image 3: Python 3.10](https://pypi-camo.freetls.fastly.net/ea10074cb289a2913e3e6b97173e8b2ce3051997/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31302d626c75652e737667)](https://www.python.org/downloads/release/python-3100/)
10
+
11
+ A [Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP) server that provides access to the Strava API. It allows language models to query athlete activities data from the Strava API.
12
+
13
+ Available Tools
14
+ ---------------
15
+
16
+ The server exposes the following tools:
17
+
18
+ ### Activities Queries
19
+
20
+ * `get_activities(limit: int = 10)`: Get the authenticated athlete's recent activities
21
+ * `get_activities_by_date_range(start_date: str, end_date: str, limit: int = 30)`: Get activities within a specific date range
22
+ * `get_activity_by_id(activity_id: int)`: Get detailed information about a specific activity
23
+ * `get_recent_activities(days: int = 7, limit: int = 10)`: Get activities from the past X days
24
+
25
+ Dates should be provided in ISO format (`YYYY-MM-DD`).
26
+
27
+ Activity Data Format
28
+ --------------------
29
+
30
+ The server returns activity data with consistent field names and units:
31
+
32
+ | Field | Description | Unit |
33
+ | --- | --- | --- |
34
+ | `name` | Activity name | - |
35
+ | `sport_type` | Type of sport | - |
36
+ | `start_date` | Start date and time | ISO 8601 |
37
+ | `distance_metres` | Distance | meters |
38
+ | `elapsed_time_seconds` | Total elapsed time | seconds |
39
+ | `moving_time_seconds` | Moving time | seconds |
40
+ | `average_speed_mps` | Average speed | meters per second |
41
+ | `max_speed_mps` | Maximum speed | meters per second |
42
+ | `total_elevation_gain_metres` | Total elevation gain | meters |
43
+ | `elev_high_metres` | Highest elevation | meters |
44
+ | `elev_low_metres` | Lowest elevation | meters |
45
+ | `calories` | Calories burned | kcal |
46
+ | `start_latlng` | Start coordinates | [lat, lng] |
47
+ | `end_latlng` | End coordinates | [lat, lng] |
48
+
49
+ Authentication
50
+ --------------
51
+
52
+ To use this server, you'll need to authenticate with the Strava API. Follow these steps:
53
+
54
+ 1. Create a Strava API application:
55
+
56
+ * Go to [Strava API Settings](https://www.strava.com/settings/api)
57
+ * Create an application to get your Client ID and Client Secret
58
+ * Set the Authorization Callback Domain to `localhost`
59
+
60
+ 2. Get your refresh token:
61
+
62
+ * Use the included `get_strava_token.py` script:
63
+
64
+ python get_strava_token.py
65
+
66
+ * Follow the prompts to authorize your application
67
+ * The script will save your tokens to a `.env` file
68
+
69
+ 3. Set environment variables: The server requires the following environment variables:
70
+
71
+ * `STRAVA_CLIENT_ID`: Your Strava API Client ID
72
+ * `STRAVA_CLIENT_SECRET`: Your Strava API Client Secret
73
+ * `STRAVA_REFRESH_TOKEN`: Your Strava API Refresh Token
74
+
75
+ Usage
76
+ -----
77
+
78
+ ### Claude for Desktop
79
+
80
+ Update your `claude_desktop_config.json` (located in `~/Library/Application\ Support/Claude/claude_desktop_config.json` on macOS and `%APPDATA%/Claude/claude_desktop_config.json` on Windows) to include the following:
81
+
82
+ {
83
+ "mcpServers": {
84
+ "strava": {
85
+ "command": "uvx",
86
+ "args": [
87
+ "strava-mcp-server"
88
+ ],
89
+ "env": {
90
+ "STRAVA_CLIENT_ID": "YOUR_CLIENT_ID",
91
+ "STRAVA_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
92
+ "STRAVA_REFRESH_TOKEN": "YOUR_REFRESH_TOKEN"
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ ### Claude Web
99
+
100
+ For Claude Web, you can run the server locally and connect it using the MCP extension.
101
+
102
+ Example Queries
103
+ ---------------
104
+
105
+ Once connected, you can ask Claude questions like:
106
+
107
+ * "What are my recent activities?"
108
+ * "Show me my activities from last week"
109
+ * "What was my longest run in the past month?"
110
+ * "Get details about my latest cycling activity"
111
+
112
+ Error Handling
113
+ --------------
114
+
115
+ The server provides human-readable error messages for common issues:
116
+
117
+ * Invalid date formats
118
+ * API authentication errors
119
+ * Network connectivity problems
120
+
121
+ License
122
+ -------
123
+
124
+ This project is licensed under the MIT License - see the LICENSE file for details.
125
+
126
+ Download files
127
+ --------------
128
+
129
+ Download the file for your platform. If you're not sure which to choose, learn more about [installing packages](https://packaging.python.org/tutorials/installing-packages/ "External link").
130
+
131
+ ### Source Distribution
132
+
133
+ ### Built Distribution
134
+
135
+ Filter files by name, interpreter, ABI, and platform.
136
+
137
+ If you're not sure about the file name format, learn more about [wheel file names](https://packaging.python.org/en/latest/specifications/binary-distribution-format/ "External link").
138
+
139
+ Copy a direct link to the current filters [](https://pypi.org/project/strava-mcp-server/#files)
140
+
141
+ File name
142
+
143
+ Interpreter
144
+
145
+ ABI
146
+
147
+ Platform
148
+
149
+ File details
150
+ ------------
151
+
152
+ Details for the file `strava_mcp_server-0.1.3.tar.gz`.
153
+
154
+ ### File metadata
155
+
156
+ * Download URL: [strava_mcp_server-0.1.3.tar.gz](https://files.pythonhosted.org/packages/c5/af/6d0b992c2d5a01b5494d6388e714072ccd47d84a1d0e4ffe9c4e077ad877/strava_mcp_server-0.1.3.tar.gz)
157
+ * Upload date: Feb 28, 2025
158
+ * Size: 6.1 kB
159
+ * Tags: Source
160
+ * Uploaded using Trusted Publishing? No
161
+ * Uploaded via: uv/0.6.0
162
+
163
+ ### File hashes
164
+
165
+ Hashes for strava_mcp_server-0.1.3.tar.gz| Algorithm | Hash digest | |
166
+ | --- | --- | --- |
167
+ | SHA256 | `8713d2e206dec10e65a67d22220677df221c02247ad4bcf0a7a4e0ae2a682202` | |
168
+ | MD5 | `95d9c00594437c032360dd2d3da1667f` | |
169
+ | BLAKE2b-256 | `c5af6d0b992c2d5a01b5494d6388e714072ccd47d84a1d0e4ffe9c4e077ad877` | |
170
+
171
+ [See more details on using hashes here.](https://pip.pypa.io/en/stable/topics/secure-installs/#hash-checking-mode "External link")
172
+
173
+ File details
174
+ ------------
175
+
176
+ Details for the file `strava_mcp_server-0.1.3-py3-none-any.whl`.
177
+
178
+ ### File metadata
179
+
180
+ * Download URL: [strava_mcp_server-0.1.3-py3-none-any.whl](https://files.pythonhosted.org/packages/ed/ae/72c2ea3d9a59a235f89ad0013741add100df968153e6c737b2d199b9a9ba/strava_mcp_server-0.1.3-py3-none-any.whl)
181
+ * Upload date: Feb 28, 2025
182
+ * Size: 7.5 kB
183
+ * Tags: Python 3
184
+ * Uploaded using Trusted Publishing? No
185
+ * Uploaded via: uv/0.6.0
186
+
187
+ ### File hashes
188
+
189
+ Hashes for strava_mcp_server-0.1.3-py3-none-any.whl| Algorithm | Hash digest | |
190
+ | --- | --- | --- |
191
+ | SHA256 | `b048109b3bae7601fcb65285405c38424996bccd59904ba443bb0a7150b00cc8` | |
192
+ | MD5 | `843e3701478e827fc36dfcf9c8e539aa` | |
193
+ | BLAKE2b-256 | `edae72c2ea3d9a59a235f89ad0013741add100df968153e6c737b2d199b9a9ba` | |
194
+
195
+ [See more details on using hashes here.](https://pip.pypa.io/en/stable/topics/secure-installs/#hash-checking-mode "External link")
@@ -8,9 +8,26 @@ import urllib.parse
8
8
 
9
9
  @mcp.tool("strava://auth/url")
10
10
 
11
- def get_auth_url(client_id):
12
- """Return the Strava OAuth authorization URL. Open this URL in a browser to get the code."""
13
- return str(f"https://www.strava.com/oauth/authorize?client_id={client_id}&response_type=code&redirect_uri=https://developers.strava.com/oauth2-redirect/&approval_prompt=force&scope=read,activity:read_all")
11
+ def get_auth_url(client_id: int | None = None):
12
+ """Return the Strava OAuth authorization URL. If client_id is not provided,
13
+ read it from the STRAVA_CLIENT_ID environment variable."""
14
+ if client_id is None:
15
+ client_id_env = os.getenv("STRAVA_CLIENT_ID")
16
+ if not client_id_env:
17
+ return {"error": "STRAVA_CLIENT_ID environment variable is not set"}
18
+ try:
19
+ client_id = int(client_id_env)
20
+ except ValueError:
21
+ return {"error": "STRAVA_CLIENT_ID must be an integer"}
22
+
23
+ params = {
24
+ "client_id": client_id,
25
+ "response_type": "code",
26
+ "redirect_uri": "https://developers.strava.com/oauth2-redirect/",
27
+ "approval_prompt": "force",
28
+ "scope": "read,activity:read_all",
29
+ }
30
+ return "https://www.strava.com/oauth/authorize?" + urllib.parse.urlencode(params)
14
31
 
15
32
 
16
33
 
@@ -80,17 +97,17 @@ def refresh_access_token(
80
97
 
81
98
 
82
99
  @mcp.tool("strava://athlete/stats")
83
- def get_athlete_stats(token: str) -> dict:
84
- """Retrieve athlete activities (last 30) using an access token."""
100
+ def get_athlete_stats(token: str) -> object:
101
+ """Retrieve athlete activities using an access token."""
85
102
  url = "https://www.strava.com/api/v3/athlete/activities?per_page=60"
86
103
  headers = {
87
104
  "accept": "application/json",
88
105
  "authorization": f"Bearer {token}"
89
106
  }
90
- import json
91
107
  response = requests.get(url, headers=headers)
92
108
  response.raise_for_status()
93
- return json.dumps(response.json(), indent=2)
109
+ # Return the parsed JSON (dict or list) instead of a JSON string so the return type matches.
110
+ return response.json()
94
111
 
95
112
  if __name__ == "__main__":
96
113
  mcp.run(transport="stdio") # Run the server, using standard input/output for communication
@@ -784,7 +784,7 @@ wheels = [
784
784
 
785
785
  [[package]]
786
786
  name = "strava-activity-mcp-server"
787
- version = "0.1.0"
787
+ version = "0.1.2"
788
788
  source = { editable = "." }
789
789
  dependencies = [
790
790
  { name = "build" },
@@ -1,21 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: strava-activity-mcp-server
3
- Version: 0.1.0
4
- Summary: Add your description here
5
- License-File: LICENSE
6
- Requires-Python: >=3.13
7
- Requires-Dist: build>=1.3.0
8
- Requires-Dist: mcp[cli]>=1.16.0
9
- Requires-Dist: twine>=6.2.0
10
- Description-Content-Type: text/markdown
11
-
12
- # strava-mcp-server
13
- MCP server that retrieves user activity data from Strava.
14
-
15
- .venv\Scripts\activate
16
-
17
- uv init --build-backend "hatchling"
18
-
19
- uv add mcp["cli"]
20
-
21
- uv run mcp dev scr/strava_mcp_server/strava_mcp_server.py
@@ -1,10 +0,0 @@
1
- # strava-mcp-server
2
- MCP server that retrieves user activity data from Strava.
3
-
4
- .venv\Scripts\activate
5
-
6
- uv init --build-backend "hatchling"
7
-
8
- uv add mcp["cli"]
9
-
10
- uv run mcp dev scr/strava_mcp_server/strava_mcp_server.py