@etweisberg/garmin-connect-mcp 0.1.17 → 0.1.19

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.
@@ -109,6 +109,12 @@ export class GarminClient {
109
109
  if (result.status === 204 || (result.status === 200 && !result.body)) {
110
110
  return { noData: true, status: result.status, path };
111
111
  }
112
+ if (result.status === 401) {
113
+ // Invalidate the singleton so the next call re-reads the session file
114
+ _sharedClient = null;
115
+ await this.close();
116
+ throw new Error(`Garmin API 401: ${path} — ${result.body}`);
117
+ }
112
118
  if (result.status !== 200) {
113
119
  throw new Error(`Garmin API ${result.status}: ${path} — ${result.body}`);
114
120
  }
@@ -200,6 +206,12 @@ export function getSharedClient() {
200
206
  }
201
207
  return _sharedClient;
202
208
  }
209
+ export async function resetSharedClient() {
210
+ if (_sharedClient) {
211
+ await _sharedClient.close();
212
+ _sharedClient = null;
213
+ }
214
+ }
203
215
  // Clean up on process exit
204
216
  process.on("exit", () => {
205
217
  _sharedClient?.close();
package/dist/tools.js CHANGED
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { writeFileSync, mkdirSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { inflateRawSync } from "node:zlib";
5
- import { getSharedClient, sessionExists, getSessionFile, } from "./garmin-client.js";
5
+ import { getSharedClient, resetSharedClient, sessionExists, getSessionFile, } from "./garmin-client.js";
6
6
  function jsonResult(data) {
7
7
  return {
8
8
  content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
@@ -89,6 +89,8 @@ To authenticate, you need the Playwright MCP server installed (\`@playwright/mcp
89
89
  }
90
90
  catch (e) {
91
91
  const msg = e instanceof Error ? e.message : String(e);
92
+ // Reset the singleton so the next attempt re-reads the session file
93
+ await resetSharedClient();
92
94
  return errorResult(`Session invalid or expired: ${msg}\nCall the garmin-login tool to re-authenticate.`);
93
95
  }
94
96
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etweisberg/garmin-connect-mcp",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "MCP server for Garmin Connect — access activities, metrics, and FIT files via Claude Code",
5
5
  "type": "module",
6
6
  "bin": {