Skip to content

Commit c7d4a19

Browse files
committed
update README and plan: Phase 8 complete (all 6 sub-phases shipped)
1 parent 8fd7259 commit c7d4a19

2 files changed

Lines changed: 38 additions & 16 deletions

File tree

FHIR_COMPLIANCE_PLAN.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -568,16 +568,17 @@ Tool catalog (all schemas are discriminated unions over `resourceType`):
568568
| v0.40.0 | 6 | FHIRPath invariant evaluator (subset) |
569569
| v0.41.0 | 8.1 | `@fhir-dsl/mcp` package skeleton |
570570
| v0.42.0 | 8.2 | MCP generic verb runners (read/search/etc. against upstream) |
571+
| v0.43.0 | 8.3 | MCP `resources/read` (URI-addressable get-by-id) |
572+
| v0.44.0 | 8.5 | Write gating + safety (dryRun, confirmWrites, write-resource-types) |
573+
| v0.45.0 | 8.7 | Token economy defaults (`_count`, `_summary`, byte cap) |
574+
| v0.46.0 | 8.9 | `fhir-gen mcp` CLI command |
575+
| v0.47.0 | 8.8 | Generator `--mcp <out>` scaffold emission |
576+
| v0.48.0 | 8.4 | Backend-services + patient-launch auth via `@fhir-dsl/smart` |
571577

572578
### Remaining
573579

574-
- Phase 8.3 — MCP `resources/read` (URI-addressable get-by-id)
575-
- Phase 8.4 — Backend-services + patient-launch auth wiring
576-
- Phase 8.5 — Write gating + safety
577-
- Phase 8.7 — Token economy defaults (response truncation, `_summary`)
578-
- Phase 8.8 — Generator integration: `fhir-gen generate --mcp <out>`
579-
- Phase 8.9 — CLI ergonomics (`fhir-gen mcp` to launch a configured server)
580-
- Phase 6 follow-up — wire compiled invariants into emitted Standard Schema validators
580+
- Phase 6 follow-up — wire compiled invariants into emitted Standard Schema validators (extract `ElementDefinition.constraint[*]` at generate time, run `compileInvariant`, thread into the zod/native validator output)
581+
- Phase 8 — Streamable HTTP transport (the package ships only stdio today; the spec also defines an HTTP transport, useful for hosted deployments)
581582

582583
## Out of scope (intentionally)
583584

README.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,11 @@ fhir-dsl is audited against the FHIR architectural overview (https://build.fhir.
219219
| FHIRPath — invariants compiled to runtime predicates || `compileInvariant` + `validateInvariants` returning OperationOutcome (Phase 6, v0.40.0). Subset: identifiers/member access, `exists`/`empty`/`matches`/`count`/`where`/`hasValue`, `and`/`or`/`xor`/`implies`/`not`, comparisons, parentheses, indexers, three-valued logic. |
220220
| SMART on FHIR v2 || PKCE-S256, backend services, scope DSL. |
221221
| Layered framework (Foundation/Base/Clinical/Financial/Specialized) || `LAYER_OF`, `referencesUpward` emitted under `<version>/layers.ts` (Phase 5, v0.30.0). |
222-
| MCP server generation — package + dispatcher || `@fhir-dsl/mcp` ships generic verb tools, three pluggable auth strategies, audit sinks, stdio transport (Phase 8.1+8.2, v0.41.0+v0.42.0). |
223-
| MCP server generation — generator `--mcp` integration || Phase 8.8. |
222+
| MCP server generation — package + dispatcher || `@fhir-dsl/mcp` ships generic verb tools, audit sinks, stdio transport, FHIR URI templates with `resources/read` (Phases 8.1–8.3, v0.41.0+). |
223+
| MCP server generation — auth strategies || Bearer / backend-services (signed JWT via SMART v2) / patient-launch (refresh-token flow), all lazy-loaded (Phase 8.4, v0.48.0). |
224+
| MCP server generation — write gating + token economy || Per-resource-type allowlists, dryRun, confirmWrites, default `_count`/`_summary`, response-byte cap (Phases 8.5+8.7, v0.44.0+v0.45.0). |
225+
| MCP server generation — generator + CLI integration || `fhir-gen generate --mcp <out>` emits a server scaffold; `fhir-gen mcp <baseUrl>` launches one inline (Phases 8.8+8.9, v0.46.0+v0.47.0). |
226+
| Phase 6 follow-up — invariants in emitted validators || Compile generator-time invariants into the emitted Standard Schema validators. |
224227

225228
Drift between this table and the code is caught by `pnpm audit:export-surface` — every PR that changes the public surface must refresh `.surface-snapshot.json`.
226229

@@ -308,14 +311,32 @@ const server = createServer({
308311
await server.listen(stdioTransport());
309312
```
310313

311-
Locked design (see `FHIR_COMPLIANCE_PLAN.md`):
314+
Capabilities:
312315

313-
- ~10 generic verbs typed by `resourceType` discriminated union: `read`, `vread`, `search`, `history`, `create`, `update`, `patch`, `delete`, `operation`, `capabilities`
314-
- Read-only by default; writes opt in via `writes`
315-
- Three pluggable auth strategies — `bearer` works today, `backend-services` and `patient-launch` are wired in a later phase
316-
- Pluggable `AuditSink` (`JsonLogAuditSink`, `MemoryAuditSink`, `NullAuditSink` ship by default)
317-
- Both `stdio` and Streamable HTTP transports planned (stdio only today)
318-
- `fhir://<ResourceType>/{id}` URI templates exposed via MCP `resources/list`
316+
- **~10 generic verbs** typed by `resourceType` discriminated union: `read`, `vread`, `search`, `history`, `create`, `update`, `patch`, `delete`, `operation`, `capabilities`
317+
- **Read-only by default**; writes opt in via `writes`, with optional per-resource-type allowlist (`writeResourceTypes`), `confirmWrites` (require `{confirm: true}` per call), and `dryRun` (short-circuit to a synthetic OperationOutcome)
318+
- **Three auth strategies, all wired**: `bearer`, `backend-services` (SMART v2 signed JWT — RS384 / ES384, lazy-loaded via `@fhir-dsl/smart` + `jose`), `patient-launch` (refresh-token flow with auto-rotation)
319+
- **Pluggable `AuditSink`**`JsonLogAuditSink`, `MemoryAuditSink`, `NullAuditSink` ship by default
320+
- **Token economy guards**`defaultSearchCount` (default 20), `defaultReadSummary`, and a `maxResponseBytes` cap (default 64KB) that swaps oversize bodies for a `too-costly` OperationOutcome (the audit retains the original)
321+
- **MCP resources**`fhir://<ResourceType>/{id}` URIs read via `resources/read` (and `_history/<versionId>` for vread)
322+
- **Stdio transport today**; Streamable HTTP is planned
323+
324+
### Generate a server alongside the typed client
325+
326+
```bash
327+
fhir-gen generate --version r4 --ig hl7.fhir.us.core@6.1.0 \
328+
--out ./src/fhir --mcp ./mcp-server
329+
```
330+
331+
`./mcp-server/` gets a `server.ts` shim, `mcp.config.json` seeded with the IG's resource types, and a README. Launch it with `FHIR_BASE_URL=… node server.ts`.
332+
333+
### Or run inline (no generated types):
334+
335+
```bash
336+
fhir-gen mcp https://hapi.fhir.org/baseR4 \
337+
--resources Patient,Observation \
338+
--writes create --confirm-writes --auth-bearer-env FHIR_TOKEN
339+
```
319340

320341
## CLI Reference
321342

0 commit comments

Comments
 (0)