Skip to content

CLI reference

The executable is dicom-kb. From a source checkout, prefix examples with uv run.

dicom-kb [--version] [--config PATH] COMMAND
Option Meaning
--version Print dicom-standard-kb <version> and exit.
--config PATH Load a validated YAML profile with a top-level dicom_kb mapping. Must appear before the command.
--help Show Typer help for the current command or group.

The application groups commands under lookup, iod, module, resolve, context, explain, mcp, and eval.

Terminal window
dicom-kb doctor

Prints package version and the project legal notice. It does not inspect the cache or database.

dicom-kb fetch [OPTIONS]

Fetches official artifacts or registers local DocBook XML and writes a source manifest.

Option Type/default Meaning
--edition TEXT required unless profile/environment supplies it current or a concrete 20YYx edition.
--docbook-xml PART=PATH repeatable Register a local DocBook XML file instead of official download.
--part PART repeatable; baseline set when omitted Official part to download. Input such as 6 normalizes to PS3.6.
--format FORMAT repeatable; docbook_xml when omitted docbook_xml, pdf, html, chtml, or targetdb.
--mirror-chtml-tree false Recursively mirror the selected per-part CHTML directory. Requires --format chtml.
--current-edition TEXT none Concrete edition used to resolve current when registering local artifacts.
--source-base-url URL official current URL Override the current-release base URL.
--archive-base-url URL official archive root Override the historical archive root.
--cache-dir PATH configured/default cache Local cache root.
--force false Overwrite conflicting cached artifacts and manifest.

Default DocBook parts:

PS3.3, PS3.4, PS3.5, PS3.6, PS3.7, PS3.8, PS3.10, PS3.16, PS3.18

Official current discovery requires one concrete edition to be identifiable. A concrete historical edition must appear in the official archive listing.

Output is a serialized source manifest.

dicom-kb build-fixture [OPTIONS]

Registers repository-authored synthetic fixtures and builds SQLite.

Option Default Meaning
--edition TEXT 2026b Synthetic fixture edition label.
--cache-dir PATH default cache Fixture artifact cache.
--db PATH <cache>/db/<edition>.sqlite Output database.
--force false Overwrite fixture artifacts, manifest, and database.
--max-unresolved-xref-rate FLOAT unset Fail above this 0–1 rate.
--max-unresolved-include-rate FLOAT unset Fail above this 0–1 rate.
--max-parse-warnings INTEGER unset Fail above this nonnegative count.
--allow-gate-failures false Keep exit status successful while retaining gate failures as warnings.

The command expects the repository’s tests/fixtures_synthetic tree to be available.

dicom-kb build [OPTIONS]

Builds a local SQLite knowledge base from cached DocBook artifacts.

Option Default Meaning
--edition TEXT required unless configured Concrete edition whose manifest will be loaded.
--cache-dir PATH default cache Cache containing the source manifest and artifacts.
--db PATH <cache>/db/<edition>.sqlite Output database.
--backend TEXT sqlite Storage backend. Any other value is rejected.
--force false Replace an existing target database.
quality-gate options unset Same options as build-fixture.

Output is a build summary with edition, database path, manifest digest, per-import summaries, metrics, gate failures, and warnings.

dicom-kb verify [OPTIONS]

Verifies a source manifest, artifact checksums, and optional database metadata.

Option Default Meaning
--edition TEXT required unless configured Concrete edition to verify.
--cache-dir PATH default cache Cache root.
--db PATH <cache>/db/<edition>.sqlite Database to inspect.

The command exits nonzero when top-level verification status is failed.

All query commands accept:

  • --edition TEXT;
  • --db PATH;
  • --cache-dir PATH.

When --db is absent, the path resolves from configuration or <cache>/db/<edition>.sqlite.

dicom-kb lookup tag TAG_OR_KEYWORD [OPTIONS]

Looks up a PS3.6 data element by concrete tag, range tag, or keyword.

dicom-kb lookup uid UID_OR_KEYWORD [OPTIONS]

Looks up a PS3.6 UID registry entry by UID value or keyword.

dicom-kb lookup vr VR [OPTIONS]

Looks up a two-letter PS3.5 Value Representation.

dicom-kb lookup transfer-syntax UID_OR_KEYWORD [OPTIONS]

Looks up a Transfer Syntax by UID value, name, or keyword and returns linked encoding details.

dicom-kb lookup media-type MEDIA_TYPE_OR_CONTEXT [OPTIONS]

Looks up parsed media-type constraints by media type or service context.

dicom-kb lookup dicomweb NAME_OR_ROUTE [OPTIONS]

Looks up a PS3.18 DICOMweb transaction by transaction name or route template.

dicom-kb lookup sr-template TID_OR_NAME [OPTIONS]

Looks up a PS3.16 SR template by TID or exact name.

dicom-kb lookup context-group CID_OR_NAME [OPTIONS]

Looks up a PS3.16 context group by CID or exact name.

dicom-kb lookup code CODE_VALUE [--scheme SCHEME] [OPTIONS]

Looks up a parsed PS3.16 coded concept by code value and optional coding scheme designator.

dicom-kb lookup iod IOD_NAME [OPTIONS]

Looks up a PS3.3 IOD by name or keyword.

dicom-kb lookup sop-class UID_OR_NAME_OR_KEYWORD [OPTIONS]

Looks up a PS3.4 SOP Class and linked IOD records.

dicom-kb lookup enumerated-values ATTRIBUTE [--context CONTEXT] [OPTIONS]

Looks up parsed enumerated values by attribute tag, keyword, or name. Context can narrow by exact imported module, macro, IOD, or SOP Class identity.

dicom-kb lookup defined-terms ATTRIBUTE [--context CONTEXT] [OPTIONS]

Uses the same input model as enumerated-value lookup but preserves defined_term as a distinct term kind.

dicom-kb iod modules IOD_NAME [OPTIONS]

Lists PS3.3 module-use rows for an IOD.

dicom-kb module attributes MODULE_NAME [--expand-macros | --no-expand-macros] [OPTIONS]

Lists PS3.3 attribute and include rows for a module. Macro expansion defaults to false.

dicom-kb resolve attribute-context ATTRIBUTE [--iod IOD] [--sop-class SOP_CLASS] [OPTIONS]

Resolves applicable attribute-use rows and a bounded effective type.

dicom-kb context attribute ATTRIBUTE [--iod IOD] [--sop-class SOP_CLASS] [OPTIONS]

Documented alias for the same resolver and response.

dicom-kb explain encoding TOPIC [OPTIONS]

Returns a cited PS3.5 encoding explanation for a topic, VR, or Transfer Syntax name.

dicom-kb search-text QUERY [--part PART] [--limit INTEGER] [OPTIONS]

Searches persisted DocBook text with SQLite FTS5.

Option Default
--part PART no part filter
--limit INTEGER 10
dicom-kb retrieve-text PART SECTION_OR_ANCHOR [--max-chars INTEGER] [OPTIONS]

Retrieves a bounded persisted-text excerpt by DICOM part and DocBook xml:id, HTML anchor, or section number.

--max-chars defaults to 800 unless overridden by environment or profile.

dicom-kb mcp serve --edition EDITION [--db PATH] [--cache-dir PATH]

Validates the database, registers all query tools, and runs FastMCP over stdio. MCP support requires the optional dependency.

dicom-kb eval run --out PATH [OPTIONS]

Runs committed agent-regression cases.

Option Default Meaning
--out PATH required Transcript JSON destination.
--edition TEXT required unless configured Database edition.
--db PATH default database Local knowledge base.
--cache-dir PATH default cache Cache root.
--case ID / --cases ID repeatable; all cases Select case ids.
--agent TEXT reference reference or external.
--external-command TEXT none Command receiving JSON stdin and emitting AgentRun JSON stdout.
--external-provider TEXT none Optional provider label.
--external-model TEXT none Optional model label.
--external-timeout FLOAT 300 External command timeout in seconds.
dicom-kb eval score TRANSCRIPT [OPTIONS]

Scores one run, a run list, or an object containing a top-level runs list.

Option Default Meaning
--output PATH stdout Write JSON report to a file.
--fail-on-issues / --no-fail-on-issues fail enabled Control nonzero exit when any run fails scoring.

All lookup, graph, context, explanation, and text commands serialize the common response envelope as indented JSON with null fields omitted.

status: "not_found" and status: "validation_error" are normal structured query outcomes. Operational failures such as a missing database, invalid CLI option, failed build gate, or missing MCP dependency produce a nonzero command exit.