healthcloud-cli
Requires Python 3.14 or newer.
hc is an SDK-backed CLI: the primary surface is hc ams, which reads and
tunes one explicitly selected AMS tenant (catalog domains -- skills, policies,
guardrails, teams, departments, organization, data-sources, health-services,
schedules, tools -- plus
read-only agent operations, and the utility-agent runs/actions they produce). The hc mcp subtree is the gateway fallback and
has one subcommand per MCP tool projected from bundled Services OpenAPI across
audiences such as patient, fieldagent, ehr, vitals, diagnostics,
appointments, graph, person, provider, tenantadmin, connectors,
and telehealth. Run hc mcp tools list to see the exact, current set for
your installed version. The npm CLI (@healthcloudai/hc-cli) uses the same
OpenAPI inputs and command names.
Install
pip install healthcloud-cli
This installs the hc console script plus its dependency, the
healthcloud-sdk package, which does the actual HTTP/JSON-RPC
work against the MCP gateway.
Local development
Use uv 0.12.5, Python 3.14, and Node.js for source checkout builds. The package's uv source override installs the
SDK checkout in editable mode; its committed lock includes the test and build
tools. Released package consumers can still use pip.
cd packages/cli/pip
uv lock --check
uv sync --frozen --extra dev
uv run --frozen --extra dev python -m pytest
uv run --frozen hc --help
uv run --frozen hc mcp tools list --audience patient
uv run --frozen hc mcp patient get-patient --help
AMS help and shell-completion discovery are credential-free and offline: they
do not resolve root profiles, read target files, create SDK clients, or log in.
You can inspect the group, a leaf command, and completion candidates before
configuring credentials or a target:
uv run --frozen hc ams --help
uv run --frozen hc ams inspect --help
_HC_COMPLETE=bash_complete COMP_WORDS="hc ams in" COMP_CWORD=2 uv run --frozen hc
_HC_COMPLETE=bash_complete COMP_WORDS="hc ams inspect --o" COMP_CWORD=3 uv run --frozen hc
Operational validation starts only when Click invokes an AMS leaf callback.
discover, agents, departments, teams, organization, skills, policies, and sessions
(with attachments and messages) then
validate their explicit environment and tenant arguments; the remaining leaves
require --target-file. All apply the root, target, and authentication checks
described below. Deferring preflight does not relax those safety requirements.
The Hatch build hook bundles the maintained Services OpenAPI JSON from
contracts/generated into healthcloud_cli/contracts/openapi. Installed
wheels read those resources locally. Building a wheel from the source
distribution uses its bundled files and only needs the Python build tools.
To refresh the resources in an existing editable install after regenerating
OpenAPI, run node scripts/sync-cli-contracts.cjs --python from the repository root.
Selecting an AMS API URL
Pass --api-url after ams to select a different AMS deployment without changing
SDK defaults or DNS:
uv run --frozen hc ams --api-url https://dev-ams-services.health.cloud/api/ams \
agents list --environment dev --tenant-id careco
The value is the full HTTPS service base URL, including /api/ams when that is
the service path. A trailing slash is normalized. Without this option, the
existing environment-derived URL is used. The option applies to AMS discovery,
reads and writes; it does not change the tenant-admin login/refresh endpoint or
the saved session's environment and tenant. Root --base-url is for MCP and
remains separate. Use root --verbose to show the selected override on stderr;
JSON results remain on stdout.
For tuning commands, the target file's api_origin must match the selected URL's
origin. New override-based receipts bind the full URL, including its path: repeat
the same option for show, apply and restore. Changing the endpoint or dropping
the option requires a new reviewed plan; existing default receipts remain bound
to their original default configuration. Embedded credentials, query strings,
fragments and ambiguous paths are refused. TLS verification stays enabled and
redirects are not followed.
The local ui launcher supports only the /api/ams service path because the
existing frontend appends that path itself; it refuses custom API paths before
launching. This option does not update deployed web clients.
Authentication & configuration
Every command accepts these global options (place them before the mcp
subcommand):
| Flag |
Env var |
Meaning |
--access-token |
HC_ACCESS_TOKEN |
Bearer token sent to the MCP gateway |
--base-url |
HC_MCP_BASE_URL |
Override the MCP gateway base URL |
--profile |
HC_PROFILE |
Named profile (see below) |
--output |
-- |
pretty (default) | json | raw |
--raw |
-- |
Shortcut for --output raw |
--verbose |
-- |
Print request diagnostics to stderr |
Precedence, highest wins: explicit CLI flag > environment variable >
profile file value > built-in default (environment defaults to "dev";
accessToken/baseUrl default to unset). The resolved access token is never
written to logs, generated files, or test snapshots.
Saved hc login session fallback
When no explicit token is given (--access-token, HC_ACCESS_TOKEN, or a
profile accessToken), hc mcp uses the saved hc login tenant-admin
session as the bearer, with the same locked refresh-near-expiry behavior as
hc ams (the refreshed session is persisted for the next command):
hc login --environment dev --tenant-id TENANT_ID # saves/refreshes the session
hc mcp tenantadmin get-current-tenant-admin # uses the saved session bearer
On HTTP 401 when no explicit token and no saved session exist, the CLI
prints one hint line — Hint: not logged in; run 'hc login', or pass --access-token / HC_ACCESS_TOKEN. — after the failure line, and exits 3.
An explicit token always wins over the saved session; hc logout removes it
(local only).
Optional profile file
~/.healthcloud/cli/profiles.json:
{
"dev-mia": {
"baseUrl": "https://dev-api-mcp.health.cloud",
"accessToken": "eyJ...",
"environment": "dev"
}
}
A missing profiles file is not an error -- profiles are entirely optional. If
--profile/HC_PROFILE names a profile and the file (or that entry) is
missing, hc exits with a clear usage error rather than silently ignoring
it.
# get-patient is self-service — the patient is resolved from the access
# token, so no --patient-id flag exists.
hc --profile dev-mia mcp patient get-patient
Listing and inspecting tools
# Local (bundled OpenAPI)
hc mcp tools list
hc mcp tools list --audience patient
# Live gateway (requires --audience)
hc mcp tools list --audience patient --remote
# Show one tool's input schema, HTTP route, and policy metadata
hc mcp tools show patient add_insurance --output json
Calling a tool
Each MCP binding has its own subcommand, grouped by audience:
hc mcp patient get-patient
hc mcp appointments book-appointment --patient-id patient-123 --slot-id slot-456
# Every Diagnostics tool takes an explicit --patient-id — providers and
# field agents legitimately look up or record diagnostics for a patient
# other than themselves. When the caller holds a patient token, the backend
# enforces server-side that --patient-id must be their own (403 otherwise).
hc mcp diagnostics create-rapid-test --patient-id patient-123 --test-type covid-19 --result negative
Run --help on any generated command to see its description
and arguments:
hc mcp patient get-patient --help
Argument flags
-
Primitive properties (string/number/integer/boolean) become a
normal flag in kebab-case, e.g. patient_id -> --patient-id.
enum values are validated; invalid values are rejected before any
network call.
minimum/maximum/exclusiveMinimum/exclusiveMaximum are enforced
the same way.
- Boolean properties are a tri-state flag pair:
--flag/--no-flag.
Passing neither leaves the value unset (falls back to the schema
default or an --input/--stdin value, if any); passing one sets it
explicitly to true/false.
-
Object/array properties are never flattened. They get a single
--<prop>-json flag that takes a raw JSON string, e.g.:
# create-medication is self-service — no --patient-id flag; the patient is
# resolved server-side from the access token.
hc mcp patient create-medication \
--name "Metformin" \
--dosage-json '{"value":10,"unit":"mg","frequency":"once_daily"}'
-
Path parameters (from {placeholders} in the tool's HTTP path) are always
required, in addition to whatever inputSchema.required lists.
Bulk input: --input / --stdin
hc mcp appointments book-appointment --input request.json
cat request.json | hc mcp appointments book-appointment --stdin
--input <file> and --stdin both supply a base JSON object of
arguments. --input and --stdin cannot be combined. Merge precedence
(highest wins): schema defaults < --input/--stdin object < explicit
flags -- i.e. an explicit flag you actually pass always overrides the same
key coming from a file or stdin, which in turn overrides the schema default.
After merging, the final object is validated against the tool's
inputSchema (required fields present, correct types, enum membership,
numeric bounds). Any validation failure prints a clear message to stderr and
exits 2, without making a network call.
hc mcp call -- generic escape hatch
hc mcp call dispatches to any MCP tool by its exact snake_case tool name --
including one added since your installed release. The CLI forwards the exact
tool name to the gateway:
# get_patient is self-service and takes no arguments — {} is a complete,
# valid call.
hc mcp call patient get_patient --input '{}'
hc mcp call patient get_patient --input-file request.json
cat request.json | hc mcp call patient get_patient --stdin
Note the deliberate inconsistency versus named commands: here --input takes
an inline JSON value, not a file path -- use --input-file for a file.
Exactly one of --input / --input-file / --stdin may be given (or none,
meaning {}).
Output modes
The MCP tool-call result is { content: [{type:"text", text: "..."}], is_error: bool } from the JSON-RPC response's .result, or the JSON-RPC
.error object if the gateway returned one.
pretty (default): if content[0].text parses as JSON, pretty-prints
the parsed value; otherwise prints the raw text. On a JSON-RPC error,
prints error.message (and error.code with --verbose) to stderr.
json: prints the tool result's parsed JSON (or raw text if
unparseable) to stdout, with no envelope.
raw: prints the complete JSON-RPC envelope (id, jsonrpc,
result, error) as returned by the gateway.
Diagnostics and --verbose logs always go to stderr -- stdout stays
pipeable in every mode.
Exit codes
| Code |
Meaning |
0 |
Success |
2 |
Local input validation failure (bad JSON, missing required field, invalid enum/number, --input+--stdin both given, unknown option) -- no network call made |
3 |
HTTP/network failure talking to the MCP gateway |
4 |
JSON-RPC error response (.error is not None) |
5 |
MCP tool result reported is_error: true |
Building
uv lock --check
uv run --frozen python -m build --no-isolation
uv run --frozen python -m zipfile -l dist/*.whl # inspect the bundled OpenAPI
Deployed AMS administration (source checkout)
The reviewed AMS administration SDK is not published yet. Use this checkout's
editable SDK and tenant-admin sources; no released SDK version is claimed to
contain ams_admin. An installed SDK missing that capability is refused before
login. Ordinary MCP commands keep their existing behavior.
Prepare ignored SDK build READMEs from tracked inputs, then install the locked
editable packages (the CLI README itself is tracked):
node tooling/docs-compiler/prepare-package-readmes.mjs
cd packages/cli/pip
uv sync --frozen --extra dev
uv run --frozen hc ams --help
Create one private tenant-admin session before interactive AMS work, inspect its
non-secret binding, and remove it when finished:
uv run --frozen hc login --environment dev --tenant-id TENANT_ID
uv run --frozen hc login --status
uv run --frozen hc logout
hc login reads HC_AMS_ADMIN_EMAIL and HC_AMS_ADMIN_PASSWORD when present,
otherwise it prompts (with hidden password input). It stores only the email,
tenant/environment binding, access/refresh tokens and expiry in the strict
owner-only ~/.healthcloud/cli/ams-session.json; it never stores the password.
By default (pretty) these three commands print readable lines — never a raw
JSON blob and never a token:
$ hc login --environment dev --tenant-id TENANT_ID
saved session: dev / TENANT_ID
email: admin@example.test
expires_at: 2026-11-02T01:42:29Z
$ hc logout
saved session removed: true
server session revoked: false
hc login --status prints the same three lines for the saved session, and a
second hc logout reports saved session removed: false. --output json (and
--output raw, which these commands treat as JSON) prints exactly the objects
they have always printed: {"schema_version": 1, "ok": true, "session": {"schema_version": 1, "environment", "tenant_id", "email", "expires_at"}}
for login/--status, and {"schema_version": 1, "ok": true, "removed": true|false, "server_session_revoked": false} for logout.
For CI and agents, log in non-interactively: pass --email and pipe the password
to --password-stdin (read as exactly one stdin line, never printed by the CLI, never a
flag value — there is no --password option):
printf '%s\n' "$HC_AMS_ADMIN_PASSWORD" | \
uv run --frozen hc login --environment dev --tenant-id TENANT_ID \
--email "$HC_AMS_ADMIN_EMAIL" --password-stdin