getbased-mcp 0.2.6__tar.gz → 0.2.7__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: getbased-mcp
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: MCP server for querying blood work data and knowledge base from getbased
5
5
  License-Expression: AGPL-3.0-or-later
6
6
  Requires-Python: >=3.10
@@ -8,7 +8,7 @@ Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
9
9
  Requires-Dist: mcp>=1.0.0
10
10
  Requires-Dist: httpx>=0.27
11
- Requires-Dist: cryptography>=42.0
11
+ Requires-Dist: cryptography>=48.0.1
12
12
  Provides-Extra: test
13
13
  Requires-Dist: pytest>=8.0; extra == "test"
14
14
  Requires-Dist: pytest-asyncio>=0.23; extra == "test"
@@ -17,9 +17,9 @@ Dynamic: license-file
17
17
 
18
18
  # getbased MCP Server
19
19
 
20
- An [MCP](https://modelcontextprotocol.io) server that exposes blood work data and an optional RAG knowledge base from [getbased](https://getbased.health) as tools. Works with any MCP-compatible client (Claude Code, Hermes, Claude Desktop, etc.).
20
+ An [MCP](https://modelcontextprotocol.io) server that exposes getbased health context and an optional local knowledge base as tools. Works with MCP-compatible clients such as Claude Code, Claude Desktop, Cursor, Cline, Codex CLI, Hermes, and OpenClaw.
21
21
 
22
- > **Installing for the first time?** The [getbased-agent-stack](https://github.com/elkimek/getbased-agents/tree/main/packages/stack) meta-package bundles this MCP with the RAG engine it talks to, plus example configs for Claude Code and Hermes. One command and you're up.
22
+ > **Installing for the first time?** Use the private setup command from **getbased → Settings → Agent Access**. It installs or updates [getbased-agent-stack](https://github.com/elkimek/getbased-agents/tree/main/packages/stack), stores the token/key locally, and configures the selected client.
23
23
 
24
24
  ## How it works
25
25
 
@@ -31,21 +31,21 @@ getbased (browser)
31
31
  ├── encrypts the rendered agent context with that context key
32
32
  └── pushes ciphertext to sync gateway on every save
33
33
 
34
- Sync Gateway (sync.getbased.health/api/context)
34
+ Context gateway (sync.getbased.health/api/context)
35
35
  └── stores encrypted context behind token auth; it cannot read the plaintext
36
36
 
37
- RAG Server (localhost, optional)
37
+ Local knowledge server (localhost, optional)
38
38
  ├── Vector database with embedded chunks
39
39
  ├── Embedding model for semantic search
40
40
  └── Your curated health knowledge base
41
41
 
42
42
  This MCP Server (on your machine)
43
- ├── fetches blood work context from sync gateway
44
- ├── queries RAG server for knowledge base searches (optional)
43
+ ├── fetches health context from the context gateway
44
+ ├── queries the local knowledge server for knowledge-base searches (optional)
45
45
  └── exposes everything as tools to any MCP client
46
46
  ```
47
47
 
48
- Your mnemonic never leaves your browser. The sync gateway receives only an end-to-end encrypted agent-context envelope; this MCP decrypts it locally with `GETBASED_AGENT_CONTEXT_KEY` and then exposes the same lab context text the getbased AI chat uses — not raw data. `GETBASED_TOKEN` is only the relay bearer token.
48
+ Your mnemonic never leaves your browser. The gateway receives only an encrypted agent-context envelope; this MCP decrypts it locally with `GETBASED_AGENT_CONTEXT_KEY` and exposes the same summary text the getbased AI chat uses. `GETBASED_TOKEN` is only the relay bearer token.
49
49
 
50
50
  ## Tools
51
51
 
@@ -54,7 +54,7 @@ Your mnemonic never leaves your browser. The sync gateway receives only an end-t
54
54
  | `getbased_lab_context` | Full lab summary with biomarkers, context cards, supplements, goals. Pass `profile` to target a specific profile. |
55
55
  | `getbased_section` | Get a specific section (e.g. hormones, lipids) or list all available sections |
56
56
  | `getbased_list_profiles` | List available profiles |
57
- | `knowledge_search` | Semantic search across the active library on your knowledge base (requires RAG server). Returns relevant passages with source attribution. |
57
+ | `knowledge_search` | Semantic search across the active library on your knowledge base (requires the local knowledge server). Returns relevant passages with source attribution. |
58
58
  | `knowledge_list_libraries` | List all knowledge base libraries and show which is active |
59
59
  | `knowledge_activate_library` | Switch the active library — subsequent searches target the new one until switched again |
60
60
  | `knowledge_stats` | Per-source chunk counts for the active library — useful for diagnosing missing results |
@@ -91,7 +91,7 @@ knowledge_search(query="blue light DHA mitochondrial damage")
91
91
  knowledge_search(query="MTHFR methylation folate", n_results=5)
92
92
  ```
93
93
 
94
- **Note:** This tool requires the RAG server to be running. Without it, all blood work tools still work — the MCP degrades gracefully.
94
+ **Note:** This tool requires the local knowledge server to be running. If it is not running, knowledge search will fail, but the lab-context tools still work.
95
95
 
96
96
  ### Multi-library (v0.2+)
97
97
 
@@ -119,24 +119,34 @@ The gateway stores context per profile ID. To work with multiple profiles:
119
119
 
120
120
  ## Setup
121
121
 
122
- ### 1. Enable Agent Access in getbased
122
+ ### Recommended: copy the private setup command
123
123
 
124
- Go to **Settings > Data > Agent Access** and toggle it on. Copy both values:
124
+ In getbased, open **Settings → Agent Access**, choose your target client, and copy the setup command. It looks like this:
125
+
126
+ ```bash
127
+ curl -fsSL https://getbased.health/install.sh | bash -s -- connect <target> --setup 'gbsetup_v1_...'
128
+ ```
129
+
130
+ The setup payload is private. Paste it only into a terminal you control.
131
+
132
+ ### Manual setup
133
+
134
+ If you are not using `getbased-stack connect`, open **Settings → Agent Access** and copy both values:
125
135
 
126
136
  - **Read-only token** → `GETBASED_TOKEN` for relay authorization
127
137
  - **Context encryption key** → `GETBASED_AGENT_CONTEXT_KEY` for local decryption
128
138
 
129
- ### 2. Set up a RAG server (optional — for knowledge_search)
139
+ ### Set up a local knowledge server (optional, for `knowledge_search`)
130
140
 
131
- The knowledge base runs as a separate service. You need:
141
+ The knowledge base runs as a separate service. The easiest path is `getbased-agent-stack[full]`, which installs `getbased-rag` and the browser dashboard. If you are wiring your own server, you need:
132
142
 
133
143
  - A vector database (e.g. [Qdrant](https://qdrant.tech/), [ChromaDB](https://www.trychroma.com/)) loaded with your document chunks and embeddings
134
144
  - A FastAPI (or similar) server that accepts `POST /query` with `{version: 1, query: "...", top_k: N}` and returns `{chunks: [{text: "...", source: "..."}]}`
135
145
  - An embedding model (e.g. [BGE-M3](https://huggingface.co/BAAI/bge-m3)) for semantic search
136
146
 
137
- The RAG server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it — no models loaded here.
147
+ The local knowledge server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it; no models are loaded inside the MCP process.
138
148
 
139
- **RAG server contract:**
149
+ **Knowledge server contract:**
140
150
 
141
151
  | Field | Required | Description |
142
152
  |---|---|---|
@@ -145,7 +155,7 @@ The RAG server handles embedding, similarity search, and filtering. This MCP jus
145
155
  | `GET /health` | Optional | Returns `{"status": "ok", "rag_ready": bool, "chunks": int}` |
146
156
  | Response | Yes | `{"chunks": [{"text": "...", "source": "..."}]}` |
147
157
 
148
- ### 3. Configure your MCP client
158
+ ### Configure your MCP client manually
149
159
 
150
160
  #### Claude Code / Claude Desktop
151
161
 
@@ -174,7 +184,7 @@ hermes mcp add getbased \
174
184
  --args /path/to/getbased_mcp.py
175
185
  ```
176
186
 
177
- Then set `GETBASED_TOKEN` and `GETBASED_AGENT_CONTEXT_KEY` in `~/.hermes/.env` or in the MCP server's `env` config in `config.yaml`:
187
+ Then set `GETBASED_TOKEN` and `GETBASED_AGENT_CONTEXT_KEY` in the MCP server's `env` config in `config.yaml`:
178
188
 
179
189
  ```yaml
180
190
  mcp_servers:
@@ -199,30 +209,30 @@ Ask about your labs in any connected conversation:
199
209
 
200
210
  | Variable | Required | Description |
201
211
  |---|---|---|
202
- | `GETBASED_TOKEN` | Yes | Read-only bearer token from getbased Settings > Data > Agent Access; authorizes fetches from the context gateway |
203
- | `GETBASED_AGENT_CONTEXT_KEY` | Yes for encrypted Agent Access payloads | Context encryption key from getbased Settings > Data > Agent Access; decrypts the relay payload locally in this MCP |
212
+ | `GETBASED_TOKEN` | Yes | Read-only bearer token from getbased Settings → Agent Access; authorizes fetches from the context gateway |
213
+ | `GETBASED_AGENT_CONTEXT_KEY` | Yes for encrypted Agent Access payloads | Context encryption key from getbased Settings → Agent Access; decrypts the relay payload locally in this MCP |
204
214
  | `GETBASED_GATEWAY` | No | Context gateway URL (default: `https://sync.getbased.health`) |
205
- | `LENS_URL` | No | RAG server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
206
- | `LENS_PORT` | No | RAG server port, only used to build default `LENS_URL` (default: `8322`) |
207
- | `LENS_API_KEY_FILE` | No | Path to RAG API key file. Default: `$XDG_DATA_HOME/getbased/lens/api_key` (getbased-rag's canonical location). If that file doesn't exist but the legacy `~/.hermes/rag/lens_api_key` does, the legacy path is used instead — upgrades from standalone `getbased-mcp` ≤ 0.1.0 keep working without config changes. |
215
+ | `LENS_URL` | No | Local knowledge server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
216
+ | `LENS_PORT` | No | Local knowledge server port, only used to build default `LENS_URL` (default: `8322`) |
217
+ | `LENS_API_KEY_FILE` | No | Path to the knowledge server API key file. Default: `$XDG_DATA_HOME/getbased/lens/api_key` (getbased-rag's canonical location). If that file doesn't exist but the legacy `~/.hermes/rag/lens_api_key` does, the legacy path is used instead; upgrades from standalone `getbased-mcp` ≤ 0.1.0 keep working without config changes. |
208
218
  | `LENS_MCP_ACTIVITY_LOG` | No | JSONL path where tool-call activity is appended. Default: `$XDG_STATE_HOME/getbased/mcp/activity.jsonl`. Each record: `{ts, tool, duration_ms, ok, error?}` — arguments are never logged (queries may contain sensitive health info). Set to `off` / `false` / `0` to disable. The [getbased-dashboard](https://github.com/elkimek/getbased-agents/tree/main/packages/dashboard) Activity tab tails this file. |
209
219
 
210
220
  ## Custom Knowledge Source (getbased app)
211
221
 
212
- The same RAG server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
222
+ The same local knowledge server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
213
223
 
214
224
  1. Run `getbased_lens_config` — it returns the endpoint URL, API key, and recommended `top_k`
215
- 2. In getbased, go to **Settings → AI → Custom Knowledge Source**
225
+ 2. In getbased, open **Knowledge Base** and choose **External server**
216
226
  3. Paste the endpoint URL, API key, and set `top_k` to 5
217
227
  4. Enable it — the chat-header Lens badge will light up green when active
218
228
 
219
- Every chat question and focus card will now be enriched with RAG-retrieved passages from your knowledge base.
229
+ Every chat question and Current Focus refresh can now include passages from your knowledge base.
220
230
 
221
231
  ## Troubleshooting
222
232
 
223
233
  ### `knowledge_search` returns "Lens server not reachable"
224
234
 
225
- The RAG server isn't running. Start it and verify with:
235
+ The local knowledge server is not running. Start it and verify with:
226
236
 
227
237
  ```bash
228
238
  curl http://localhost:8322/health
@@ -230,7 +240,7 @@ curl http://localhost:8322/health
230
240
 
231
241
  ### `knowledge_search` returns "Lens API key not found"
232
242
 
233
- getbased-rag generates its API key on first start and writes it to `$XDG_DATA_HOME/getbased/lens/api_key` (e.g. `~/.local/share/getbased/lens/api_key` on Linux). If you're upgrading from the standalone `getbased-mcp` ≤ 0.1.0 and your key is at `~/.hermes/rag/lens_api_key`, that legacy path is still auto-detected — no config change needed. If the file is missing entirely, restart the RAG server and it will create a new one.
243
+ getbased-rag generates its API key on first start and writes it to `$XDG_DATA_HOME/getbased/lens/api_key` (e.g. `~/.local/share/getbased/lens/api_key` on Linux). If you're upgrading from the standalone `getbased-mcp` ≤ 0.1.0 and your key is at `~/.hermes/rag/lens_api_key`, that legacy path is still auto-detected; no config change needed. If the file is missing entirely, restart the knowledge server and it will create a new one.
234
244
 
235
245
  ### `knowledge_list_libraries` / `knowledge_stats` return "this lens server doesn't expose library management"
236
246
 
@@ -238,7 +248,7 @@ The lens server you're pointed at is older than `getbased-rag` 0.1.0 and doesn't
238
248
 
239
249
  ### Blood work tools work but knowledge_search doesn't
240
250
 
241
- That's expected — they're independent. Blood work tools talk to the sync gateway; knowledge_search talks to the RAG server. The MCP degrades gracefully: if the RAG server is down, all blood work tools continue to work normally.
251
+ That's expected. Blood work tools talk to the context gateway; `knowledge_search` talks to the local knowledge server. If the knowledge server is down, knowledge search will fail, but the lab-context tools continue to work normally.
242
252
 
243
253
  ## Security
244
254
 
@@ -250,7 +260,7 @@ That's expected — they're independent. Blood work tools talk to the sync gatew
250
260
 
251
261
  ## Related projects
252
262
 
253
- - **[getbased](https://github.com/elkimek/get-based)** — the health dashboard. This MCP reads the same lab context the in-app AI chat uses, and queries the same Knowledge Source endpoint configured in Settings → AI → Custom Knowledge Source. The [endpoint contract](https://github.com/elkimek/get-based/blob/main/dev-docs/lens-endpoint-contract.md) is shared — one server backs both the app and this MCP.
263
+ - **[getbased](https://github.com/elkimek/get-based)** — the health dashboard. This MCP reads the same context the in-app AI chat uses, and can query the same external Knowledge Base server configured in the app. The endpoint contract is shared: one server can back both the app and this MCP.
254
264
 
255
265
  ## License
256
266
 
@@ -1,8 +1,8 @@
1
1
  # getbased MCP Server
2
2
 
3
- An [MCP](https://modelcontextprotocol.io) server that exposes blood work data and an optional RAG knowledge base from [getbased](https://getbased.health) as tools. Works with any MCP-compatible client (Claude Code, Hermes, Claude Desktop, etc.).
3
+ An [MCP](https://modelcontextprotocol.io) server that exposes getbased health context and an optional local knowledge base as tools. Works with MCP-compatible clients such as Claude Code, Claude Desktop, Cursor, Cline, Codex CLI, Hermes, and OpenClaw.
4
4
 
5
- > **Installing for the first time?** The [getbased-agent-stack](https://github.com/elkimek/getbased-agents/tree/main/packages/stack) meta-package bundles this MCP with the RAG engine it talks to, plus example configs for Claude Code and Hermes. One command and you're up.
5
+ > **Installing for the first time?** Use the private setup command from **getbased → Settings → Agent Access**. It installs or updates [getbased-agent-stack](https://github.com/elkimek/getbased-agents/tree/main/packages/stack), stores the token/key locally, and configures the selected client.
6
6
 
7
7
  ## How it works
8
8
 
@@ -14,21 +14,21 @@ getbased (browser)
14
14
  ├── encrypts the rendered agent context with that context key
15
15
  └── pushes ciphertext to sync gateway on every save
16
16
 
17
- Sync Gateway (sync.getbased.health/api/context)
17
+ Context gateway (sync.getbased.health/api/context)
18
18
  └── stores encrypted context behind token auth; it cannot read the plaintext
19
19
 
20
- RAG Server (localhost, optional)
20
+ Local knowledge server (localhost, optional)
21
21
  ├── Vector database with embedded chunks
22
22
  ├── Embedding model for semantic search
23
23
  └── Your curated health knowledge base
24
24
 
25
25
  This MCP Server (on your machine)
26
- ├── fetches blood work context from sync gateway
27
- ├── queries RAG server for knowledge base searches (optional)
26
+ ├── fetches health context from the context gateway
27
+ ├── queries the local knowledge server for knowledge-base searches (optional)
28
28
  └── exposes everything as tools to any MCP client
29
29
  ```
30
30
 
31
- Your mnemonic never leaves your browser. The sync gateway receives only an end-to-end encrypted agent-context envelope; this MCP decrypts it locally with `GETBASED_AGENT_CONTEXT_KEY` and then exposes the same lab context text the getbased AI chat uses — not raw data. `GETBASED_TOKEN` is only the relay bearer token.
31
+ Your mnemonic never leaves your browser. The gateway receives only an encrypted agent-context envelope; this MCP decrypts it locally with `GETBASED_AGENT_CONTEXT_KEY` and exposes the same summary text the getbased AI chat uses. `GETBASED_TOKEN` is only the relay bearer token.
32
32
 
33
33
  ## Tools
34
34
 
@@ -37,7 +37,7 @@ Your mnemonic never leaves your browser. The sync gateway receives only an end-t
37
37
  | `getbased_lab_context` | Full lab summary with biomarkers, context cards, supplements, goals. Pass `profile` to target a specific profile. |
38
38
  | `getbased_section` | Get a specific section (e.g. hormones, lipids) or list all available sections |
39
39
  | `getbased_list_profiles` | List available profiles |
40
- | `knowledge_search` | Semantic search across the active library on your knowledge base (requires RAG server). Returns relevant passages with source attribution. |
40
+ | `knowledge_search` | Semantic search across the active library on your knowledge base (requires the local knowledge server). Returns relevant passages with source attribution. |
41
41
  | `knowledge_list_libraries` | List all knowledge base libraries and show which is active |
42
42
  | `knowledge_activate_library` | Switch the active library — subsequent searches target the new one until switched again |
43
43
  | `knowledge_stats` | Per-source chunk counts for the active library — useful for diagnosing missing results |
@@ -74,7 +74,7 @@ knowledge_search(query="blue light DHA mitochondrial damage")
74
74
  knowledge_search(query="MTHFR methylation folate", n_results=5)
75
75
  ```
76
76
 
77
- **Note:** This tool requires the RAG server to be running. Without it, all blood work tools still work — the MCP degrades gracefully.
77
+ **Note:** This tool requires the local knowledge server to be running. If it is not running, knowledge search will fail, but the lab-context tools still work.
78
78
 
79
79
  ### Multi-library (v0.2+)
80
80
 
@@ -102,24 +102,34 @@ The gateway stores context per profile ID. To work with multiple profiles:
102
102
 
103
103
  ## Setup
104
104
 
105
- ### 1. Enable Agent Access in getbased
105
+ ### Recommended: copy the private setup command
106
106
 
107
- Go to **Settings > Data > Agent Access** and toggle it on. Copy both values:
107
+ In getbased, open **Settings → Agent Access**, choose your target client, and copy the setup command. It looks like this:
108
+
109
+ ```bash
110
+ curl -fsSL https://getbased.health/install.sh | bash -s -- connect <target> --setup 'gbsetup_v1_...'
111
+ ```
112
+
113
+ The setup payload is private. Paste it only into a terminal you control.
114
+
115
+ ### Manual setup
116
+
117
+ If you are not using `getbased-stack connect`, open **Settings → Agent Access** and copy both values:
108
118
 
109
119
  - **Read-only token** → `GETBASED_TOKEN` for relay authorization
110
120
  - **Context encryption key** → `GETBASED_AGENT_CONTEXT_KEY` for local decryption
111
121
 
112
- ### 2. Set up a RAG server (optional — for knowledge_search)
122
+ ### Set up a local knowledge server (optional, for `knowledge_search`)
113
123
 
114
- The knowledge base runs as a separate service. You need:
124
+ The knowledge base runs as a separate service. The easiest path is `getbased-agent-stack[full]`, which installs `getbased-rag` and the browser dashboard. If you are wiring your own server, you need:
115
125
 
116
126
  - A vector database (e.g. [Qdrant](https://qdrant.tech/), [ChromaDB](https://www.trychroma.com/)) loaded with your document chunks and embeddings
117
127
  - A FastAPI (or similar) server that accepts `POST /query` with `{version: 1, query: "...", top_k: N}` and returns `{chunks: [{text: "...", source: "..."}]}`
118
128
  - An embedding model (e.g. [BGE-M3](https://huggingface.co/BAAI/bge-m3)) for semantic search
119
129
 
120
- The RAG server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it — no models loaded here.
130
+ The local knowledge server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it; no models are loaded inside the MCP process.
121
131
 
122
- **RAG server contract:**
132
+ **Knowledge server contract:**
123
133
 
124
134
  | Field | Required | Description |
125
135
  |---|---|---|
@@ -128,7 +138,7 @@ The RAG server handles embedding, similarity search, and filtering. This MCP jus
128
138
  | `GET /health` | Optional | Returns `{"status": "ok", "rag_ready": bool, "chunks": int}` |
129
139
  | Response | Yes | `{"chunks": [{"text": "...", "source": "..."}]}` |
130
140
 
131
- ### 3. Configure your MCP client
141
+ ### Configure your MCP client manually
132
142
 
133
143
  #### Claude Code / Claude Desktop
134
144
 
@@ -157,7 +167,7 @@ hermes mcp add getbased \
157
167
  --args /path/to/getbased_mcp.py
158
168
  ```
159
169
 
160
- Then set `GETBASED_TOKEN` and `GETBASED_AGENT_CONTEXT_KEY` in `~/.hermes/.env` or in the MCP server's `env` config in `config.yaml`:
170
+ Then set `GETBASED_TOKEN` and `GETBASED_AGENT_CONTEXT_KEY` in the MCP server's `env` config in `config.yaml`:
161
171
 
162
172
  ```yaml
163
173
  mcp_servers:
@@ -182,30 +192,30 @@ Ask about your labs in any connected conversation:
182
192
 
183
193
  | Variable | Required | Description |
184
194
  |---|---|---|
185
- | `GETBASED_TOKEN` | Yes | Read-only bearer token from getbased Settings > Data > Agent Access; authorizes fetches from the context gateway |
186
- | `GETBASED_AGENT_CONTEXT_KEY` | Yes for encrypted Agent Access payloads | Context encryption key from getbased Settings > Data > Agent Access; decrypts the relay payload locally in this MCP |
195
+ | `GETBASED_TOKEN` | Yes | Read-only bearer token from getbased Settings → Agent Access; authorizes fetches from the context gateway |
196
+ | `GETBASED_AGENT_CONTEXT_KEY` | Yes for encrypted Agent Access payloads | Context encryption key from getbased Settings → Agent Access; decrypts the relay payload locally in this MCP |
187
197
  | `GETBASED_GATEWAY` | No | Context gateway URL (default: `https://sync.getbased.health`) |
188
- | `LENS_URL` | No | RAG server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
189
- | `LENS_PORT` | No | RAG server port, only used to build default `LENS_URL` (default: `8322`) |
190
- | `LENS_API_KEY_FILE` | No | Path to RAG API key file. Default: `$XDG_DATA_HOME/getbased/lens/api_key` (getbased-rag's canonical location). If that file doesn't exist but the legacy `~/.hermes/rag/lens_api_key` does, the legacy path is used instead — upgrades from standalone `getbased-mcp` ≤ 0.1.0 keep working without config changes. |
198
+ | `LENS_URL` | No | Local knowledge server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
199
+ | `LENS_PORT` | No | Local knowledge server port, only used to build default `LENS_URL` (default: `8322`) |
200
+ | `LENS_API_KEY_FILE` | No | Path to the knowledge server API key file. Default: `$XDG_DATA_HOME/getbased/lens/api_key` (getbased-rag's canonical location). If that file doesn't exist but the legacy `~/.hermes/rag/lens_api_key` does, the legacy path is used instead; upgrades from standalone `getbased-mcp` ≤ 0.1.0 keep working without config changes. |
191
201
  | `LENS_MCP_ACTIVITY_LOG` | No | JSONL path where tool-call activity is appended. Default: `$XDG_STATE_HOME/getbased/mcp/activity.jsonl`. Each record: `{ts, tool, duration_ms, ok, error?}` — arguments are never logged (queries may contain sensitive health info). Set to `off` / `false` / `0` to disable. The [getbased-dashboard](https://github.com/elkimek/getbased-agents/tree/main/packages/dashboard) Activity tab tails this file. |
192
202
 
193
203
  ## Custom Knowledge Source (getbased app)
194
204
 
195
- The same RAG server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
205
+ The same local knowledge server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
196
206
 
197
207
  1. Run `getbased_lens_config` — it returns the endpoint URL, API key, and recommended `top_k`
198
- 2. In getbased, go to **Settings → AI → Custom Knowledge Source**
208
+ 2. In getbased, open **Knowledge Base** and choose **External server**
199
209
  3. Paste the endpoint URL, API key, and set `top_k` to 5
200
210
  4. Enable it — the chat-header Lens badge will light up green when active
201
211
 
202
- Every chat question and focus card will now be enriched with RAG-retrieved passages from your knowledge base.
212
+ Every chat question and Current Focus refresh can now include passages from your knowledge base.
203
213
 
204
214
  ## Troubleshooting
205
215
 
206
216
  ### `knowledge_search` returns "Lens server not reachable"
207
217
 
208
- The RAG server isn't running. Start it and verify with:
218
+ The local knowledge server is not running. Start it and verify with:
209
219
 
210
220
  ```bash
211
221
  curl http://localhost:8322/health
@@ -213,7 +223,7 @@ curl http://localhost:8322/health
213
223
 
214
224
  ### `knowledge_search` returns "Lens API key not found"
215
225
 
216
- getbased-rag generates its API key on first start and writes it to `$XDG_DATA_HOME/getbased/lens/api_key` (e.g. `~/.local/share/getbased/lens/api_key` on Linux). If you're upgrading from the standalone `getbased-mcp` ≤ 0.1.0 and your key is at `~/.hermes/rag/lens_api_key`, that legacy path is still auto-detected — no config change needed. If the file is missing entirely, restart the RAG server and it will create a new one.
226
+ getbased-rag generates its API key on first start and writes it to `$XDG_DATA_HOME/getbased/lens/api_key` (e.g. `~/.local/share/getbased/lens/api_key` on Linux). If you're upgrading from the standalone `getbased-mcp` ≤ 0.1.0 and your key is at `~/.hermes/rag/lens_api_key`, that legacy path is still auto-detected; no config change needed. If the file is missing entirely, restart the knowledge server and it will create a new one.
217
227
 
218
228
  ### `knowledge_list_libraries` / `knowledge_stats` return "this lens server doesn't expose library management"
219
229
 
@@ -221,7 +231,7 @@ The lens server you're pointed at is older than `getbased-rag` 0.1.0 and doesn't
221
231
 
222
232
  ### Blood work tools work but knowledge_search doesn't
223
233
 
224
- That's expected — they're independent. Blood work tools talk to the sync gateway; knowledge_search talks to the RAG server. The MCP degrades gracefully: if the RAG server is down, all blood work tools continue to work normally.
234
+ That's expected. Blood work tools talk to the context gateway; `knowledge_search` talks to the local knowledge server. If the knowledge server is down, knowledge search will fail, but the lab-context tools continue to work normally.
225
235
 
226
236
  ## Security
227
237
 
@@ -233,7 +243,7 @@ That's expected — they're independent. Blood work tools talk to the sync gatew
233
243
 
234
244
  ## Related projects
235
245
 
236
- - **[getbased](https://github.com/elkimek/get-based)** — the health dashboard. This MCP reads the same lab context the in-app AI chat uses, and queries the same Knowledge Source endpoint configured in Settings → AI → Custom Knowledge Source. The [endpoint contract](https://github.com/elkimek/get-based/blob/main/dev-docs/lens-endpoint-contract.md) is shared — one server backs both the app and this MCP.
246
+ - **[getbased](https://github.com/elkimek/get-based)** — the health dashboard. This MCP reads the same context the in-app AI chat uses, and can query the same external Knowledge Base server configured in the app. The endpoint contract is shared: one server can back both the app and this MCP.
237
247
 
238
248
  ## License
239
249
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: getbased-mcp
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: MCP server for querying blood work data and knowledge base from getbased
5
5
  License-Expression: AGPL-3.0-or-later
6
6
  Requires-Python: >=3.10
@@ -8,7 +8,7 @@ Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
9
9
  Requires-Dist: mcp>=1.0.0
10
10
  Requires-Dist: httpx>=0.27
11
- Requires-Dist: cryptography>=42.0
11
+ Requires-Dist: cryptography>=48.0.1
12
12
  Provides-Extra: test
13
13
  Requires-Dist: pytest>=8.0; extra == "test"
14
14
  Requires-Dist: pytest-asyncio>=0.23; extra == "test"
@@ -17,9 +17,9 @@ Dynamic: license-file
17
17
 
18
18
  # getbased MCP Server
19
19
 
20
- An [MCP](https://modelcontextprotocol.io) server that exposes blood work data and an optional RAG knowledge base from [getbased](https://getbased.health) as tools. Works with any MCP-compatible client (Claude Code, Hermes, Claude Desktop, etc.).
20
+ An [MCP](https://modelcontextprotocol.io) server that exposes getbased health context and an optional local knowledge base as tools. Works with MCP-compatible clients such as Claude Code, Claude Desktop, Cursor, Cline, Codex CLI, Hermes, and OpenClaw.
21
21
 
22
- > **Installing for the first time?** The [getbased-agent-stack](https://github.com/elkimek/getbased-agents/tree/main/packages/stack) meta-package bundles this MCP with the RAG engine it talks to, plus example configs for Claude Code and Hermes. One command and you're up.
22
+ > **Installing for the first time?** Use the private setup command from **getbased → Settings → Agent Access**. It installs or updates [getbased-agent-stack](https://github.com/elkimek/getbased-agents/tree/main/packages/stack), stores the token/key locally, and configures the selected client.
23
23
 
24
24
  ## How it works
25
25
 
@@ -31,21 +31,21 @@ getbased (browser)
31
31
  ├── encrypts the rendered agent context with that context key
32
32
  └── pushes ciphertext to sync gateway on every save
33
33
 
34
- Sync Gateway (sync.getbased.health/api/context)
34
+ Context gateway (sync.getbased.health/api/context)
35
35
  └── stores encrypted context behind token auth; it cannot read the plaintext
36
36
 
37
- RAG Server (localhost, optional)
37
+ Local knowledge server (localhost, optional)
38
38
  ├── Vector database with embedded chunks
39
39
  ├── Embedding model for semantic search
40
40
  └── Your curated health knowledge base
41
41
 
42
42
  This MCP Server (on your machine)
43
- ├── fetches blood work context from sync gateway
44
- ├── queries RAG server for knowledge base searches (optional)
43
+ ├── fetches health context from the context gateway
44
+ ├── queries the local knowledge server for knowledge-base searches (optional)
45
45
  └── exposes everything as tools to any MCP client
46
46
  ```
47
47
 
48
- Your mnemonic never leaves your browser. The sync gateway receives only an end-to-end encrypted agent-context envelope; this MCP decrypts it locally with `GETBASED_AGENT_CONTEXT_KEY` and then exposes the same lab context text the getbased AI chat uses — not raw data. `GETBASED_TOKEN` is only the relay bearer token.
48
+ Your mnemonic never leaves your browser. The gateway receives only an encrypted agent-context envelope; this MCP decrypts it locally with `GETBASED_AGENT_CONTEXT_KEY` and exposes the same summary text the getbased AI chat uses. `GETBASED_TOKEN` is only the relay bearer token.
49
49
 
50
50
  ## Tools
51
51
 
@@ -54,7 +54,7 @@ Your mnemonic never leaves your browser. The sync gateway receives only an end-t
54
54
  | `getbased_lab_context` | Full lab summary with biomarkers, context cards, supplements, goals. Pass `profile` to target a specific profile. |
55
55
  | `getbased_section` | Get a specific section (e.g. hormones, lipids) or list all available sections |
56
56
  | `getbased_list_profiles` | List available profiles |
57
- | `knowledge_search` | Semantic search across the active library on your knowledge base (requires RAG server). Returns relevant passages with source attribution. |
57
+ | `knowledge_search` | Semantic search across the active library on your knowledge base (requires the local knowledge server). Returns relevant passages with source attribution. |
58
58
  | `knowledge_list_libraries` | List all knowledge base libraries and show which is active |
59
59
  | `knowledge_activate_library` | Switch the active library — subsequent searches target the new one until switched again |
60
60
  | `knowledge_stats` | Per-source chunk counts for the active library — useful for diagnosing missing results |
@@ -91,7 +91,7 @@ knowledge_search(query="blue light DHA mitochondrial damage")
91
91
  knowledge_search(query="MTHFR methylation folate", n_results=5)
92
92
  ```
93
93
 
94
- **Note:** This tool requires the RAG server to be running. Without it, all blood work tools still work — the MCP degrades gracefully.
94
+ **Note:** This tool requires the local knowledge server to be running. If it is not running, knowledge search will fail, but the lab-context tools still work.
95
95
 
96
96
  ### Multi-library (v0.2+)
97
97
 
@@ -119,24 +119,34 @@ The gateway stores context per profile ID. To work with multiple profiles:
119
119
 
120
120
  ## Setup
121
121
 
122
- ### 1. Enable Agent Access in getbased
122
+ ### Recommended: copy the private setup command
123
123
 
124
- Go to **Settings > Data > Agent Access** and toggle it on. Copy both values:
124
+ In getbased, open **Settings → Agent Access**, choose your target client, and copy the setup command. It looks like this:
125
+
126
+ ```bash
127
+ curl -fsSL https://getbased.health/install.sh | bash -s -- connect <target> --setup 'gbsetup_v1_...'
128
+ ```
129
+
130
+ The setup payload is private. Paste it only into a terminal you control.
131
+
132
+ ### Manual setup
133
+
134
+ If you are not using `getbased-stack connect`, open **Settings → Agent Access** and copy both values:
125
135
 
126
136
  - **Read-only token** → `GETBASED_TOKEN` for relay authorization
127
137
  - **Context encryption key** → `GETBASED_AGENT_CONTEXT_KEY` for local decryption
128
138
 
129
- ### 2. Set up a RAG server (optional — for knowledge_search)
139
+ ### Set up a local knowledge server (optional, for `knowledge_search`)
130
140
 
131
- The knowledge base runs as a separate service. You need:
141
+ The knowledge base runs as a separate service. The easiest path is `getbased-agent-stack[full]`, which installs `getbased-rag` and the browser dashboard. If you are wiring your own server, you need:
132
142
 
133
143
  - A vector database (e.g. [Qdrant](https://qdrant.tech/), [ChromaDB](https://www.trychroma.com/)) loaded with your document chunks and embeddings
134
144
  - A FastAPI (or similar) server that accepts `POST /query` with `{version: 1, query: "...", top_k: N}` and returns `{chunks: [{text: "...", source: "..."}]}`
135
145
  - An embedding model (e.g. [BGE-M3](https://huggingface.co/BAAI/bge-m3)) for semantic search
136
146
 
137
- The RAG server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it — no models loaded here.
147
+ The local knowledge server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it; no models are loaded inside the MCP process.
138
148
 
139
- **RAG server contract:**
149
+ **Knowledge server contract:**
140
150
 
141
151
  | Field | Required | Description |
142
152
  |---|---|---|
@@ -145,7 +155,7 @@ The RAG server handles embedding, similarity search, and filtering. This MCP jus
145
155
  | `GET /health` | Optional | Returns `{"status": "ok", "rag_ready": bool, "chunks": int}` |
146
156
  | Response | Yes | `{"chunks": [{"text": "...", "source": "..."}]}` |
147
157
 
148
- ### 3. Configure your MCP client
158
+ ### Configure your MCP client manually
149
159
 
150
160
  #### Claude Code / Claude Desktop
151
161
 
@@ -174,7 +184,7 @@ hermes mcp add getbased \
174
184
  --args /path/to/getbased_mcp.py
175
185
  ```
176
186
 
177
- Then set `GETBASED_TOKEN` and `GETBASED_AGENT_CONTEXT_KEY` in `~/.hermes/.env` or in the MCP server's `env` config in `config.yaml`:
187
+ Then set `GETBASED_TOKEN` and `GETBASED_AGENT_CONTEXT_KEY` in the MCP server's `env` config in `config.yaml`:
178
188
 
179
189
  ```yaml
180
190
  mcp_servers:
@@ -199,30 +209,30 @@ Ask about your labs in any connected conversation:
199
209
 
200
210
  | Variable | Required | Description |
201
211
  |---|---|---|
202
- | `GETBASED_TOKEN` | Yes | Read-only bearer token from getbased Settings > Data > Agent Access; authorizes fetches from the context gateway |
203
- | `GETBASED_AGENT_CONTEXT_KEY` | Yes for encrypted Agent Access payloads | Context encryption key from getbased Settings > Data > Agent Access; decrypts the relay payload locally in this MCP |
212
+ | `GETBASED_TOKEN` | Yes | Read-only bearer token from getbased Settings → Agent Access; authorizes fetches from the context gateway |
213
+ | `GETBASED_AGENT_CONTEXT_KEY` | Yes for encrypted Agent Access payloads | Context encryption key from getbased Settings → Agent Access; decrypts the relay payload locally in this MCP |
204
214
  | `GETBASED_GATEWAY` | No | Context gateway URL (default: `https://sync.getbased.health`) |
205
- | `LENS_URL` | No | RAG server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
206
- | `LENS_PORT` | No | RAG server port, only used to build default `LENS_URL` (default: `8322`) |
207
- | `LENS_API_KEY_FILE` | No | Path to RAG API key file. Default: `$XDG_DATA_HOME/getbased/lens/api_key` (getbased-rag's canonical location). If that file doesn't exist but the legacy `~/.hermes/rag/lens_api_key` does, the legacy path is used instead — upgrades from standalone `getbased-mcp` ≤ 0.1.0 keep working without config changes. |
215
+ | `LENS_URL` | No | Local knowledge server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
216
+ | `LENS_PORT` | No | Local knowledge server port, only used to build default `LENS_URL` (default: `8322`) |
217
+ | `LENS_API_KEY_FILE` | No | Path to the knowledge server API key file. Default: `$XDG_DATA_HOME/getbased/lens/api_key` (getbased-rag's canonical location). If that file doesn't exist but the legacy `~/.hermes/rag/lens_api_key` does, the legacy path is used instead; upgrades from standalone `getbased-mcp` ≤ 0.1.0 keep working without config changes. |
208
218
  | `LENS_MCP_ACTIVITY_LOG` | No | JSONL path where tool-call activity is appended. Default: `$XDG_STATE_HOME/getbased/mcp/activity.jsonl`. Each record: `{ts, tool, duration_ms, ok, error?}` — arguments are never logged (queries may contain sensitive health info). Set to `off` / `false` / `0` to disable. The [getbased-dashboard](https://github.com/elkimek/getbased-agents/tree/main/packages/dashboard) Activity tab tails this file. |
209
219
 
210
220
  ## Custom Knowledge Source (getbased app)
211
221
 
212
- The same RAG server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
222
+ The same local knowledge server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
213
223
 
214
224
  1. Run `getbased_lens_config` — it returns the endpoint URL, API key, and recommended `top_k`
215
- 2. In getbased, go to **Settings → AI → Custom Knowledge Source**
225
+ 2. In getbased, open **Knowledge Base** and choose **External server**
216
226
  3. Paste the endpoint URL, API key, and set `top_k` to 5
217
227
  4. Enable it — the chat-header Lens badge will light up green when active
218
228
 
219
- Every chat question and focus card will now be enriched with RAG-retrieved passages from your knowledge base.
229
+ Every chat question and Current Focus refresh can now include passages from your knowledge base.
220
230
 
221
231
  ## Troubleshooting
222
232
 
223
233
  ### `knowledge_search` returns "Lens server not reachable"
224
234
 
225
- The RAG server isn't running. Start it and verify with:
235
+ The local knowledge server is not running. Start it and verify with:
226
236
 
227
237
  ```bash
228
238
  curl http://localhost:8322/health
@@ -230,7 +240,7 @@ curl http://localhost:8322/health
230
240
 
231
241
  ### `knowledge_search` returns "Lens API key not found"
232
242
 
233
- getbased-rag generates its API key on first start and writes it to `$XDG_DATA_HOME/getbased/lens/api_key` (e.g. `~/.local/share/getbased/lens/api_key` on Linux). If you're upgrading from the standalone `getbased-mcp` ≤ 0.1.0 and your key is at `~/.hermes/rag/lens_api_key`, that legacy path is still auto-detected — no config change needed. If the file is missing entirely, restart the RAG server and it will create a new one.
243
+ getbased-rag generates its API key on first start and writes it to `$XDG_DATA_HOME/getbased/lens/api_key` (e.g. `~/.local/share/getbased/lens/api_key` on Linux). If you're upgrading from the standalone `getbased-mcp` ≤ 0.1.0 and your key is at `~/.hermes/rag/lens_api_key`, that legacy path is still auto-detected; no config change needed. If the file is missing entirely, restart the knowledge server and it will create a new one.
234
244
 
235
245
  ### `knowledge_list_libraries` / `knowledge_stats` return "this lens server doesn't expose library management"
236
246
 
@@ -238,7 +248,7 @@ The lens server you're pointed at is older than `getbased-rag` 0.1.0 and doesn't
238
248
 
239
249
  ### Blood work tools work but knowledge_search doesn't
240
250
 
241
- That's expected — they're independent. Blood work tools talk to the sync gateway; knowledge_search talks to the RAG server. The MCP degrades gracefully: if the RAG server is down, all blood work tools continue to work normally.
251
+ That's expected. Blood work tools talk to the context gateway; `knowledge_search` talks to the local knowledge server. If the knowledge server is down, knowledge search will fail, but the lab-context tools continue to work normally.
242
252
 
243
253
  ## Security
244
254
 
@@ -250,7 +260,7 @@ That's expected — they're independent. Blood work tools talk to the sync gatew
250
260
 
251
261
  ## Related projects
252
262
 
253
- - **[getbased](https://github.com/elkimek/get-based)** — the health dashboard. This MCP reads the same lab context the in-app AI chat uses, and queries the same Knowledge Source endpoint configured in Settings → AI → Custom Knowledge Source. The [endpoint contract](https://github.com/elkimek/get-based/blob/main/dev-docs/lens-endpoint-contract.md) is shared — one server backs both the app and this MCP.
263
+ - **[getbased](https://github.com/elkimek/get-based)** — the health dashboard. This MCP reads the same context the in-app AI chat uses, and can query the same external Knowledge Base server configured in the app. The endpoint contract is shared: one server can back both the app and this MCP.
254
264
 
255
265
  ## License
256
266
 
@@ -1,6 +1,6 @@
1
1
  mcp>=1.0.0
2
2
  httpx>=0.27
3
- cryptography>=42.0
3
+ cryptography>=48.0.1
4
4
 
5
5
  [test]
6
6
  pytest>=8.0
@@ -419,8 +419,8 @@ async def _lens_call(method: str, path: str, json_body: dict | None = None) -> d
419
419
  body = e.response.json()
420
420
  if body.get("detail") == "Not Found":
421
421
  return {"error": "unsupported_endpoint"}
422
- except (json.JSONDecodeError, ValueError):
423
- pass
422
+ except (json.JSONDecodeError, ValueError) as parse_error:
423
+ log.debug("Unable to parse Lens 404 response body: %s", parse_error)
424
424
  # Same rationale as _lens_request: truncate the body preview so
425
425
  # internal details don't end up in a cloud AI client's context.
426
426
  preview = (e.response.text or "")[:_UPSTREAM_ERROR_PREVIEW]
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "getbased-mcp"
7
- version = "0.2.6"
7
+ version = "0.2.7"
8
8
  description = "MCP server for querying blood work data and knowledge base from getbased"
9
9
  readme = "README.md"
10
10
  license = "AGPL-3.0-or-later"
@@ -12,7 +12,7 @@ requires-python = ">=3.10"
12
12
  dependencies = [
13
13
  "mcp>=1.0.0",
14
14
  "httpx>=0.27",
15
- "cryptography>=42.0",
15
+ "cryptography>=48.0.1",
16
16
  ]
17
17
 
18
18
  [project.optional-dependencies]
@@ -268,7 +268,6 @@ async def test_knowledge_search_happy(gm) -> None:
268
268
  assert route.called
269
269
  req = route.calls[0].request
270
270
  assert req.headers["Authorization"] == "Bearer test-lens-key"
271
- import json
272
271
  body = json.loads(req.content)
273
272
  assert body == {"version": 1, "query": "vitamin D", "top_k": 2}
274
273
  # Response rendered
@@ -283,7 +282,6 @@ async def test_knowledge_search_clamps_n_results(gm) -> None:
283
282
  route = respx.post(f"{LENS_URL_PREFIX}/query").mock(return_value=Response(200, json={"chunks": []}))
284
283
  # n_results=99 → clamped to 10
285
284
  await gm.knowledge_search(query="x", n_results=99)
286
- import json
287
285
  body = json.loads(route.calls[0].request.content)
288
286
  assert body["top_k"] == 10
289
287
  # n_results=0 → clamped to 1
File without changes
File without changes