getUserSettings
Retrieve user preferences and configuration from Fitbit to customize health tracking and data analysis.
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": "getUserSettings"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:509-540 (registration)Registration of the 'getUserSettings' tool, including its inline handler function. The handler fetches the user's profile from the Fitbit API endpoint '/user/-/profile.json' using the shared makeApiRequest helper and returns the 'user' object from the response. No input parameters (empty schema).
server.tool("getUserSettings", {}, async () => { try { const endpoint = "/user/-/profile.json"; const data = await makeApiRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify( { user: data.user || {}, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } }); - src/server.ts:509-540 (handler)The inline handler for 'getUserSettings' tool executes the core logic: calls Fitbit API for user profile and formats the response as MCP content.
server.tool("getUserSettings", {}, async () => { try { const endpoint = "/user/-/profile.json"; const data = await makeApiRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify( { user: data.user || {}, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } }); - src/server.ts:44-65 (helper)Shared helper function makeApiRequest used by getUserSettings (and other tools) to perform authenticated API calls to Fitbit endpoints.
async function makeApiRequest(endpoint: string): Promise<any> { try { const url = `${baseUrl}${endpoint}`; const response = await fetch(url, { headers: { Authorization: `Bearer ${accessToken}`, Accept: "application/json", }, }); if (!response.ok) { throw new Error( `Fitbit API error: ${response.status} ${response.statusText}` ); } return await response.json(); } catch (error) { console.error(`Error making request to ${endpoint}:`, error); throw error; } }