resmed-data-mcp 1.1.4 → 1.1.6

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/README.md CHANGED
@@ -163,8 +163,11 @@ All under `~/.resmed-data-mcp/` (config cannot override this directory):
163
163
  Every HTTP request, including `/health`, needs `Authorization: Bearer <token>`;
164
164
  anything else gets `401`. The token is a random secret created on first use and
165
165
  kept in the login Keychain (service `resmed-data-mcp-http`, account
166
- `http-auth-token`), never in config or logs. `resmed-data-mcp http-token`
167
- prints it. It is still meant for a trusted home LAN: don't expose port 8420 to
166
+ `http-auth-token`), never in config or logs. When the environment variable
167
+ `RESMED_DATA_MCP_TOKEN` is set and not empty, the server uses it instead and
168
+ leaves the Keychain alone, so a secrets manager can inject the token at start
169
+ (for example `infisical run -- resmed-data-mcp serve`). `resmed-data-mcp http-token`
170
+ prints the token in use. It is still meant for a trusted home LAN: don't expose port 8420 to
168
171
  the internet (no port forwarding, no tunnel). The MCP server's database
169
172
  connection is read-only at the SQLite level, so even a buggy or malicious
170
173
  client can't write through it.
@@ -185,7 +188,7 @@ Install Gitleaks 8.30.1 and enable the staged gate once per clone:
185
188
 
186
189
  ```bash
187
190
  git config core.hooksPath .githooks
188
- gitleaks git --log-opts=--all --config .gitleaks.toml --redact=100 --no-banner .
191
+ gitleaks git --log-opts=HEAD --config .gitleaks.toml --redact=100 --no-banner .
189
192
  npm run build && npm run scan:package
190
193
  ```
191
194
 
@@ -3,11 +3,16 @@
3
3
  * (and Apple Tools): a random bearer token generated once and kept in the
4
4
  * macOS Keychain — never in a config file, the repo, or logs after the
5
5
  * one-time print.
6
+ *
7
+ * The token is read from RESMED_DATA_MCP_TOKEN first (set and non empty),
8
+ * so the server can start through infisical-run, which injects it into the
9
+ * environment; the Keychain item is the fallback, read exactly as before.
6
10
  */
7
11
  import crypto from "node:crypto";
8
12
  import { execFileSync as defaultExecFileSync } from "node:child_process";
9
13
  export declare const KEYCHAIN_SERVICE = "resmed-data-mcp-http";
10
14
  export declare const KEYCHAIN_ACCOUNT = "http-auth-token";
15
+ export declare const ENV_TOKEN_VAR = "RESMED_DATA_MCP_TOKEN";
11
16
  type Exec = typeof defaultExecFileSync;
12
17
  export declare function readKeychainSecret(service: string, account: string, exec?: Exec): string | null;
13
18
  export declare function loadOrCreateHttpAuthToken(options?: {
@@ -15,6 +20,7 @@ export declare function loadOrCreateHttpAuthToken(options?: {
15
20
  forceNew?: boolean;
16
21
  execFileSync?: Exec;
17
22
  randomBytes?: typeof crypto.randomBytes;
23
+ env?: NodeJS.ProcessEnv;
18
24
  }): {
19
25
  token: string;
20
26
  generated: boolean;
@@ -3,12 +3,17 @@
3
3
  * (and Apple Tools): a random bearer token generated once and kept in the
4
4
  * macOS Keychain — never in a config file, the repo, or logs after the
5
5
  * one-time print.
6
+ *
7
+ * The token is read from RESMED_DATA_MCP_TOKEN first (set and non empty),
8
+ * so the server can start through infisical-run, which injects it into the
9
+ * environment; the Keychain item is the fallback, read exactly as before.
6
10
  */
7
11
  import crypto from "node:crypto";
8
12
  import { writeKeychainSecret } from "../keychainWrite.js";
9
13
  import { execFileSync as defaultExecFileSync } from "node:child_process";
10
14
  export const KEYCHAIN_SERVICE = "resmed-data-mcp-http";
11
15
  export const KEYCHAIN_ACCOUNT = "http-auth-token";
16
+ export const ENV_TOKEN_VAR = "RESMED_DATA_MCP_TOKEN";
12
17
  export function readKeychainSecret(service, account, exec = defaultExecFileSync) {
13
18
  try {
14
19
  const out = exec("/usr/bin/security", ["find-generic-password", "-s", service, "-a", account, "-w"], {
@@ -26,6 +31,9 @@ export function loadOrCreateHttpAuthToken(options = {}) {
26
31
  const exec = options.execFileSync || defaultExecFileSync;
27
32
  const randomBytes = options.randomBytes || crypto.randomBytes;
28
33
  if (!options.forceNew) {
34
+ const fromEnv = (options.env || process.env)[ENV_TOKEN_VAR]?.trim();
35
+ if (fromEnv)
36
+ return { token: fromEnv, generated: false };
29
37
  const existing = readKeychainSecret(KEYCHAIN_SERVICE, KEYCHAIN_ACCOUNT, exec);
30
38
  if (existing)
31
39
  return { token: existing, generated: false };
@@ -1 +1 @@
1
- {"version":3,"file":"httpAuth.js","sourceRoot":"","sources":["../../src/mcp/httpAuth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAIlD,MAAM,UAAU,kBAAkB,CAAC,OAAe,EAAE,OAAe,EAAE,OAAa,mBAAmB;IACnG,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC,uBAAuB,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;YACnG,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,UAA2H,EAAE;IAE7H,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,IAAI,mBAA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AC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACpD,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "resmed-data-mcp",
3
- "version": "1.1.4",
4
- "description": "Indexer and read-only MCP server for ResMed AirSense CPAP data: reads the SD card over Wi-Fi through a Toshiba FlashAir card, archives every EDF signal (nightly summary, per-minute therapy detail, events) in a local SQLite database, and serves it to any MCP client over bearer-token HTTP.",
3
+ "version": "1.1.6",
4
+ "description": "Indexer and read-only MCP server for ResMed AirSense CPAP data: reads the SD card over Wi-Fi through a Toshiba FlashAir card, archives every EDF signal in a local SQLite database, and serves it to any MCP client over bearer-token HTTP.",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",
7
7
  "bin": {
@@ -65,6 +65,6 @@
65
65
  "devDependencies": {
66
66
  "@types/node": "^22.10.0",
67
67
  "typescript": "^5.7.0",
68
- "vitest": "^2.1.0"
68
+ "vitest": "^4.1.12"
69
69
  }
70
70
  }