npm latest stays @lastehr/mcp@0.5.4. The Official MCP Registry record for
io.github.cbetz/last-ehr marks 0.5.4 isLatest. This checkout prepares
0.5.5. That version is not published.
npx -y @lastehr/mcp@0.5.5 init --demo
npx -y @lastehr/mcp@0.5.5 init --demo --client claude-code
npx -y @lastehr/mcp@0.5.5 init --demo --client cursorinit --demo runs synthetic seed patients in-process, and approved writes vanish when the process exits. Synthetic data only. This is not a clinical or compliance claim.
A FHIR MCP server exposes patient-chart operations as tools through the
Model Context Protocol. @lastehr/mcp is Last EHR's open-source implementation:
your MCP client supplies the agent and model, while this package reads from
your FHIR backend and returns the results to that client. It runs separately
from the Last EHR web app and is read-only by default.
What can the agent read or write?
The package provides four read tools: patient search, chart overview, a filtered chart section, and inline document text. The section reader covers 23 patient-scoped sections and reports incomplete or unsupported reads. See the tool surface and FHIR coverage for resource types and limits.
With LASTEHR_MCP_WRITES=proposal, four additional tools can create notes
(Communication), measurements and linked corrections (Observation), and
follow-up tasks (Task). Each write requires a human approval prompt in a
client that declares MCP elicitation support. The tools do not update or
delete existing records, and a client without that capability receives no
write tools.
Which FHIR backends are supported?
Use hosted or self-hosted Medplum for the authenticated path. The package also
supports this repository's no-auth HAPI stack over stdio for local synthetic
evaluation. FHIR_BACKEND=memory, selected by init --demo, is an
in-process synthetic store seeded from this repository's fixtures. No
account, token, or Docker. Approved writes stay in that process and vanish
when it exits. Synthetic data only. This is not a clinical or compliance
claim.
LASTEHR_BACKEND=epic|oracle|smart with
LASTEHR_EXPERIMENTAL_FHIR_ADAPTERS=1 selects SMART Backend Services for the
Epic sandbox, the Oracle Health sandbox, or another token endpoint. Those
sandboxes do not support delete, so an approved Observation persists. They
are not a supported production configuration and not a clinical or
compliance claim. Setup is in
Epic and Oracle Health sandboxes and the
0.5.1 notes. The separate checkout-only
Local Lab below exposes just two read tools against four synthetic patients.
See the support matrix.
Where does patient data go?
The MCP server fetches chart data from the configured FHIR backend and returns it to your MCP client. The client may send those results to its model provider and retain them according to its own settings. This package does not call a model provider itself. Reads run without a human approval step; approving a write controls saving a resource, not sharing read context with a model.
Start with synthetic records and review your client's and provider's data handling before connecting a project. Install and connect describes the local stdio setup; remote HTTP and OAuth requires additional operator infrastructure.
Zero-credential Local Lab (checkout only)
Want to inspect the MCP interaction before creating a Medplum project or
configuring a model-provider API key? The repository includes a separate
synthetic HAPI Local Lab. It is intentionally not part of @lastehr/mcp
and does not broaden that package's support boundary.
From a local checkout with Node 22.18+ and Docker running:
If the stack fails to come up, see Troubleshooting the local lab.
npm install
npm run mcp:demo -- --client claude-codeThe command starts the repository's local HAPI + Postgres stack, waits for it,
recreates the four synthetic fixture charts, then prints a ready-to-paste
Claude Code registration command. For a JSON configuration (including Cursor),
use either the default or --client cursor:
npm run mcp:demo
npm run mcp:demo -- --client cursorThe generated client process invokes the checkout directly, rather than an npm lifecycle command, so its stdout is reserved for MCP JSON-RPC. The lab server does not require or read FHIR/Medplum credentials or a model-provider API key. Your MCP client still needs its usual authenticated model account and may send the returned synthetic chart data to that provider. Docker may also pull the local images on the first run.
Its boundary is deliberately narrow:
- exactly
search_patientsandshow_patient_info, both withreadOnlyHint— the Local Lab deliberately dropsread_chart_sectionandread_documentthat@lastehr/mcpoffers, because its fixture client serves six resource types and the section reader advertises 23, so 17 would refuse; - only the four records carrying this repository's synthetic fixture identifiers are discoverable;
- the generated configuration targets
127.0.0.1:8080/fhir, and the server accepts only loopback HAPI endpoints; - no write tool, write flag, credential configuration, or arbitrary FHIR endpoint exists.
The local HAPI container has no authentication. Use this lab only for synthetic
data on one machine. Compose binds it to 127.0.0.1 by default; do not change
that to a network-facing port. It is an evaluation experience, not generic HAPI
support, an authorization layer, a PHI workflow, or a release of
@lastehr/mcp.
Run npm run mcp:demo -- --prepare when you only want to pre-warm the local
stack. The --serve mode is reserved for the generated MCP configuration and
must not be launched through npm run, because npm may write non-protocol text
to stdout. Keep the local stack running while the client is connected; use
npm run demo:local:down to remove it when finished. Port 8080 must be free.
Install and connect
The zero-setup command is at the top of this page. The commands below are a
Medplum credential. They generate a local stdio configuration. They do not
install the server into your client or configure remote OAuth automatically.
Since 0.4.1, init pins the generated package command to its own version,
so these commands produce a configuration that starts @lastehr/mcp@0.5.5.
Confirm it with npx -y @lastehr/mcp@0.5.5 --version. Older releases do not
include init --demo, HTTP transport, or doctor --connect.
Claude Code
Configure a least-privilege Medplum credential using Auth, then print the registration command:
npx -y @lastehr/mcp@0.5.5 init --client claude-codeRun the generated claude mcp add command, then launch Claude Code from an
environment where those credentials are available. The server process
inherits MEDPLUM_* variables from your shell or MCP client configuration.
Use /mcp in Claude Code to inspect the connection. Its
MCP documentation
covers registration, credential configuration, and installation scope.
Cursor or a JSON configuration
Print the Cursor configuration:
npx -y @lastehr/mcp@0.5.5 init --client cursorThe default command prints the same server fields without "type":
npx -y @lastehr/mcp@0.5.5 initReplace the placeholder with a least-privilege Medplum token, then add the
lastehr entry to your client's MCP configuration. The Cursor output below
declares "type": "stdio". Save the configuration in
~/.cursor/mcp.json for personal use or .cursor/mcp.json for this project.
See Cursor's MCP documentation
for its configuration fields and locations.
{
"mcpServers": {
"lastehr": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@lastehr/mcp@0.5.5"
],
"env": {
"MEDPLUM_ACCESS_TOKEN": "<replace-with-a-least-privilege-token>"
}
}
}
}Start the server directly with npx -y @lastehr/mcp@0.5.5 when you want to inspect a
stdio connection yourself. These setup commands do not establish write
compatibility: the optional write profile checks the connected client's
elicitation capability at runtime.
Auth
The package uses Medplum credentials:
MEDPLUM_CLIENT_ID=...
MEDPLUM_CLIENT_SECRET=...or:
MEDPLUM_ACCESS_TOKEN=...Set MEDPLUM_BASE_URL for self-hosted Medplum.
The stdio server answers initialize and tools/list when these are missing or still the <replace-...> placeholder from init, so a directory can show the catalog. The first tool call names the missing or invalid variable and points at npx @lastehr/mcp init and npx @lastehr/mcp doctor. doctor still rejects a missing credential. Nothing is written without a valid configuration and a human approval.
Check the connection
doctor validates configuration without making a network request:
npx -y @lastehr/mcp@0.5.5 doctorAdd --connect to check FHIR R4 metadata and make a count-only Patient
search with your configured stdio credentials. That check has been in the
package since 0.4.0:
npx -y @lastehr/mcp@0.5.5 doctor --connectThe check makes no chart write and prints no patient data or counts. A successful count-only search does not establish permission to read individual charts, other resource types, or write resources. It also does not test an MCP host's approval support. Requests have a ten-second overall deadline and refuse redirects.
For HTTP transport, doctor checks configuration only. doctor --connect
returns a nonzero exit status because it cannot verify a caller's remote
OAuth login, token exchange, permissions, or host approval behavior. Follow
the remote verification boundary
before relying on that transport.
Local stack (FHIR_BACKEND=hapi)
The published package also honors the same env pair the web app and seed use, so a fully local synthetic stack gets MCP too:
FHIR_BACKEND=hapi
FHIR_BASE_URL=http://localhost:8080/fhir # or HAPI_BASE_URLNo credentials: the repository's HAPI evaluation stack is no-auth by design,
which is exactly why the same caveats apply as in the web app — local,
single-tenant, synthetic data only; never point it at an exposed server or
treat it as an authorization layer. Any configured MEDPLUM_* values are
unused in this mode (a checkout's .env commonly carries both). The tools
and the write-policy boundary (read-only by default, the same opt-in write
profile) are identical to the Medplum mode.
This is distinct from npm run mcp:demo (the checkout-only Local Lab), which
remains fixture-restricted and needs no configuration at all.
Registry metadata
The package is listed in the Official MCP Registry, the client-facing installation record for the verified npm release.
Maintainers publish that immutable record through the manual Publish MCP Registry metadata GitHub Actions workflow after the corresponding npm version is public.
Tool surface
By default the package exposes four read tools, all marked with MCP's
readOnlyHint:
search_patientsshow_patient_inforead_chart_section— one of 23 patient-scoped sections, with code, measurement-name, status, category and date filtersread_document— the text of one document already listed in the chart
As of 0.3.0 those are the same implementations the Last EHR web agent uses
(packages/mcp/src/chart-read.ts), not a reduced copy. That is deliberate:
each of their honesty properties came from a real false negative found against
a live FHIR server, and a second implementation would have re-earned every one.
The retired 0.1.x line was permanently read-only, and read-only remains the
default forever. As of 0.2.0 there is exactly one opt-in beyond it, the
proposal-shaped write profile below.
What a reply tells you it could not see
An empty result is never proof of absence, and the server says why. These are the fields to check before telling anyone a patient has no record of something:
| Field | Meaning |
|---|---|
truncated | The server's window came back full, so older records may exist beyond it. Measured at the window, not at the surviving row count. |
codeFilterUnmatched | The section does hold records; none carry the code you filtered by. Text-only CodeableConcepts cannot match a coded search. |
includeUnsupported | The backend refused the reference lookup. Not the same as there being no references. |
unreadable (documents) | The document exists and its contents were not read: a scan, or a body stored as a pointer rather than inline. |
A filter a section cannot apply is refused with that section's legal values, and those refusals reach the client verbatim rather than being scrubbed into a generic backend error — the message exists so the caller can correct itself. Backend errors are still scrubbed, since a FHIR server may put resource fragments in one.
Chart free text arrives wrapped in <chart_text> tags: that content is data,
never instructions. The server declares this, and the flag meanings above, in
its MCP instructions, because unlike the web app it does not control the
client's system prompt.
Proposal-shaped writes (0.2.0, opt-in)
LASTEHR_MCP_WRITES=proposal adds the web demo's write actions —
add_note (Communication), record_observation and
record_superseding_observation (Observation), and create_task (Task) — as
elicitation-gated proposals: the tool builds the exact FHIR resource it
would create, presents those fields to the human through MCP elicitation
(client-rendered accept/decline/cancel with a single "Approve and save?"
boolean), and commits only on an explicit approval. A decline, cancel,
unapproved accept, or any approval-transport failure saves nothing and the
tool result says so. Every value the flag accepts other than proposal is
rejected loudly.
The profile is a binding of the repository's framework-neutral Approval-Gated Agent Writes on FHIR protocol (v0.1 draft). The gate is structural, not advisory:
- Capability-gated, fail closed. The write tools are offered only to
clients that declared the
elicitationcapability at initialization; a host that cannot render the approval never sees a write tool. - What you see is what saves. The elicitation message contains the exact proposed fields; the committed resource is built from the same parsed input, with the same caps as the web demo's tools.
- Evidence beside the diff. Each write tool takes an optional
evidenceorbasedOnlist ofResourceType/idvalues, with an optional short reason. Calls that omit it still propose the write. The approval prompt includes a diff of the proposed resource, the cited list, and the resources this session's read tools returned before the proposal. A proposal with no citation says so. Citations are not stored on the resource. A missing citation does not approve or deny the write. - Cited evidence is re-read at commit. While the proposal is prepared,
each cited resource is pinned to the version from this session's read of
it. A citation this session has not retained is read then, and that read
is the pin. The pin is
meta.versionIdwhen the resource has one, otherwisemeta.lastUpdated, otherwise a SHA-256 of the resource's JSON with object keys sorted and array order kept. Medplum, HAPI, and the experimental adapters supplymeta.versionId. The in-process memory store (FHIR_BACKEND=memory) assigns neither meta field, so it uses the content hash. After approval and before the create, each cited resource is read again. If any is missing, deleted, or no longer that version, or the read fails, nothing is saved and the tool result names the reference so the agent can read again and propose again. A proposal with no citation is unchanged.record_superseding_observationre-checks the observation it would supersede the same way, whether or not that observation was cited. The check compares versions. It does not decide that the proposal follows from the cited rows. - Tagged for audit. Approved writes carry
meta.tag {https://lastehr.com/mcp | approved-proposal}so operators can find every agent-written record with one_tagsearch, plus the standard AIAST security label ("Artificial Intelligence asserted") inmeta.securityper the HL7 AI Transparency on FHIR IG. SetLASTEHR_WRITE_PROVENANCE=trueto also emit aProvenanceresource per approved write naming the agent as author and the reviewer as verifier — see the protocol's Audit section. - Narrowable, never widenable.
LASTEHR_WRITE_TOOLS_DISABLED(comma-separated:add_note,record_observation,record_superseding_observation,create_task) unregisters write tools entirely — unlisted and uncallable, with unknown names refusing startup. Embedders can pass a deny-onlypolicyhook inWriteToolOptions: checked before the reviewer is asked, re-checked at commit, fail-closed, and its denials are attributed to configuration, never to a human (see the protocol's Decision section). - Transport-adaptable. The approval exchange lives behind one function
(
createElicitationApproval); the MCP 2026-07-28 release candidate replaces server-initiated elicitation with Multi Round-Trip Requests, and only that adapter changes when it lands.
Batch review
A single write still asks for approval on that call. To hold several
proposals for one review, pass holdForReview: true on each write. Nothing
is saved. list_pending_proposals returns the queue grouped by patient,
with the same diff and citation flag as a single prompt. A proposal that
cites nothing is marked that way. The flag does not approve or deny the
write.
review_pending_proposals asks the person to decide each held proposal.
The form has one approve-or-decline field per proposal, plus a control that
declines every proposal left unset. There is no approve-all. Submit saves
only the proposals set to approve. A proposal left unset stays pending.
Each approved item is checked again at that moment: policy, the cited-version
re-read, and the attribution tag. One item failing does not save or block
the others. The result lists each item on its own. Decisions come from the
person's form, not from the tool arguments.
The same data caveats as reads apply, doubled: only enable writes against a project whose access policy you have scoped, and never against real data you are not authorized to modify. The elicitation exchange requests a decision, never data.
Remote transport (HTTP, opt-in)
Stdio is the default and stays so. Since 0.4.0, LASTEHR_MCP_TRANSPORT=http
serves streamable HTTP instead, so a hosted agent can reach the server. The
design and its evidence are in remote-mcp.md; this is the
operator view.
What it is. An OAuth 2.1 resource server in front of one MCP server per
session. Every request must carry a bearer addressed to this server, verified
offline against your authorization server's JWKS. Each caller's own FHIR
credential is obtained once per session by RFC 8693 token exchange, so this
process needs no shared FHIR credential. Each session's client holds its
exchanged token, and Medplum's AccessPolicy still decides what each caller
can reach. Read-only stays the default; LASTEHR_MCP_WRITES=proposal is the
same opt-in, and the approval gate is evaluated per session.
What you need.
- An authorization server that can issue tokens addressed to this server
(RFC 8707 resource indicators). Medplum cannot be that server: it issues
tokens addressed to itself and ignores the
resourceparameter, which the probe in remote-mcp.md records. - A Medplum
ClientApplicationwith your identity provider configured (its user-info URL). The exchange goes through it, and it checks no client secret, so this server stores none. - The identity provider's
/userinforeachable over public HTTPS. Medplum refuses plain HTTP and private addresses, and the resulting error names the identity provider configuration without mentioning the protocol. MEDPLUM_BASE_URL, when set, on the same origin asLASTEHR_MCP_TOKEN_ENDPOINT. An exchanged token is only ever sent to the server that issued it, and the server refuses to start otherwise.- TLS in front of this process. It speaks plain HTTP, binds loopback by
default, and refuses a non-loopback bind unless the resource identifier is
https.
LASTEHR_MCP_TRANSPORT=http
LASTEHR_MCP_RESOURCE=https://mcp.example.org/mcp
LASTEHR_MCP_OAUTH_ISSUER=https://auth.example.org/
LASTEHR_MCP_OAUTH_JWKS_URI=https://auth.example.org/.well-known/jwks.json
LASTEHR_MCP_REQUIRED_SCOPES=chart.read
LASTEHR_MCP_EXCHANGE_CLIENT_ID=<ClientApplication id with the identity provider>
LASTEHR_MCP_TOKEN_ENDPOINT=https://api.medplum.com/oauth2/token
npx -y @lastehr/mcp@0.5.5The metadata document is served unauthenticated at
/.well-known/oauth-protected-resource<path> so a client can discover the
authorization server; every 401 points there.
What it does not do. It is not multi-tenant aggregation: each caller
reaches what their own Medplum identity allows, and nothing here pools
tenants. It is not an authorization server and issues no tokens. It refuses
FHIR_BACKEND=hapi, because a remote transport in front of a no-auth server
would publish an unauthenticated chart API. Sessions live in one process, so
several instances need sticky routing.
The October 22, 2026 checkout report
records 18 passing checks on clean source e970461, using real Keycloak
login, local self-hosted Medplum, and public HTTPS UserInfo. Hosted Medplum,
deployed public MCP TLS, a real host's human approval UI, and actual reviewer
identity remain unverified. See the verification boundary.
Data and support boundary
Read-only does not mean low-risk: show_patient_info can return PHI-rich
chart data. Use the smallest Medplum AccessPolicy that meets the task, confirm
that your MCP client and model provider are appropriate for the data, and do
not treat this package as an authorization layer.
@lastehr/mcp supports hosted or self-hosted Medplum authentication, plus
the repository's local no-auth HAPI stack (FHIR_BACKEND=hapi, local synthetic
data only). It does not claim generic FHIR, SMART launch, or browser-approval
parity. See the support matrix for the complete boundary.
From a checkout
The repository includes the same Medplum package for contributors:
npm run mcpThis builds @lastehr/mcp and starts it with your local Medplum environment
variables — including LASTEHR_MCP_WRITES if you have opted in.
Roadmap
- Remote transport shipped in
0.4.0behindLASTEHR_MCP_TRANSPORT=http(see above). The design, the probe evidence, and what the implementation corrected are in remote-mcp.md. The local real-IdP checkout harness passed on October 22, 2026. Hosted Medplum, deployed MCP TLS, real-host human approval UI, and reviewer identity still need evidence. - Better read-tool coverage where it can stay bounded and auditable.
- Proposal-shaped writes shipped in
0.2.0behindLASTEHR_MCP_WRITES=proposal(see above), riding MCP's reviewable confirmation protocol (elicitation). AIAST labeling and opt-in Provenance emission aligned with HL7's AI Transparency IG shipped with it (see "Tagged for audit" above).
Want a concrete starting point?
Inspect the fixture-restricted local MCP surface before connecting a real project.