fitdays-mcp-server 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rodrigo Roque
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # fitdays-mcp-server
2
+
3
+ [Model Context Protocol](https://modelcontextprotocol.io) server that exposes
4
+ the unofficial [FitDays / iComon smart-scale API](https://github.com/roquerodrigo/fitdays-api)
5
+ as tools that an LLM client (Claude Desktop, Claude Code, etc.) can call.
6
+
7
+ It logs into your FitDays account once, caches a full ~6-year sync in memory,
8
+ and serves the data as structured tool responses.
9
+
10
+ ## Tools
11
+
12
+ | Tool | What it does |
13
+ | --- | --- |
14
+ | `list_users` | Sub-users (people) registered under the account. |
15
+ | `list_devices` | FitDays-compatible devices known to the account. |
16
+ | `get_weight_history` | Body-composition / weight measurements. Filters: `suid`, `since`, `until`, `limit`, `include_deleted` (default `true` — the FitDays mobile app marks edited records `is_deleted: 1` rather than removing them server-side). |
17
+ | `get_latest_weight` | Most recent weight measurement (filter by `suid`; `include_deleted` defaults to `false`). |
18
+ | `refresh_sync` | Force-refresh the cached sync data. Returns counts including the `active` / `deleted` / `total` split for weight records. |
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ npm install -g fitdays-mcp-server
24
+ ```
25
+
26
+ Requires Node.js ≥ 22.
27
+
28
+ ## Configuration
29
+
30
+ The server reads credentials from environment variables:
31
+
32
+ | Variable | Required | Default |
33
+ | --- | --- | --- |
34
+ | `FITDAYS_EMAIL` | yes | — |
35
+ | `FITDAYS_PASSWORD` | yes | — |
36
+ | `FITDAYS_REGION` | no | `us` (other values: see [`fitdays-api` regions](https://github.com/roquerodrigo/fitdays-api)) |
37
+
38
+ ## Use with Claude Desktop / Claude Code
39
+
40
+ Add it to your MCP client config (`claude_desktop_config.json` or
41
+ `~/.claude.json` / `.mcp.json`):
42
+
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "fitdays": {
47
+ "command": "npx",
48
+ "args": ["-y", "fitdays-mcp-server"],
49
+ "env": {
50
+ "FITDAYS_EMAIL": "you@example.com",
51
+ "FITDAYS_PASSWORD": "your-password"
52
+ }
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ ## Run from source
59
+
60
+ ```sh
61
+ git clone https://github.com/roquerodrigo/fitdays-mcp-server.git
62
+ cd fitdays-mcp-server
63
+ npm install
64
+ npm run build
65
+ FITDAYS_EMAIL=… FITDAYS_PASSWORD=… npm start
66
+ ```
67
+
68
+ ## License
69
+
70
+ MIT
@@ -0,0 +1,12 @@
1
+ import type { Region, SyncFromServerData } from 'fitdays-api';
2
+ export declare class FitDaysSession {
3
+ private readonly email;
4
+ private readonly password;
5
+ private readonly region;
6
+ private cache;
7
+ private client;
8
+ private loginPromise;
9
+ constructor(email: string, password: string, region?: Region);
10
+ getSync: (force?: boolean) => Promise<SyncFromServerData>;
11
+ private getClient;
12
+ }
@@ -0,0 +1,45 @@
1
+ import { FitDaysClient } from 'fitdays-api';
2
+ const SYNC_TTL_MS = 5 * 60 * 1000;
3
+ export class FitDaysSession {
4
+ email;
5
+ password;
6
+ region;
7
+ cache = null;
8
+ client = null;
9
+ loginPromise = null;
10
+ constructor(email, password, region = 'us') {
11
+ this.email = email;
12
+ this.password = password;
13
+ this.region = region;
14
+ }
15
+ getSync = async (force = false) => {
16
+ const now = Date.now();
17
+ if (!force && this.cache && now - this.cache.fetchedAt < SYNC_TTL_MS) {
18
+ return this.cache.data;
19
+ }
20
+ const client = await this.getClient();
21
+ const res = await client.syncAll();
22
+ if (!res.data) {
23
+ throw new Error(`syncAll returned no data (code=${String(res.code)})`);
24
+ }
25
+ this.cache = { data: res.data, fetchedAt: now };
26
+ return res.data;
27
+ };
28
+ getClient = async () => {
29
+ if (this.client?.session)
30
+ return this.client;
31
+ if (!this.loginPromise) {
32
+ this.loginPromise = (async () => {
33
+ const c = new FitDaysClient({ region: this.region });
34
+ await c.login(this.email, this.password);
35
+ this.client = c;
36
+ })().finally(() => {
37
+ this.loginPromise = null;
38
+ });
39
+ }
40
+ await this.loginPromise;
41
+ if (!this.client)
42
+ throw new Error('FitDays client not initialized after login');
43
+ return this.client;
44
+ };
45
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { FitDaysSession } from './fitdays.js';
4
+ import { buildServer } from './server.js';
5
+ const main = async () => {
6
+ const email = process.env.FITDAYS_EMAIL;
7
+ const password = process.env.FITDAYS_PASSWORD;
8
+ const region = (process.env.FITDAYS_REGION ?? 'us');
9
+ if (!email || !password) {
10
+ console.error('FITDAYS_EMAIL and FITDAYS_PASSWORD must be set in the environment.');
11
+ process.exit(1);
12
+ }
13
+ const session = new FitDaysSession(email, password, region);
14
+ const server = buildServer(session);
15
+ const transport = new StdioServerTransport();
16
+ await server.connect(transport);
17
+ };
18
+ main().catch((err) => {
19
+ console.error(err);
20
+ process.exit(1);
21
+ });
@@ -0,0 +1,3 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { FitDaysSession } from './fitdays.js';
3
+ export declare const buildServer: (session: FitDaysSession) => McpServer;
package/dist/server.js ADDED
@@ -0,0 +1,126 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod';
3
+ const json = (value) => ({
4
+ content: [{ text: JSON.stringify(value, null, 2), type: 'text' }],
5
+ });
6
+ const summarizeUser = (u) => ({
7
+ birthday: u.birthday,
8
+ height_cm: u.height,
9
+ nickname: u.nickname,
10
+ sex: u.sex === 0 ? 'female' : 'male',
11
+ suid: u.suid,
12
+ target_weight_kg: u.target_weight,
13
+ uid: u.uid,
14
+ });
15
+ const summarizeWeight = (r) => ({
16
+ bfr_pct: r.bfr,
17
+ bm_kg: r.bm,
18
+ bmi: r.bmi,
19
+ bmr_kcal: r.bmr,
20
+ bodyage: r.bodyage,
21
+ data_id: r.data_id,
22
+ is_deleted: r.is_deleted,
23
+ measured_at: new Date(r.measured_time * 1000).toISOString(),
24
+ measured_time: r.measured_time,
25
+ pp_pct: r.pp,
26
+ rom_pct: r.rom,
27
+ sfr_pct: r.sfr,
28
+ suid: r.suid,
29
+ uid: r.uid,
30
+ uvi: r.uvi,
31
+ vwc_pct: r.vwc,
32
+ weight_kg: r.weight_kg,
33
+ weight_lb: r.weight_lb,
34
+ });
35
+ export const buildServer = (session) => {
36
+ const server = new McpServer({ name: 'fitdays-mcp-server', version: '1.0.0' });
37
+ server.registerTool('list_users', {
38
+ description: 'List the sub-users (people) registered under the FitDays account.',
39
+ inputSchema: {},
40
+ title: 'List FitDays users',
41
+ }, async () => {
42
+ const data = await session.getSync();
43
+ return json(data.users.filter((u) => u.is_deleted === 0).map(summarizeUser));
44
+ });
45
+ server.registerTool('list_devices', {
46
+ description: 'List the FitDays-compatible devices known to the account.',
47
+ inputSchema: {},
48
+ title: 'List FitDays devices',
49
+ }, async () => {
50
+ const data = await session.getSync();
51
+ return json(data.devices.map((d) => ({
52
+ device_id: d.device_id,
53
+ firmware_ver: d.firmware_ver,
54
+ mac: d.mac,
55
+ model: d.model,
56
+ name: d.name,
57
+ })));
58
+ });
59
+ server.registerTool('get_weight_history', {
60
+ description: 'Return body-composition / weight measurements, optionally filtered by sub-user (`suid`) and time window. Times are unix seconds. By default includes records the server marks `is_deleted: 1` (tombstones from the mobile app) — set `include_deleted: false` to hide them.',
61
+ inputSchema: {
62
+ include_deleted: z.boolean().optional()
63
+ .describe('Include records with `is_deleted: 1` (server-side tombstones). Default: true.'),
64
+ limit: z.number().int().positive().max(1000).optional()
65
+ .describe('Maximum number of records (newest first). Default: 100.'),
66
+ since: z.number().int().nonnegative().optional()
67
+ .describe('Only include records measured at or after this unix-seconds timestamp.'),
68
+ suid: z.number().int().optional()
69
+ .describe('Sub-user id (from list_users). Omit to return records for all users.'),
70
+ until: z.number().int().nonnegative().optional()
71
+ .describe('Only include records measured at or before this unix-seconds timestamp.'),
72
+ },
73
+ title: 'Weight history',
74
+ }, async ({ include_deleted, limit, since, suid, until }) => {
75
+ const includeDeleted = include_deleted ?? true;
76
+ const data = await session.getSync();
77
+ const records = data.weight_list
78
+ .filter((r) => includeDeleted || r.is_deleted === 0)
79
+ .filter((r) => suid === undefined || r.suid === suid)
80
+ .filter((r) => since === undefined || r.measured_time >= since)
81
+ .filter((r) => until === undefined || r.measured_time <= until)
82
+ .sort((a, b) => b.measured_time - a.measured_time)
83
+ .slice(0, limit ?? 100)
84
+ .map(summarizeWeight);
85
+ return json(records);
86
+ });
87
+ server.registerTool('get_latest_weight', {
88
+ description: 'Return the most recent weight measurement, optionally for a single sub-user. By default ignores tombstoned records (`is_deleted: 1`).',
89
+ inputSchema: {
90
+ include_deleted: z.boolean().optional()
91
+ .describe('Include records with `is_deleted: 1`. Default: false.'),
92
+ suid: z.number().int().optional()
93
+ .describe('Sub-user id. Omit to return the latest record across all users.'),
94
+ },
95
+ title: 'Latest weight',
96
+ }, async ({ include_deleted, suid }) => {
97
+ const includeDeleted = include_deleted ?? false;
98
+ const data = await session.getSync();
99
+ const latest = data.weight_list
100
+ .filter((r) => includeDeleted || r.is_deleted === 0)
101
+ .filter((r) => suid === undefined || r.suid === suid)
102
+ .reduce((acc, r) => {
103
+ return acc === null || r.measured_time > acc.measured_time ? r : acc;
104
+ }, null);
105
+ return json(latest ? summarizeWeight(latest) : null);
106
+ });
107
+ server.registerTool('refresh_sync', {
108
+ description: 'Force-refresh the cached FitDays sync data. Returns counts per record type.',
109
+ inputSchema: {},
110
+ title: 'Refresh sync cache',
111
+ }, async () => {
112
+ const data = await session.getSync(true);
113
+ const activeWeight = data.weight_list.filter((r) => r.is_deleted === 0).length;
114
+ return json({
115
+ devices: data.devices.length,
116
+ height_records: data.height_list.length,
117
+ users: data.users.length,
118
+ weight_records: {
119
+ active: activeWeight,
120
+ deleted: data.weight_list.length - activeWeight,
121
+ total: data.weight_list.length,
122
+ },
123
+ });
124
+ });
125
+ return server;
126
+ };
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "fitdays-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "MCP server exposing the unofficial FitDays / iComon smart-scale API as tools (weight history, devices, users) for LLM clients.",
5
+ "keywords": [
6
+ "mcp",
7
+ "model-context-protocol",
8
+ "fitdays",
9
+ "icomon",
10
+ "smart-scale",
11
+ "body-composition",
12
+ "weight",
13
+ "bluetooth-scale"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "Rodrigo Roque <rodrigogoncalvesroque@gmail.com>",
17
+ "homepage": "https://github.com/roquerodrigo/fitdays-mcp-server#readme",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/roquerodrigo/fitdays-mcp-server.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/roquerodrigo/fitdays-mcp-server/issues"
24
+ },
25
+ "type": "module",
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ }
33
+ },
34
+ "bin": {
35
+ "fitdays-mcp-server": "dist/index.js"
36
+ },
37
+ "sideEffects": false,
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "scripts": {
42
+ "build": "tsc",
43
+ "build:publish": "rm -rf dist && tsc",
44
+ "start": "node dist/index.js",
45
+ "lint": "eslint --fix",
46
+ "prepack": "npm run build:publish",
47
+ "prepublishOnly": "npm run lint"
48
+ },
49
+ "dependencies": {
50
+ "@modelcontextprotocol/sdk": "^1.29.0",
51
+ "fitdays-api": "^1.0.0",
52
+ "zod": "^4.4.2"
53
+ },
54
+ "devDependencies": {
55
+ "@eslint/js": "10.0.1",
56
+ "@stylistic/eslint-plugin": "5.10.0",
57
+ "@types/node": "^20.12.0",
58
+ "eslint": "10.2.0",
59
+ "eslint-plugin-perfectionist": "5.8.0",
60
+ "globals": "17.4.0",
61
+ "typescript": "^5.5.3",
62
+ "typescript-eslint": "8.58.1"
63
+ },
64
+ "engines": {
65
+ "node": ">=22.0.0"
66
+ },
67
+ "publishConfig": {
68
+ "access": "public"
69
+ }
70
+ }