get-goals
Retrieve fitness goals from Garmin Connect. Filter by status (active, future, or past) to track progress.
Instructions
Get fitness goals
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get-goals"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | Goal status: active, future, or past | active |
Implementation Reference
- src/tools.ts:640-654 (registration)Registration of the 'get-goals' tool on the McpServer using server.tool()
server.tool( "get-goals", "Get fitness goals", { status: z .string() .default("active") .describe("Goal status: active, future, or past"), }, async ({ status }) => { const client = getClient(); const data = await client.get("goal-service/goal/goals", { status }); return jsonResult(data); } ); - src/tools.ts:644-647 (schema)Input schema for 'get-goals': an optional 'status' string (default 'active') describing goal status filter
status: z .string() .default("active") .describe("Goal status: active, future, or past"), - src/tools.ts:649-653 (handler)Handler function that fetches goals from the Garmin Connect API via goal-service/goal/goals endpoint
async ({ status }) => { const client = getClient(); const data = await client.get("goal-service/goal/goals", { status }); return jsonResult(data); } - src/tools.ts:32-39 (helper)getClient() helper that checks session existence and returns the shared GarminClient singleton
function getClient() { if (!sessionExists()) { throw new Error( "No Garmin session found. The user needs to run: npx garmin-connect-mcp login" ); } return getSharedClient(); } - src/garmin-client.ts:127-170 (helper)GarminClient.get() method that performs the actual HTTP fetch through a Playwright browser context
async get( path: string, params?: Record<string, string | number> ): Promise<unknown> { await this.init(); let url = `/gc-api/${path}`; if (params) { const qs = new URLSearchParams(); for (const [k, v] of Object.entries(params)) { qs.set(k, String(v)); } url += `?${qs.toString()}`; } const csrfToken = this.csrfToken; const result = await this.page.evaluate( async ({ url, csrfToken }: { url: string; csrfToken: string }) => { const resp = await fetch(url, { headers: { "connect-csrf-token": csrfToken, Accept: "*/*", }, }); const text = await resp.text(); return { status: resp.status, body: text }; }, { url, csrfToken } ); if (result.status === 204 || (result.status === 200 && !result.body)) { return { noData: true, status: result.status, path }; } if (result.status === 401) { // Invalidate the singleton so the next call re-reads the session file _sharedClient = null; await this.close(); throw new Error(`Garmin API 401: ${path} — ${result.body}`); } if (result.status !== 200) { throw new Error(`Garmin API ${result.status}: ${path} — ${result.body}`); } return JSON.parse(result.body); }