Skip to content
Get Started

The Engine

The Engine as a Library

pip install mirobody: offline indicator resolution, one-call document parsing, and the four install layers between a 77 MB library and the full chat server.

The chat server is built on top of the engine. The engine itself — ① Collect and ② Standardize — is an ordinary Python package: no framework, no database, and no network calls. pip install mirobody is enough to use it.

The reason for that split: standardizing health data normally requires sending it to an external service, whereas here the vocabulary ships with the wheel and the process needs no network access.

mirobody/engine.py is the whole public surface of the engine layer: two functions and two result types.

from mirobody.engine import resolve, parse_file
r = resolve("血红蛋白")
r.loinc # '718-7'
r.canonical # 'Hemoglobin [Mass/volume] in Blood'
r.resolved # True
r.candidates # 72 — how many aliases pointed at this name
readings = await parse_file("physical-2026.pdf") # needs one model key

resolve() is offline and deterministic. parse_file() is the one call that reads a document: it needs a model key for the extraction half only, and the standardization that follows runs offline, which is why the function still does something useful without one.

Installed as a console script, so a plain pip install mirobody gets a runnable command. Deployments use python -m mirobody.

CommandWhat it doesNeeds
mirobody resolve <terms…>Indicator names → standard codesnothing: no key, no config, no network
mirobody parse <file>Lab report in, standardized LOINC table outone LLM key
mirobody serveThe HTTP server (chat, MCP, API)the [agents] extra + Postgres/Redis
mirobody workerThe background task worker (indicator sync, profile refresh)same as serve

serve and worker check for the agent layer up front and print what to install, instead of dying several modules deep with ModuleNotFoundError: langchain.

Terminal window
mirobody resolve "LDL cholesterol" "血红蛋白" "ヘモグロビン" "血圧"
LDL cholesterol LOINC 13457-7 Cholesterol in LDL [Mass/volume] in Serum or Plasma by calculation [63 candidates]
血红蛋白 LOINC 718-7 Hemoglobin [Mass/volume] in Blood [72 candidates]
ヘモグロビン LOINC 718-7 Hemoglobin [Mass/volume] in Blood [72 candidates]
血圧 unresolved — not in the lexical index (the full semantic pipeline may still resolve it)

Three languages, two of them landing on the same code. The fourth line matters: 血圧 names a panel, not an observation, and the lexical index reports an honest miss rather than selecting one of its two components.

InstallWhat worksFootprint
the wheel + numpy onlyfrom mirobody.engine import resolve: the offline resolver77 MB, 2 packages
pip install mirobody+ mirobody parse (one LLM key) · file parsing (PDF/Excel/audio) · FHIR output233 MB, 90 packages
pip install 'mirobody[server]'+ the HTTP API and the MCP endpointneeds Postgres + Redis
pip install 'mirobody[agents]'+ DeepAgent / BaseAgent and mirobody serve (includes [server])+ the LangChain stack
pip install 'mirobody[indicator-build]'rebuilding the terminology bundles themselvesneeds LOINC / UMLS sources

Of the 77 MB floor, 51 MB is the shipped LOINC/SNOMED data — the resolver itself, and the reason standardization works without network access. Two more extras exist: [cn] (Aliyun OSS + Volcengine Ark) and [test] (pytest + import-linter).

The database driver, HTTP server, S3 and email clients live in [server], which [agents] pulls in, so a library user does not pay for a Postgres driver.

The engine must import with no agent framework installed. langchain*, deepagents and langgraph are allowed only under agent/ and server/, the same layering langchain itself uses for langchain-core. Two import-linter contracts in pyproject.toml fail the build on violation, function-local imports included:

Terminal window
pip install -e '.[test]' && lint-imports

That contract is why mirobody.engine can resolve an indicator with numpy as the only third-party package present.

Five scripts in examples/, in order of how much they need, and each one can be run directly.

ExampleNeedsShows
0101_resolve_offline.pypip install mirobody② name → LOINC, any language, fully offline
0202_standardize_a_reading.pypip install mirobody① unit conversion + the indicator catalogue
0303_parse_a_lab_report.py+ one model keya document → standardized readings in one call
0404_mcp_tool_surface.pypip install mirobody③ exactly what an external MCP client receives
0505_agent_server_preflight.pypip install 'mirobody[agents]'whether this machine can run the full server, and what is missing

Examples 01, 02 and 04 require only the package. Example 05 reports every prerequisite of the full server in a single run, which is the quickest way to find out what a machine is still missing.