dsh-plugin-mirobody
其他 活跃维护

dsh-plugin-mirobody

zwbao/dsh-plugin-mirobody

轻量级 Mirobody 插件,内置离线 LOINC/UCUM 标准术语库,并带只读的健康、用药与基因型数据工具,所有内容本地处理,无需联网即可完成检索。

2
Stars 标星
0
Forks 分支
2
Watchers 关注
0
Open Issues
JavaScript
主要语言
Apache-2.0
开源协议
159 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:zwbao/dsh-plugin-mirobody
git clone https://github.com/zwbao/dsh-plugin-mirobody.git
git clone git@github.com:zwbao/dsh-plugin-mirobody.git
README.md main

dsh-plugin-mirobody

English · 中文

DeepSeek Harness plugin for Mirobody: one LOINC code for a lab name, one UCUM unit, and the same read-only record tools Mirobody serves at /mcp.

The Python engine stays the resolver. This package is the harness: nine tools, five skills, a Mirobody tab, and slash commands. It does not reimplement the LOINC bundle, Postgres, wearable OAuth, or file ingestion.

Install

Requires Node 22.19+, pnpm (dsh plugin installs through it), and a Python 3.12+ interpreter with mirobody installed. The record tools follow Mirobody 1.5.2 and later (tested against 1.5.9); a 1.5.1 server rejects their view parameter.

With dsh-plugin-longpi you do not install this separately. LongPi declares this plugin as a dependency, so dsh plugin add puts it in the profile and LongPi mounts it with the settings in LongPi's own row. Adding it a second time registers the same tools twice.

On its own:

# 1. The Python engine (offline terminology)
python3.12 -m venv ~/.venvs/mirobody && ~/.venvs/mirobody/bin/pip install mirobody

# 2. Into the DSH web profile (created on first use)
dsh plugin --profile web add github:zwbao/dsh-plugin-mirobody

Then override the row in ~/.dsh/profiles/web/cordis.patch.yml (replace the file's [] with the block below). A patch replaces the row's whole config, so restate every key:

- id: dsh-plugin-mirobody
  config:
    pythonBin: /Users/you/.venvs/mirobody/bin/python   # your absolute path
    mirobodyHome: ''
    mcpUrl: http://127.0.0.1:18060/mcp/<personal-secret>  # Mirobody Settings → MCP
    mcpToken: ''
    timeoutMs: 30000

dsh --profile web --dump-config shows the row in effect; then restart dsh web. From a checkout: git clone https://github.com/zwbao/dsh-plugin-mirobody && cd dsh-plugin-mirobody && npm install && npm test && dsh plugin --profile web add link:$PWD. npm test also compares the record tools with the installed Mirobody's own schemas when MIROBODY_PYTHON (or ./.venv) can import them, which needs python-dotenv ruamel.yaml cryptography beside mirobody. Against a running server: MIROBODY_E2E_MCP_URL=<personal MCP link> npm run e2e (the account needs readings, a medication plan and a genotype upload, or Mirobody hides those tools).

Field Meaning
pythonBin Interpreter that can import mirobody. Empty tries python3.14, python3.13, python3.12, then python3.
mirobodyHome Optional source checkout added to sys.path. A checkout still needs git lfs pull for the LOINC bundle.
mcpUrl Record server: the personal URL from Mirobody Settings → MCP (…/mcp/<secret>, valid 10 days by default since Mirobody 1.5.3, MCP_URL_TTL_DAYS), or http://127.0.0.1:18060/mcp with mcpToken.
mcpToken Account JWT when the URL does not carry one (the access_token from POST /password/login, valid 30 days by default). Leave empty for terminology-only use.
timeoutMs Bridge and MCP budget. Default 30000. First resolve loads the bundle and can be slower.

The Python bridge starts with a minimal environment, never the harness's own: PATH, HOME, LANG, LC_ALL, TMPDIR, MIROBODY_HOME (from mirobodyHome), PYTHONNOUSERSITE=1 and PYTHONDONTWRITEBYTECODE=1. So pythonBin must import mirobody from its own site-packages (the venv above); a pip install --user copy and PYTHONPATH are not seen. Use mirobodyHome for a source checkout.

Tools

Tool Where it runs What it returns
resolve_indicator local engine LOINC for each printed name. Unresolved is empty, not a guess.
resolve_reading local engine LOINC for a name plus value and unit. The unit selects the code.
convert_unit local engine A converted number, or null when the units are not interconvertible.
normalize_unit local engine UCUM form and property family.
query_health_indicators Mirobody /mcp Catalogue, then one view: raw rows, minute…month points, stats, trend, or latest.
query_medications Mirobody /mcp Plan, dose log, or course history. Read-only.
query_genetic_data Mirobody /mcp Genotype calls by rsID, gene, or region; a summary with none. A missing locus was not typed.
query_pharmacogenomics Mirobody /mcp CPIC A/B drug–gene pairs and which defining sites the upload covers. Not a phenotype, not dosing.
mirobody_status local Whether the engine imports, and whether mcpUrl is set. No chart data, no token.

Record tools read only the account the token or personal link belongs to; there is no parameter for another person. Mirobody checks the arguments itself and its refusal names each parameter, so the plugin does not keep a copy of the server's grammar.

Commands and HTTP

  • /mirobody — engine version and whether MCP is configured
  • /mirobody-resolve 血红蛋白 血脂 — offline resolve
  • /mirobody-version
  • GET /api/mirobody/status
  • GET /api/mirobody/resolve?q=血红蛋白&q=血脂
  • GET /api/mirobody/version

Each route runs DeepSeek Harness's own connection check first (Host/Origin and the session cookie): 401 or 403 otherwise, 503 when the connection service is missing. A write must be application/json (415 otherwise).

The web tab is Mirobody. It forwards the DSH token query parameter the same way the page was opened and sends the session cookie.

Boundaries

Not a medical device. No diagnosis, no dose change. When a message describes an emergency happening now, or real self-harm wording, the plugin appends a note after it so the reply begins with “call 120” (988 in the US) and gives no treatment steps; a request to start, stop or change a medicine gets a note to leave it to the prescribing doctor. The person's words are never replaced. A negated symptom, a family member's history, a risk question or a past event does not trigger it. See docs/intended-use.md.

血红蛋白 resolves to 718-7. 血脂 resolves to nothing, because it names a panel. Total cholesterol 5.0 mmol/L resolves to 14647-2.

Apache-2.0. Mirobody and its terminology licences are named in NOTICE.