Skip to main content
Glama

getDevices

Retrieve information about your connected Fitbit devices to monitor hardware status and access device-specific data for health tracking.

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • The inline handler function registered for the 'getDevices' tool. It makes an API request to '/user/-/devices.json', returns the JSON-formatted device data, or an error message if the request fails.
    server.tool("getDevices", {}, async () => { try { const endpoint = "/user/-/devices.json"; const data = await makeApiRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } });
  • Shared utility function used by the getDevices handler (and others) to perform authenticated HTTP GET requests to Fitbit API 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; } }
  • src/server.ts:771-796 (registration)
    Registration of the 'getDevices' tool using McpServer.tool method with empty schema and inline handler.
    server.tool("getDevices", {}, async () => { try { const endpoint = "/user/-/devices.json"; const data = await makeApiRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NitayRabi/fitbit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server