getbased-mcp 0.2.2__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.
- getbased_mcp-0.2.2/LICENSE +22 -0
- getbased_mcp-0.2.2/PKG-INFO +248 -0
- getbased_mcp-0.2.2/README.md +232 -0
- getbased_mcp-0.2.2/getbased_mcp.egg-info/PKG-INFO +248 -0
- getbased_mcp-0.2.2/getbased_mcp.egg-info/SOURCES.txt +11 -0
- getbased_mcp-0.2.2/getbased_mcp.egg-info/dependency_links.txt +1 -0
- getbased_mcp-0.2.2/getbased_mcp.egg-info/entry_points.txt +2 -0
- getbased_mcp-0.2.2/getbased_mcp.egg-info/requires.txt +7 -0
- getbased_mcp-0.2.2/getbased_mcp.egg-info/top_level.txt +1 -0
- getbased_mcp-0.2.2/getbased_mcp.py +488 -0
- getbased_mcp-0.2.2/pyproject.toml +30 -0
- getbased_mcp-0.2.2/setup.cfg +4 -0
- getbased_mcp-0.2.2/tests/test_tools.py +464 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
Preamble
|
|
9
|
+
|
|
10
|
+
The GNU General Public License is a free, copyleft license for
|
|
11
|
+
software and other kinds of works.
|
|
12
|
+
|
|
13
|
+
The licenses for most software and other practical works are designed
|
|
14
|
+
to take away your freedom to share and change the works. By contrast,
|
|
15
|
+
the GNU General Public License is intended to guarantee your freedom to
|
|
16
|
+
share and change all versions of a program--to make sure it remains free
|
|
17
|
+
software for all its users. We, the Free Software Foundation, use the
|
|
18
|
+
GNU General Public License for most of our software; it applies also to
|
|
19
|
+
any other work released this way by its authors. You can apply it to
|
|
20
|
+
your programs, too.
|
|
21
|
+
|
|
22
|
+
For the full license text, see <https://www.gnu.org/licenses/gpl-3.0.txt>
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: getbased-mcp
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: MCP server for querying blood work data and knowledge base from getbased
|
|
5
|
+
License-Expression: GPL-3.0-only
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: mcp>=1.0.0
|
|
10
|
+
Requires-Dist: httpx>=0.27
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
13
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "test"
|
|
14
|
+
Requires-Dist: respx>=0.21; extra == "test"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# getbased MCP Server
|
|
18
|
+
|
|
19
|
+
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
|
+
|
|
21
|
+
> **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
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
getbased (browser)
|
|
27
|
+
├── your data, your mnemonic
|
|
28
|
+
├── generates a read-only token
|
|
29
|
+
└── pushes lab context to sync gateway on every save
|
|
30
|
+
|
|
31
|
+
Sync Gateway (sync.getbased.health/api/context)
|
|
32
|
+
└── stores context text behind token auth
|
|
33
|
+
|
|
34
|
+
RAG Server (localhost, optional)
|
|
35
|
+
├── Vector database with embedded chunks
|
|
36
|
+
├── Embedding model for semantic search
|
|
37
|
+
└── Your curated health knowledge base
|
|
38
|
+
|
|
39
|
+
This MCP Server (on your machine)
|
|
40
|
+
├── fetches blood work context from sync gateway
|
|
41
|
+
├── queries RAG server for knowledge base searches (optional)
|
|
42
|
+
└── exposes everything as tools to any MCP client
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Your mnemonic never leaves your browser. The MCP server receives the same lab context text the getbased AI chat uses — not raw data.
|
|
46
|
+
|
|
47
|
+
## Tools
|
|
48
|
+
|
|
49
|
+
| Tool | Description |
|
|
50
|
+
|---|---|
|
|
51
|
+
| `getbased_lab_context` | Full lab summary with biomarkers, context cards, supplements, goals. Pass `profile` to target a specific profile. |
|
|
52
|
+
| `getbased_section` | Get a specific section (e.g. hormones, lipids) or list all available sections |
|
|
53
|
+
| `getbased_list_profiles` | List available profiles |
|
|
54
|
+
| `knowledge_search` | Semantic search across the active library on your knowledge base (requires RAG server). Returns relevant passages with source attribution. |
|
|
55
|
+
| `knowledge_list_libraries` | List all knowledge base libraries and show which is active |
|
|
56
|
+
| `knowledge_activate_library` | Switch the active library — subsequent searches target the new one until switched again |
|
|
57
|
+
| `knowledge_stats` | Per-source chunk counts for the active library — useful for diagnosing missing results |
|
|
58
|
+
| `getbased_lens_config` | Show RAG endpoint config for getbased's Knowledge Base (External server) |
|
|
59
|
+
|
|
60
|
+
### getbased_section
|
|
61
|
+
|
|
62
|
+
Query-aware context: pull just the section you need instead of the full dump. Saves tokens and allows deeper analysis of specific areas.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
# No args — returns section index with names, updated dates, and line counts
|
|
66
|
+
getbased_section()
|
|
67
|
+
|
|
68
|
+
# With section name — returns just that section's content
|
|
69
|
+
getbased_section(section="hormones")
|
|
70
|
+
|
|
71
|
+
# With profile — query a specific profile
|
|
72
|
+
getbased_section(section="hormones", profile="mne8m9hf")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Section names are matched by prefix, so `hormones` matches `hormones updated:2026-03-13`.
|
|
76
|
+
|
|
77
|
+
### knowledge_search
|
|
78
|
+
|
|
79
|
+
**What is RAG?** Retrieval-Augmented Generation (RAG) is a technique where an AI assistant's responses are grounded in a specific knowledge base. Instead of relying solely on training data, the assistant first searches a curated collection of documents for relevant passages, then uses those passages to inform its answer. This makes the AI's output more accurate, more specific, and traceable to real sources.
|
|
80
|
+
|
|
81
|
+
The `knowledge_search` tool searches your knowledge base using semantic similarity — meaning it finds passages that match the *meaning* of your query, not just keywords. Results include the passage text and source attribution.
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
# Basic search
|
|
85
|
+
knowledge_search(query="blue light DHA mitochondrial damage")
|
|
86
|
+
|
|
87
|
+
# With result count (1–10, default 5)
|
|
88
|
+
knowledge_search(query="MTHFR methylation folate", n_results=5)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Note:** This tool requires the RAG server to be running. Without it, all blood work tools still work — the MCP degrades gracefully.
|
|
92
|
+
|
|
93
|
+
### Multi-library (v0.2+)
|
|
94
|
+
|
|
95
|
+
The Lens server (0.2+ of `getbased-rag`) supports multiple libraries — keep research papers, clinical guides, and personal notes in separate collections and switch between them. `knowledge_search` always targets the currently active library.
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
# See what's available and which is active
|
|
99
|
+
knowledge_list_libraries()
|
|
100
|
+
|
|
101
|
+
# Switch. Subsequent knowledge_search calls hit this library until switched again
|
|
102
|
+
knowledge_activate_library(library_id="<id-from-list>")
|
|
103
|
+
|
|
104
|
+
# Confirm what's indexed in the active library
|
|
105
|
+
knowledge_stats()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Multi-profile
|
|
109
|
+
|
|
110
|
+
The gateway stores context per profile ID. To work with multiple profiles:
|
|
111
|
+
|
|
112
|
+
- Use `getbased_list_profiles` to see available profiles and their IDs
|
|
113
|
+
- Pass `profile="id"` to any tool to query a specific profile
|
|
114
|
+
- Omit the `profile` param to use the default profile
|
|
115
|
+
- Each profile's context is pushed automatically when data is saved or the profile is switched in getbased
|
|
116
|
+
|
|
117
|
+
## Setup
|
|
118
|
+
|
|
119
|
+
### 1. Enable messenger access in getbased
|
|
120
|
+
|
|
121
|
+
Go to **Settings > Data > Messenger Access** and toggle it on. Copy the read-only token.
|
|
122
|
+
|
|
123
|
+
### 2. Set up a RAG server (optional — for knowledge_search)
|
|
124
|
+
|
|
125
|
+
The knowledge base runs as a separate service. You need:
|
|
126
|
+
|
|
127
|
+
- A vector database (e.g. [Qdrant](https://qdrant.tech/), [ChromaDB](https://www.trychroma.com/)) loaded with your document chunks and embeddings
|
|
128
|
+
- A FastAPI (or similar) server that accepts `POST /query` with `{version: 1, query: "...", top_k: N}` and returns `{chunks: [{text: "...", source: "..."}]}`
|
|
129
|
+
- An embedding model (e.g. [BGE-M3](https://huggingface.co/BAAI/bge-m3)) for semantic search
|
|
130
|
+
|
|
131
|
+
The RAG server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it — no models loaded here.
|
|
132
|
+
|
|
133
|
+
**RAG server contract:**
|
|
134
|
+
|
|
135
|
+
| Field | Required | Description |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `POST /query` | Yes | Accepts JSON body with `version` (int), `query` (string), `top_k` (int) |
|
|
138
|
+
| `Authorization` | Recommended | Bearer token auth |
|
|
139
|
+
| `GET /health` | Optional | Returns `{"status": "ok", "rag_ready": bool, "chunks": int}` |
|
|
140
|
+
| Response | Yes | `{"chunks": [{"text": "...", "source": "..."}]}` |
|
|
141
|
+
|
|
142
|
+
### 3. Configure your MCP client
|
|
143
|
+
|
|
144
|
+
#### Claude Code / Claude Desktop
|
|
145
|
+
|
|
146
|
+
Add to your MCP config (`~/.claude/claude_desktop_config.json` or similar):
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"mcpServers": {
|
|
151
|
+
"getbased": {
|
|
152
|
+
"command": "python3",
|
|
153
|
+
"args": ["/path/to/getbased_mcp.py"],
|
|
154
|
+
"env": {
|
|
155
|
+
"GETBASED_TOKEN": "your-token-here"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Hermes Agent
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
hermes mcp add getbased \
|
|
166
|
+
--command python3 \
|
|
167
|
+
--args /path/to/getbased_mcp.py
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Then set `GETBASED_TOKEN` in `~/.hermes/.env` or in the MCP server's `env` config in `config.yaml`:
|
|
171
|
+
|
|
172
|
+
```yaml
|
|
173
|
+
mcp_servers:
|
|
174
|
+
getbased:
|
|
175
|
+
command: python3
|
|
176
|
+
args: [/path/to/getbased_mcp.py]
|
|
177
|
+
env:
|
|
178
|
+
GETBASED_TOKEN: your-token-here
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 4. Use it
|
|
182
|
+
|
|
183
|
+
Ask about your labs in any connected conversation:
|
|
184
|
+
|
|
185
|
+
> "How's my vitamin D?"
|
|
186
|
+
> "What markers are out of range?"
|
|
187
|
+
> "Summarize my latest blood work"
|
|
188
|
+
> "What does the knowledge base say about blue light and DHA?"
|
|
189
|
+
|
|
190
|
+
## Environment variables
|
|
191
|
+
|
|
192
|
+
| Variable | Required | Description |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| `GETBASED_TOKEN` | Yes | Read-only token from getbased Settings > Data > Messenger Access |
|
|
195
|
+
| `GETBASED_GATEWAY` | No | Context gateway URL (default: `https://sync.getbased.health`) |
|
|
196
|
+
| `LENS_URL` | No | RAG server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
|
|
197
|
+
| `LENS_PORT` | No | RAG server port, only used to build default `LENS_URL` (default: `8322`) |
|
|
198
|
+
| `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. |
|
|
199
|
+
| `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. |
|
|
200
|
+
|
|
201
|
+
## Custom Knowledge Source (getbased app)
|
|
202
|
+
|
|
203
|
+
The same RAG server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
|
|
204
|
+
|
|
205
|
+
1. Run `getbased_lens_config` — it returns the endpoint URL, API key, and recommended `top_k`
|
|
206
|
+
2. In getbased, go to **Settings → AI → Custom Knowledge Source**
|
|
207
|
+
3. Paste the endpoint URL, API key, and set `top_k` to 5
|
|
208
|
+
4. Enable it — the chat-header Lens badge will light up green when active
|
|
209
|
+
|
|
210
|
+
Every chat question and focus card will now be enriched with RAG-retrieved passages from your knowledge base.
|
|
211
|
+
|
|
212
|
+
## Troubleshooting
|
|
213
|
+
|
|
214
|
+
### `knowledge_search` returns "Lens server not reachable"
|
|
215
|
+
|
|
216
|
+
The RAG server isn't running. Start it and verify with:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
curl http://localhost:8322/health
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### `knowledge_search` returns "Lens API key not found"
|
|
223
|
+
|
|
224
|
+
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.
|
|
225
|
+
|
|
226
|
+
### `knowledge_list_libraries` / `knowledge_stats` return "this lens server doesn't expose library management"
|
|
227
|
+
|
|
228
|
+
The lens server you're pointed at is older than `getbased-rag` 0.1.0 and doesn't implement the `/libraries` or `/stats` endpoints. `knowledge_search` still works against older lens servers since `/query` is protocol-stable. To get library management, either upgrade the lens, or set `LENS_URL` to a library-capable endpoint.
|
|
229
|
+
|
|
230
|
+
### Blood work tools work but knowledge_search doesn't
|
|
231
|
+
|
|
232
|
+
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.
|
|
233
|
+
|
|
234
|
+
## Security
|
|
235
|
+
|
|
236
|
+
- **Read-only**: the token grants access to lab context text only — no raw data, no write access
|
|
237
|
+
- **Self-hosted**: the MCP server runs on your own machine
|
|
238
|
+
- **Revocable**: regenerate the token in getbased to revoke access instantly
|
|
239
|
+
- **No mnemonic exposure**: the token is independent of your sync mnemonic
|
|
240
|
+
- **No models in-process**: RAG queries go through the external server — no embedding models loaded in the MCP process
|
|
241
|
+
|
|
242
|
+
## Related projects
|
|
243
|
+
|
|
244
|
+
- **[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/docs/guide/interpretive-lens.md#for-developers-endpoint-contract) is shared — one server backs both the app and this MCP.
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
GPL-3.0
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# getbased MCP Server
|
|
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.).
|
|
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.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
getbased (browser)
|
|
11
|
+
├── your data, your mnemonic
|
|
12
|
+
├── generates a read-only token
|
|
13
|
+
└── pushes lab context to sync gateway on every save
|
|
14
|
+
|
|
15
|
+
Sync Gateway (sync.getbased.health/api/context)
|
|
16
|
+
└── stores context text behind token auth
|
|
17
|
+
|
|
18
|
+
RAG Server (localhost, optional)
|
|
19
|
+
├── Vector database with embedded chunks
|
|
20
|
+
├── Embedding model for semantic search
|
|
21
|
+
└── Your curated health knowledge base
|
|
22
|
+
|
|
23
|
+
This MCP Server (on your machine)
|
|
24
|
+
├── fetches blood work context from sync gateway
|
|
25
|
+
├── queries RAG server for knowledge base searches (optional)
|
|
26
|
+
└── exposes everything as tools to any MCP client
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Your mnemonic never leaves your browser. The MCP server receives the same lab context text the getbased AI chat uses — not raw data.
|
|
30
|
+
|
|
31
|
+
## Tools
|
|
32
|
+
|
|
33
|
+
| Tool | Description |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `getbased_lab_context` | Full lab summary with biomarkers, context cards, supplements, goals. Pass `profile` to target a specific profile. |
|
|
36
|
+
| `getbased_section` | Get a specific section (e.g. hormones, lipids) or list all available sections |
|
|
37
|
+
| `getbased_list_profiles` | List available profiles |
|
|
38
|
+
| `knowledge_search` | Semantic search across the active library on your knowledge base (requires RAG server). Returns relevant passages with source attribution. |
|
|
39
|
+
| `knowledge_list_libraries` | List all knowledge base libraries and show which is active |
|
|
40
|
+
| `knowledge_activate_library` | Switch the active library — subsequent searches target the new one until switched again |
|
|
41
|
+
| `knowledge_stats` | Per-source chunk counts for the active library — useful for diagnosing missing results |
|
|
42
|
+
| `getbased_lens_config` | Show RAG endpoint config for getbased's Knowledge Base (External server) |
|
|
43
|
+
|
|
44
|
+
### getbased_section
|
|
45
|
+
|
|
46
|
+
Query-aware context: pull just the section you need instead of the full dump. Saves tokens and allows deeper analysis of specific areas.
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
# No args — returns section index with names, updated dates, and line counts
|
|
50
|
+
getbased_section()
|
|
51
|
+
|
|
52
|
+
# With section name — returns just that section's content
|
|
53
|
+
getbased_section(section="hormones")
|
|
54
|
+
|
|
55
|
+
# With profile — query a specific profile
|
|
56
|
+
getbased_section(section="hormones", profile="mne8m9hf")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Section names are matched by prefix, so `hormones` matches `hormones updated:2026-03-13`.
|
|
60
|
+
|
|
61
|
+
### knowledge_search
|
|
62
|
+
|
|
63
|
+
**What is RAG?** Retrieval-Augmented Generation (RAG) is a technique where an AI assistant's responses are grounded in a specific knowledge base. Instead of relying solely on training data, the assistant first searches a curated collection of documents for relevant passages, then uses those passages to inform its answer. This makes the AI's output more accurate, more specific, and traceable to real sources.
|
|
64
|
+
|
|
65
|
+
The `knowledge_search` tool searches your knowledge base using semantic similarity — meaning it finds passages that match the *meaning* of your query, not just keywords. Results include the passage text and source attribution.
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
# Basic search
|
|
69
|
+
knowledge_search(query="blue light DHA mitochondrial damage")
|
|
70
|
+
|
|
71
|
+
# With result count (1–10, default 5)
|
|
72
|
+
knowledge_search(query="MTHFR methylation folate", n_results=5)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Note:** This tool requires the RAG server to be running. Without it, all blood work tools still work — the MCP degrades gracefully.
|
|
76
|
+
|
|
77
|
+
### Multi-library (v0.2+)
|
|
78
|
+
|
|
79
|
+
The Lens server (0.2+ of `getbased-rag`) supports multiple libraries — keep research papers, clinical guides, and personal notes in separate collections and switch between them. `knowledge_search` always targets the currently active library.
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
# See what's available and which is active
|
|
83
|
+
knowledge_list_libraries()
|
|
84
|
+
|
|
85
|
+
# Switch. Subsequent knowledge_search calls hit this library until switched again
|
|
86
|
+
knowledge_activate_library(library_id="<id-from-list>")
|
|
87
|
+
|
|
88
|
+
# Confirm what's indexed in the active library
|
|
89
|
+
knowledge_stats()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Multi-profile
|
|
93
|
+
|
|
94
|
+
The gateway stores context per profile ID. To work with multiple profiles:
|
|
95
|
+
|
|
96
|
+
- Use `getbased_list_profiles` to see available profiles and their IDs
|
|
97
|
+
- Pass `profile="id"` to any tool to query a specific profile
|
|
98
|
+
- Omit the `profile` param to use the default profile
|
|
99
|
+
- Each profile's context is pushed automatically when data is saved or the profile is switched in getbased
|
|
100
|
+
|
|
101
|
+
## Setup
|
|
102
|
+
|
|
103
|
+
### 1. Enable messenger access in getbased
|
|
104
|
+
|
|
105
|
+
Go to **Settings > Data > Messenger Access** and toggle it on. Copy the read-only token.
|
|
106
|
+
|
|
107
|
+
### 2. Set up a RAG server (optional — for knowledge_search)
|
|
108
|
+
|
|
109
|
+
The knowledge base runs as a separate service. You need:
|
|
110
|
+
|
|
111
|
+
- A vector database (e.g. [Qdrant](https://qdrant.tech/), [ChromaDB](https://www.trychroma.com/)) loaded with your document chunks and embeddings
|
|
112
|
+
- A FastAPI (or similar) server that accepts `POST /query` with `{version: 1, query: "...", top_k: N}` and returns `{chunks: [{text: "...", source: "..."}]}`
|
|
113
|
+
- An embedding model (e.g. [BGE-M3](https://huggingface.co/BAAI/bge-m3)) for semantic search
|
|
114
|
+
|
|
115
|
+
The RAG server handles embedding, similarity search, and filtering. This MCP just sends HTTP queries to it — no models loaded here.
|
|
116
|
+
|
|
117
|
+
**RAG server contract:**
|
|
118
|
+
|
|
119
|
+
| Field | Required | Description |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `POST /query` | Yes | Accepts JSON body with `version` (int), `query` (string), `top_k` (int) |
|
|
122
|
+
| `Authorization` | Recommended | Bearer token auth |
|
|
123
|
+
| `GET /health` | Optional | Returns `{"status": "ok", "rag_ready": bool, "chunks": int}` |
|
|
124
|
+
| Response | Yes | `{"chunks": [{"text": "...", "source": "..."}]}` |
|
|
125
|
+
|
|
126
|
+
### 3. Configure your MCP client
|
|
127
|
+
|
|
128
|
+
#### Claude Code / Claude Desktop
|
|
129
|
+
|
|
130
|
+
Add to your MCP config (`~/.claude/claude_desktop_config.json` or similar):
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"getbased": {
|
|
136
|
+
"command": "python3",
|
|
137
|
+
"args": ["/path/to/getbased_mcp.py"],
|
|
138
|
+
"env": {
|
|
139
|
+
"GETBASED_TOKEN": "your-token-here"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Hermes Agent
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
hermes mcp add getbased \
|
|
150
|
+
--command python3 \
|
|
151
|
+
--args /path/to/getbased_mcp.py
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Then set `GETBASED_TOKEN` in `~/.hermes/.env` or in the MCP server's `env` config in `config.yaml`:
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
mcp_servers:
|
|
158
|
+
getbased:
|
|
159
|
+
command: python3
|
|
160
|
+
args: [/path/to/getbased_mcp.py]
|
|
161
|
+
env:
|
|
162
|
+
GETBASED_TOKEN: your-token-here
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 4. Use it
|
|
166
|
+
|
|
167
|
+
Ask about your labs in any connected conversation:
|
|
168
|
+
|
|
169
|
+
> "How's my vitamin D?"
|
|
170
|
+
> "What markers are out of range?"
|
|
171
|
+
> "Summarize my latest blood work"
|
|
172
|
+
> "What does the knowledge base say about blue light and DHA?"
|
|
173
|
+
|
|
174
|
+
## Environment variables
|
|
175
|
+
|
|
176
|
+
| Variable | Required | Description |
|
|
177
|
+
|---|---|---|
|
|
178
|
+
| `GETBASED_TOKEN` | Yes | Read-only token from getbased Settings > Data > Messenger Access |
|
|
179
|
+
| `GETBASED_GATEWAY` | No | Context gateway URL (default: `https://sync.getbased.health`) |
|
|
180
|
+
| `LENS_URL` | No | RAG server URL (default: `http://localhost:8322`). Overrides `LENS_PORT` |
|
|
181
|
+
| `LENS_PORT` | No | RAG server port, only used to build default `LENS_URL` (default: `8322`) |
|
|
182
|
+
| `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. |
|
|
183
|
+
| `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. |
|
|
184
|
+
|
|
185
|
+
## Custom Knowledge Source (getbased app)
|
|
186
|
+
|
|
187
|
+
The same RAG server that powers `knowledge_search` for your AI client can also back the in-app AI chat. To connect them:
|
|
188
|
+
|
|
189
|
+
1. Run `getbased_lens_config` — it returns the endpoint URL, API key, and recommended `top_k`
|
|
190
|
+
2. In getbased, go to **Settings → AI → Custom Knowledge Source**
|
|
191
|
+
3. Paste the endpoint URL, API key, and set `top_k` to 5
|
|
192
|
+
4. Enable it — the chat-header Lens badge will light up green when active
|
|
193
|
+
|
|
194
|
+
Every chat question and focus card will now be enriched with RAG-retrieved passages from your knowledge base.
|
|
195
|
+
|
|
196
|
+
## Troubleshooting
|
|
197
|
+
|
|
198
|
+
### `knowledge_search` returns "Lens server not reachable"
|
|
199
|
+
|
|
200
|
+
The RAG server isn't running. Start it and verify with:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
curl http://localhost:8322/health
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### `knowledge_search` returns "Lens API key not found"
|
|
207
|
+
|
|
208
|
+
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.
|
|
209
|
+
|
|
210
|
+
### `knowledge_list_libraries` / `knowledge_stats` return "this lens server doesn't expose library management"
|
|
211
|
+
|
|
212
|
+
The lens server you're pointed at is older than `getbased-rag` 0.1.0 and doesn't implement the `/libraries` or `/stats` endpoints. `knowledge_search` still works against older lens servers since `/query` is protocol-stable. To get library management, either upgrade the lens, or set `LENS_URL` to a library-capable endpoint.
|
|
213
|
+
|
|
214
|
+
### Blood work tools work but knowledge_search doesn't
|
|
215
|
+
|
|
216
|
+
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.
|
|
217
|
+
|
|
218
|
+
## Security
|
|
219
|
+
|
|
220
|
+
- **Read-only**: the token grants access to lab context text only — no raw data, no write access
|
|
221
|
+
- **Self-hosted**: the MCP server runs on your own machine
|
|
222
|
+
- **Revocable**: regenerate the token in getbased to revoke access instantly
|
|
223
|
+
- **No mnemonic exposure**: the token is independent of your sync mnemonic
|
|
224
|
+
- **No models in-process**: RAG queries go through the external server — no embedding models loaded in the MCP process
|
|
225
|
+
|
|
226
|
+
## Related projects
|
|
227
|
+
|
|
228
|
+
- **[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/docs/guide/interpretive-lens.md#for-developers-endpoint-contract) is shared — one server backs both the app and this MCP.
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
GPL-3.0
|