medical-terminologies-mcp 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +171 -157
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ function unknownCursorError(message) {
30
30
  var package_default = {
31
31
  name: "medical-terminologies-mcp",
32
32
  mcpName: "io.github.SidneyBissoli/medical-terminologies-mcp",
33
- version: "2.3.0",
33
+ version: "2.4.0",
34
34
  description: "Unified MCP server for six medical terminologies (ICD-11, LOINC, RxNorm, MeSH, ATC, CID-10) with authoritative WHO ICD-10\u2192ICD-11 mapping. 33 tools, hosted endpoint available, MIT.",
35
35
  author: "Sidney da Silva Pereira Bissoli",
36
36
  license: "MIT",
@@ -90,13 +90,14 @@ var package_default = {
90
90
  "@modelcontextprotocol/server": "^2.0.0",
91
91
  "@sbissoli/mcp-provenance": "^0.4.0",
92
92
  "@sbissoli/mcp-search": "^0.9.0",
93
- "@sbissoli/mcp-upstream": "^0.4.2",
93
+ "@sbissoli/mcp-upstream": "^0.5.1",
94
94
  pino: "^10.2.1",
95
95
  zod: "^4.5.4"
96
96
  },
97
97
  devDependencies: {
98
98
  "@modelcontextprotocol/client": "^2.0.0",
99
99
  "@sbissoli/mcp-evals": "^0.2.1",
100
+ "@sbissoli/mcp-live-source": "^0.5.0",
100
101
  "@sbissoli/mcp-surface": "^0.6.0",
101
102
  "@types/node": "^26.5.1",
102
103
  esbuild: "^0.28.2",
@@ -573,8 +574,8 @@ var ICD11MatchingPVSchema = z.object({
573
574
  important: z.boolean().optional()
574
575
  });
575
576
  var ICD11SearchOutputSchema = z.object({
576
- query: z.string(),
577
- total_count: z.number().int(),
577
+ query: z.string().describe("The search text as submitted."),
578
+ total_count: z.number().int().describe("Number of entities the WHO search returned, before the max_results cap."),
578
579
  entities: z.array(
579
580
  z.object({
580
581
  code: z.string().nullable(),
@@ -584,31 +585,31 @@ var ICD11SearchOutputSchema = z.object({
584
585
  is_leaf: z.boolean(),
585
586
  matching_pvs: z.array(ICD11MatchingPVSchema)
586
587
  })
587
- )
588
+ ).describe("Matching ICD-11 MMS entities in WHO relevance order, at most max_results.")
588
589
  });
589
590
  var ICD11LabelRefSchema = z.object({
590
591
  uri: z.string(),
591
592
  label: z.string()
592
593
  });
593
594
  var ICD11LookupOutputSchema = z.object({
594
- code: z.string().nullable(),
595
- code_range: z.string().nullable(),
596
- uri: z.string(),
597
- title: z.string(),
598
- class_kind: z.string().nullable(),
599
- block_id: z.string().nullable(),
600
- definition: z.string().nullable(),
601
- long_definition: z.string().nullable(),
602
- diagnostic_criteria: z.string().nullable(),
603
- coding_note: z.string().nullable(),
604
- exclusions: z.array(ICD11LabelRefSchema),
605
- inclusions: z.array(ICD11LabelRefSchema),
606
- index_terms: z.array(ICD11LabelRefSchema),
607
- browser_url: z.string().nullable()
595
+ code: z.string().nullable().describe('ICD-11 MMS code (e.g. "BA00"); null for blocks and chapters, which have a code_range instead.'),
596
+ code_range: z.string().nullable().describe('Code range of a block or chapter (e.g. "BA00-BA0Z"); null for coded categories.'),
597
+ uri: z.string().describe("WHO ICD-11 entity URI."),
598
+ title: z.string().describe('Official title in the requested language ("Unknown" when the WHO returns none).'),
599
+ class_kind: z.string().nullable().describe('WHO class kind (e.g. "chapter", "block", "category"); null when the WHO does not state it.'),
600
+ block_id: z.string().nullable().describe("WHO block identifier for blocks; null otherwise."),
601
+ definition: z.string().nullable().describe("Official short definition; null when the WHO publishes none."),
602
+ long_definition: z.string().nullable().describe("Official detailed description; null when the WHO publishes none."),
603
+ diagnostic_criteria: z.string().nullable().describe("Official diagnostic criteria text; null when the WHO publishes none."),
604
+ coding_note: z.string().nullable().describe("Official coding note; null when the WHO publishes none."),
605
+ exclusions: z.array(ICD11LabelRefSchema).describe("Exclusion entries (conditions coded elsewhere), each with its URI and label."),
606
+ inclusions: z.array(ICD11LabelRefSchema).describe("Inclusion entries (synonyms and terms included under this entity), each with its URI and label."),
607
+ index_terms: z.array(ICD11LabelRefSchema).describe("Index terms that lead to this entity, each with its URI and label."),
608
+ browser_url: z.string().nullable().describe("Link to the entity in the WHO ICD-11 browser; null when the WHO returns none.")
608
609
  });
609
610
  var ICD11HierarchyOutputSchema = z.object({
610
- code: z.string(),
611
- direction: z.enum(["parents", "children"]),
611
+ code: z.string().describe("The code, block range or URI the walk started from, as submitted."),
612
+ direction: z.enum(["parents", "children"]).describe("Direction walked: parents (ancestors) or children (subtypes)."),
612
613
  entities: z.array(
613
614
  z.object({
614
615
  code: z.string().nullable(),
@@ -616,7 +617,7 @@ var ICD11HierarchyOutputSchema = z.object({
616
617
  title: z.string(),
617
618
  uri: z.string()
618
619
  })
619
- )
620
+ ).describe("Direct parents or children of the entity; empty when it has none. Entries the WHO failed to return are left out.")
620
621
  });
621
622
  var ICD11ChaptersOutputSchema = z.object({
622
623
  chapters: z.array(
@@ -628,10 +629,10 @@ var ICD11ChaptersOutputSchema = z.object({
628
629
  title: z.string().nullable(),
629
630
  error: z.string().nullable()
630
631
  })
631
- )
632
+ ).describe("Top-level ICD-11 MMS chapters in WHO order; a chapter the WHO failed to return keeps its number and URI, with error set and the other fields null.")
632
633
  });
633
634
  var ICD11PostcoordinationOutputSchema = z.object({
634
- code: z.string(),
635
+ code: z.string().describe("The ICD-11 code as submitted."),
635
636
  axes: z.array(
636
637
  z.object({
637
638
  axis_name: z.string(),
@@ -639,7 +640,7 @@ var ICD11PostcoordinationOutputSchema = z.object({
639
640
  allow_multiple: z.boolean(),
640
641
  value_count: z.number().int().nullable()
641
642
  })
642
- )
643
+ ).describe("Postcoordination axes the WHO allows for this code; empty when it has none or the WHO has no postcoordination info for it.")
643
644
  });
644
645
  var LOINCSearchParamsSchema = z.object({
645
646
  query: z.string().min(1).describe("Search term (test name, keyword, or partial LOINC code)"),
@@ -649,32 +650,32 @@ var LOINCByCodeParamsSchema = z.object({
649
650
  loinc_num: LOINCNumberSchema.describe('LOINC number (e.g., "2339-0")')
650
651
  }).strict();
651
652
  var LOINCItemOutputSchema = z.object({
652
- loinc_num: z.string(),
653
- long_common_name: z.string(),
654
- short_name: z.string(),
655
- component: z.string(),
656
- property: z.string(),
657
- time_aspect: z.string(),
658
- system: z.string(),
659
- scale_type: z.string(),
660
- method_type: z.string(),
661
- class: z.string(),
662
- status: z.string(),
653
+ loinc_num: z.string().describe('LOINC number (e.g. "2339-0").'),
654
+ long_common_name: z.string().describe("LOINC Long Common Name, the full human-readable name of the term."),
655
+ short_name: z.string().describe("LOINC short name; empty when the source has none."),
656
+ component: z.string().describe('LOINC axis 1, Component: what is measured or observed (e.g. "Glucose").'),
657
+ property: z.string().describe('LOINC axis 2, Property: the kind of quantity (e.g. "MCnc" = mass concentration).'),
658
+ time_aspect: z.string().describe('LOINC axis 3, Time: point in time or interval of the observation (e.g. "Pt", "24H").'),
659
+ system: z.string().describe('LOINC axis 4, System: the specimen or thing observed (e.g. "Bld", "Ser/Plas").'),
660
+ scale_type: z.string().describe("LOINC axis 5, Scale: Qn (quantitative), Ord, Nom, Nar, etc."),
661
+ method_type: z.string().describe("LOINC axis 6, Method; empty when the term specifies none."),
662
+ class: z.string().describe('LOINC class the term is grouped under (e.g. "CHEM").'),
663
+ status: z.string().describe('LOINC term status (e.g. "ACTIVE", "DEPRECATED"); empty when the source omits it.'),
663
664
  // LOINC License §10 pass-through: some LOINC terms carry third-party
664
665
  // copyright (e.g. survey instruments like PHQ-9). When Clinical Tables
665
666
  // exposes EXTERNAL_COPYRIGHT_NOTICE for a term, it is served verbatim
666
667
  // alongside the term; null when the term carries none.
667
- external_copyright_notice: z.string().nullable()
668
+ external_copyright_notice: z.string().nullable().describe("Third-party copyright notice the term carries, served verbatim (LOINC License \xA710); null when it carries none.")
668
669
  });
669
670
  var LOINCSearchOutputSchema = z.object({
670
- query: z.string(),
671
- total_count: z.number().int(),
672
- shown_count: z.number().int(),
673
- items: z.array(LOINCItemOutputSchema)
671
+ query: z.string().describe("The search term as submitted."),
672
+ total_count: z.number().int().describe("Total number of LOINC terms matching the query at the source, which may exceed the items returned."),
673
+ shown_count: z.number().int().describe("Number of terms returned in items (at most max_results)."),
674
+ items: z.array(LOINCItemOutputSchema).describe("Matching LOINC terms in source relevance order.")
674
675
  });
675
676
  var LOINCDetailsOutputSchema = LOINCItemOutputSchema;
676
677
  var LOINCAnswersOutputSchema = z.object({
677
- loinc_num: z.string(),
678
+ loinc_num: z.string().describe("The LOINC number as submitted."),
678
679
  answers: z.array(
679
680
  z.object({
680
681
  sequence: z.number().int().describe("Display order in the answer list (1-based)."),
@@ -682,7 +683,7 @@ var LOINCAnswersOutputSchema = z.object({
682
683
  answer_string: z.string(),
683
684
  score: z.number().nullable().describe("Numeric score for scored instruments (PHQ-9 items: 0-3); null when the answer list carries none.")
684
685
  })
685
- )
686
+ ).describe("Answer list of the question in display order; empty when the code exists but has no answer list.")
686
687
  });
687
688
  var LOINCPanelOutputSchema = z.object({
688
689
  loinc_num: z.string(),
@@ -697,8 +698,8 @@ var LOINCPanelOutputSchema = z.object({
697
698
  )
698
699
  });
699
700
  var LOINCPanelsOutputSchema = z.object({
700
- loinc_num: z.string(),
701
- panel: LOINCPanelOutputSchema.nullable()
701
+ loinc_num: z.string().describe("The LOINC number as submitted."),
702
+ panel: LOINCPanelOutputSchema.nullable().describe("Panel/form definition with its member items; null when no panel structure is found for the code (not a panel, or no definition available).")
702
703
  });
703
704
  var RxNormSearchParamsSchema = z.object({
704
705
  query: z.string().min(1).describe("Drug name to search (brand or generic)"),
@@ -725,28 +726,28 @@ var RxNormDrugOutputSchema = z.object({
725
726
  language: z.string()
726
727
  });
727
728
  var RxNormSearchOutputSchema = z.object({
728
- query: z.string(),
729
- total_count: z.number().int(),
729
+ query: z.string().describe("The drug name as submitted."),
730
+ total_count: z.number().int().describe("Number of concepts RxNav returned for the name, before the max_results cap."),
730
731
  // tty === 'APPROX' on items signals the search used the approximate-match
731
732
  // fallback rather than an exact name match.
732
- drugs: z.array(RxNormDrugOutputSchema)
733
+ drugs: z.array(RxNormDrugOutputSchema).describe('Matching RxNorm concepts, at most max_results. tty "APPROX" marks results of the approximate-match fallback, used when the name matched nothing exactly.')
733
734
  });
734
735
  var RxNormConceptOutputSchema = z.object({
735
- rxcui: z.string(),
736
+ rxcui: z.string().describe("The RxCUI looked up."),
736
737
  // An RxCUI that RxNorm does not have is an ANSWER, not an error (since
737
738
  // 1.16.0; the siblings already say so: rxnorm_search with total_count 0,
738
739
  // rxnorm_ingredients/classes/ndc with an empty list, atc_lookup with
739
740
  // found:false). found=false ⇒ every concept field below is null,
740
741
  // remapped_to is [] and related_groups is null.
741
742
  found: z.boolean().describe("false when RxNorm has no concept with this RxCUI (the lookup answered; the fields below are null)"),
742
- name: z.string().nullable(),
743
- synonym: z.string().nullable(),
744
- tty: z.string().nullable(),
745
- language: z.string().nullable(),
746
- suppress: z.string().nullable(),
747
- umlscui: z.string().nullable(),
748
- status: z.string().nullable(),
749
- remapped_to: z.array(z.string()),
743
+ name: z.string().nullable().describe("RxNorm normalized name of the concept; null when found=false."),
744
+ synonym: z.string().nullable().describe("RxNorm synonym (may be empty); null when found=false."),
745
+ tty: z.string().nullable().describe('RxNorm term type (e.g. "IN" ingredient, "SCD" clinical drug, "SBD" branded drug); null when found=false.'),
746
+ language: z.string().nullable().describe('Language of the concept name as RxNav reports it (e.g. "ENG"); null when found=false.'),
747
+ suppress: z.string().nullable().describe('RxNorm suppress flag ("N" = not suppressed, the default when RxNav omits it); null when found=false.'),
748
+ umlscui: z.string().nullable().describe("UMLS Concept Unique Identifier linked to the concept (empty when none); null when found=false."),
749
+ status: z.string().nullable().describe('RxNorm history status (e.g. "Active", "Remapped", "Obsolete"); "Active" when RxNav does not report one; null when found=false.'),
750
+ remapped_to: z.array(z.string()).describe("RxCUIs a remapped concept was replaced by; empty otherwise."),
750
751
  // Populated only when include_related=true; null when the caller didn't
751
752
  // ask for related concepts so the field's absence vs emptiness is
752
753
  // unambiguous.
@@ -755,10 +756,10 @@ var RxNormConceptOutputSchema = z.object({
755
756
  tty: z.string(),
756
757
  concepts: z.array(RxNormDrugOutputSchema)
757
758
  })
758
- ).nullable()
759
+ ).nullable().describe("Related concepts (ingredients, brands, dose forms) grouped by term type; null unless include_related=true.")
759
760
  });
760
761
  var RxNormIngredientsOutputSchema = z.object({
761
- rxcui: z.string(),
762
+ rxcui: z.string().describe("The RxCUI as submitted."),
762
763
  ingredients: z.array(
763
764
  z.object({
764
765
  rxcui: z.string(),
@@ -766,10 +767,10 @@ var RxNormIngredientsOutputSchema = z.object({
766
767
  tty: z.string(),
767
768
  is_multiple: z.boolean()
768
769
  })
769
- )
770
+ ).describe("Ingredient concepts (term types IN and MIN) RxNav relates to the RxCUI; empty when none.")
770
771
  });
771
772
  var RxNormClassesOutputSchema = z.object({
772
- rxcui: z.string(),
773
+ rxcui: z.string().describe("The RxCUI as submitted."),
773
774
  classes: z.array(
774
775
  z.object({
775
776
  class_id: z.string(),
@@ -777,15 +778,15 @@ var RxNormClassesOutputSchema = z.object({
777
778
  class_type: z.string(),
778
779
  source: z.string()
779
780
  })
780
- )
781
+ ).describe("Drug classes NLM RxClass links to the RxCUI (one entry per class and relationship); empty when none.")
781
782
  });
782
783
  var RxNormNDCOutputSchema = z.object({
783
784
  // 'ndcs_for_rxcui': rxcui populated, ndc null, ndcs = list.
784
785
  // 'rxcui_for_ndc': ndc populated, rxcui = found ID or null, ndcs = [].
785
- query_mode: z.enum(["ndcs_for_rxcui", "rxcui_for_ndc"]),
786
- rxcui: z.string().nullable(),
787
- ndc: z.string().nullable(),
788
- ndcs: z.array(z.object({ ndc: z.string() }))
786
+ query_mode: z.enum(["ndcs_for_rxcui", "rxcui_for_ndc"]).describe("Which lookup ran: ndcs_for_rxcui (rxcui given, list its NDCs) or rxcui_for_ndc (ndc given, find its RxCUI)."),
787
+ rxcui: z.string().nullable().describe("ndcs_for_rxcui: the RxCUI as submitted. rxcui_for_ndc: the RxCUI the NDC belongs to, or null when RxNorm has none for it."),
788
+ ndc: z.string().nullable().describe("rxcui_for_ndc: the NDC as submitted; null in ndcs_for_rxcui mode."),
789
+ ndcs: z.array(z.object({ ndc: z.string() })).describe("ndcs_for_rxcui: NDC codes RxNorm lists for the RxCUI (empty when none); always empty in rxcui_for_ndc mode.")
789
790
  });
790
791
  var MeSHSearchParamsSchema = z.object({
791
792
  query: z.string().min(1).describe('Search term (e.g., "diabetes", "heart failure")'),
@@ -810,23 +811,23 @@ var MeSHQualifierOutputSchema = z.object({
810
811
  label: z.string()
811
812
  });
812
813
  var MeSHSearchOutputSchema = z.object({
813
- query: z.string(),
814
- match: z.enum(["exact", "contains", "startswith"]),
815
- total_count: z.number().int(),
814
+ query: z.string().describe("The search term as submitted."),
815
+ match: z.enum(["exact", "contains", "startswith"]).describe("Match type applied to descriptor labels."),
816
+ total_count: z.number().int().describe("Number of descriptors returned (the NLM lookup is capped at max_results, so this is not a total count of all matches)."),
816
817
  descriptors: z.array(
817
818
  z.object({
818
819
  id: z.string(),
819
820
  uri: z.string(),
820
821
  label: z.string()
821
822
  })
822
- )
823
+ ).describe('Matching MeSH descriptors, each with its ID (e.g. "D003920"), URI and label.')
823
824
  });
824
825
  var MeSHDescriptorOutputSchema = z.object({
825
- id: z.string(),
826
- uri: z.string(),
827
- label: z.string(),
828
- scope_note: z.string(),
829
- tree_numbers: z.array(MeSHTreeNumberOutputSchema),
826
+ id: z.string().describe('MeSH descriptor ID (e.g. "D003920").'),
827
+ uri: z.string().describe("NLM MeSH RDF URI of the descriptor."),
828
+ label: z.string().describe("Descriptor heading, in the requested language when NLM publishes that translation."),
829
+ scope_note: z.string().describe("Scope note (definition) of the descriptor's preferred concept; empty when it has none."),
830
+ tree_numbers: z.array(MeSHTreeNumberOutputSchema).describe('Tree numbers placing the descriptor in the MeSH hierarchy (e.g. "C18.452.394.750").'),
830
831
  concepts: z.array(
831
832
  z.object({
832
833
  uri: z.string(),
@@ -834,16 +835,16 @@ var MeSHDescriptorOutputSchema = z.object({
834
835
  is_preferred: z.boolean(),
835
836
  terms: z.array(z.string())
836
837
  })
837
- ),
838
- qualifiers: z.array(MeSHQualifierOutputSchema)
838
+ ).describe("The preferred concept with its entry terms (synonyms); non-preferred concepts are not retrieved. Empty when the descriptor names no preferred concept."),
839
+ qualifiers: z.array(MeSHQualifierOutputSchema).describe("Allowable qualifiers (subheadings) for the descriptor.")
839
840
  });
840
841
  var MeSHTreeOutputSchema = z.object({
841
- mesh_id: z.string(),
842
- tree_numbers: z.array(MeSHTreeNumberOutputSchema)
842
+ mesh_id: z.string().describe("The MeSH descriptor ID as submitted."),
843
+ tree_numbers: z.array(MeSHTreeNumberOutputSchema).describe("Tree numbers placing the descriptor in the MeSH hierarchy; a descriptor can sit in several branches.")
843
844
  });
844
845
  var MeSHQualifiersOutputSchema = z.object({
845
- mesh_id: z.string(),
846
- qualifiers: z.array(MeSHQualifierOutputSchema)
846
+ mesh_id: z.string().describe("The MeSH descriptor ID as submitted."),
847
+ qualifiers: z.array(MeSHQualifierOutputSchema).describe("Allowable qualifiers (subheadings) for the descriptor, each with its ID, URI and label.")
847
848
  });
848
849
  var MapICD10ToICD11ParamsSchema = z.object({
849
850
  icd10_code: z.string().min(1).describe("ICD-10 code to query in the ICD-11 search index (e.g., E11, I21.0, J18.9)")
@@ -876,12 +877,12 @@ var FindEquivalentItemSchema = z.object({
876
877
  rank: z.number().int().min(1)
877
878
  });
878
879
  var FindEquivalentTerminologyResultSchema = z.object({
879
- found: z.boolean(),
880
+ found: z.boolean().describe("True when this terminology returned at least one candidate."),
880
881
  // Populated when the upstream call failed (timeout, server error).
881
- error: z.string().nullable(),
882
+ error: z.string().nullable().describe("Failure message when the search in this terminology failed (timeout, server error); null when it answered."),
882
883
  // Sorted by match_score descending (i.e. by global rank) since v1.7.0;
883
884
  // before that the order was whatever the upstream returned.
884
- items: z.array(FindEquivalentItemSchema)
885
+ items: z.array(FindEquivalentItemSchema).describe("Candidates from this terminology, best first (by global rank), at most limit.")
885
886
  });
886
887
  var FindEquivalentGroupMemberSchema = z.object({
887
888
  terminology: TerminologyEnum,
@@ -897,27 +898,27 @@ var FindEquivalentGroupSchema = z.object({
897
898
  members: z.array(FindEquivalentGroupMemberSchema)
898
899
  });
899
900
  var FindEquivalentOutputSchema = z.object({
900
- term: z.string(),
901
- source_terminology: TerminologyEnum.nullable(),
902
- searched_terminologies: z.array(TerminologyEnum),
901
+ term: z.string().describe("The medical term as submitted."),
902
+ source_terminology: TerminologyEnum.nullable().describe("Terminology excluded from the search; null when none was given."),
903
+ searched_terminologies: z.array(TerminologyEnum).describe("Terminologies actually searched: the targets minus source_terminology. Empty when nothing was left to search."),
903
904
  // Each terminology key is present only if it was actually searched (i.e.
904
905
  // it's in searched_terminologies). Absent keys mean "not requested",
905
906
  // empty items+found:false means "searched, no hits".
906
907
  results: z.object({
907
- icd11: FindEquivalentTerminologyResultSchema.optional(),
908
- loinc: FindEquivalentTerminologyResultSchema.optional(),
909
- rxnorm: FindEquivalentTerminologyResultSchema.optional(),
910
- mesh: FindEquivalentTerminologyResultSchema.optional()
911
- }),
908
+ icd11: FindEquivalentTerminologyResultSchema.optional().describe("ICD-11 (WHO) candidates; present only when ICD-11 was searched."),
909
+ loinc: FindEquivalentTerminologyResultSchema.optional().describe("LOINC candidates; present only when LOINC was searched."),
910
+ rxnorm: FindEquivalentTerminologyResultSchema.optional().describe("RxNorm candidates; present only when RxNorm was searched."),
911
+ mesh: FindEquivalentTerminologyResultSchema.optional().describe("MeSH candidates; present only when MeSH was searched.")
912
+ }).describe("Per-terminology results, keyed by terminology. A key is absent when that terminology was not searched; found=false with empty items and error null means searched, no hits."),
912
913
  // Groups of lexically identical candidates across terminologies, sorted
913
914
  // by best member match_score. Empty when nothing groups.
914
- groups: z.array(FindEquivalentGroupSchema),
915
+ groups: z.array(FindEquivalentGroupSchema).describe("Candidates from different terminologies whose normalized titles are identical, grouped as likely the same concept; best match_score first. Empty when nothing groups (not evidence of non-equivalence)."),
915
916
  // Self-description of the server-side ranking so consumers know the
916
917
  // scores are derived here, not upstream relevance.
917
918
  ranking: z.object({
918
- method: z.literal("lexical"),
919
- note: z.string()
920
- })
919
+ method: z.literal("lexical").describe("Ranking method: lexical similarity computed by this server."),
920
+ note: z.string().describe("How match_score and rank are computed.")
921
+ }).describe("Self-description of the ranking: match_score, rank and groups are computed by this server, not upstream relevance.")
921
922
  });
922
923
  var ICD10SourceSchema = z.object({
923
924
  code: z.string(),
@@ -946,7 +947,7 @@ var MapICD10ToICD11OutputSchema = z.object({
946
947
  publisher: z.string().describe('Authoritative publisher (e.g. "WHO").'),
947
948
  version: z.string().describe('Transition table release identifier (e.g. "2025-01").'),
948
949
  release_date: z.string().describe("ISO date string for the release.")
949
- })
950
+ }).describe("The bundled WHO ICD-10 \u2192 ICD-11 transition table release this answer comes from.")
950
951
  });
951
952
  var ValidateCodesTerminologyEnum = z.enum([
952
953
  "icd11",
@@ -987,7 +988,7 @@ var ValidateCodesOutputSchema = z.object({
987
988
  valid_count: z.number().int().describe("How many were confirmed valid."),
988
989
  invalid_count: z.number().int().describe("How many were not found."),
989
990
  error_count: z.number().int().describe("How many couldn't be validated due to upstream/network errors."),
990
- results: z.array(ValidateCodesResultSchema)
991
+ results: z.array(ValidateCodesResultSchema).describe("One entry per submitted code, in request order.")
991
992
  });
992
993
  var HARMONIZE_MAX_TERMS = 50;
993
994
  var HarmonizeDomainEnum = z.enum(["diagnosis", "drug", "lab"]).describe(
@@ -1035,20 +1036,20 @@ var HarmonizeTermsOutputSchema = z.object({
1035
1036
  total: z.number().int().describe("Terms submitted."),
1036
1037
  unique_lookups: z.number().int().describe("Distinct term+domain pairs actually looked up."),
1037
1038
  counts: z.object({
1038
- exact: z.number().int(),
1039
- strong: z.number().int(),
1040
- needs_review: z.number().int(),
1041
- no_candidates: z.number().int(),
1042
- error: z.number().int()
1043
- }),
1039
+ exact: z.number().int().describe("Terms whose best candidate is an exact match."),
1040
+ strong: z.number().int().describe("Terms whose best candidate is a strong match."),
1041
+ needs_review: z.number().int().describe("Terms whose best candidate needs review."),
1042
+ no_candidates: z.number().int().describe("Terms the source answered with no candidates."),
1043
+ error: z.number().int().describe("Terms whose lookup failed.")
1044
+ }).describe("Submitted terms tallied by outcome (best-candidate match_type, no candidates, or error); the five counts add up to total."),
1044
1045
  results: z.array(HarmonizeResultSchema).describe("One entry per submitted term, in request order."),
1045
1046
  // Same self-description as find_equivalent: match_score and match_type are
1046
1047
  // computed here, not upstream relevance (the concise provenance block does
1047
1048
  // not carry `derived`, so the method travels in the payload).
1048
1049
  ranking: z.object({
1049
- method: z.literal("lexical"),
1050
- note: z.string()
1051
- })
1050
+ method: z.literal("lexical").describe("Ranking method: lexical similarity computed by this server."),
1051
+ note: z.string().describe("How match_score and match_type are computed.")
1052
+ }).describe("Self-description of the ranking: match_score and match_type are computed by this server, not upstream relevance.")
1052
1053
  });
1053
1054
  var TerminologyVersionsParamsSchema = z.object({
1054
1055
  terminology: ValidateCodesTerminologyEnum.optional().describe("Filter to a single terminology. Omit to return all 7.")
@@ -1068,8 +1069,8 @@ var TerminologyVersionEntrySchema = z.object({
1068
1069
  });
1069
1070
  var TerminologyVersionsOutputSchema = z.object({
1070
1071
  generated: z.string().describe("Date this snapshot was generated."),
1071
- total: z.number().int(),
1072
- terminologies: z.array(TerminologyVersionEntrySchema)
1072
+ total: z.number().int().describe("Number of terminologies listed."),
1073
+ terminologies: z.array(TerminologyVersionEntrySchema).describe("Release this server queries for each terminology (all 7, or the one requested): publisher, current version, release date, update cadence, source and changelog links, and whether the data is bundled in the server.")
1073
1074
  });
1074
1075
  var TerminologyDiffParamsSchema = z.object({
1075
1076
  terminology: ValidateCodesTerminologyEnum.describe("Which terminology to report on."),
@@ -1083,15 +1084,15 @@ var CrossRevisionSummarySchema = z.object({
1083
1084
  avg_alternatives_when_split: z.number()
1084
1085
  });
1085
1086
  var TerminologyDiffOutputSchema = z.object({
1086
- terminology: ValidateCodesTerminologyEnum,
1087
- from_version: z.string().nullable(),
1088
- to_version: z.string().nullable(),
1087
+ terminology: ValidateCodesTerminologyEnum.describe("The terminology reported on, as submitted."),
1088
+ from_version: z.string().nullable().describe("The from_version requested (for icd10, the bundled ICD-10 release when not given); null when not given."),
1089
+ to_version: z.string().nullable().describe("The to_version requested; null when not given."),
1089
1090
  diff_available: z.boolean().describe(
1090
1091
  "True when this server has the data to compute a real diff for the requested terminology. False = guidance-only response."
1091
1092
  ),
1092
- message: z.string(),
1093
- changelog_url: z.string().nullable(),
1094
- bundled_versions: z.array(z.string()),
1093
+ message: z.string().describe("Explanation of the answer: what was computed, or why no diff is available and where to look instead."),
1094
+ changelog_url: z.string().nullable().describe("Publisher's official changelog for the terminology; null when none is known."),
1095
+ bundled_versions: z.array(z.string()).describe("Versions of this terminology bundled in the server; empty when the server queries the live upstream."),
1095
1096
  cross_revision_summary: CrossRevisionSummarySchema.nullable().describe(
1096
1097
  'Populated only for terminology="icd10" today \u2014 the bundled WHO ICD-10 \u2192 ICD-11 transition tables let us surface a real structural diff between the two WHO revisions.'
1097
1098
  )
@@ -1119,7 +1120,7 @@ var ATCClassEntrySchema = z.object({
1119
1120
  atc_level_type: z.string()
1120
1121
  });
1121
1122
  var ATCClassifyOutputSchema = z.object({
1122
- drug_name: z.string(),
1123
+ drug_name: z.string().describe("The drug name as submitted."),
1123
1124
  matches: z.array(
1124
1125
  z.object({
1125
1126
  rxcui: z.string(),
@@ -1129,17 +1130,17 @@ var ATCClassifyOutputSchema = z.object({
1129
1130
  atc_name: z.string(),
1130
1131
  atc_level_type: z.string()
1131
1132
  })
1132
- )
1133
+ ).describe("ATC classes NLM RxClass assigns to the drug, one entry per RxNorm concept and ATC class pair; empty when the drug is unknown or has no ATC mapping.")
1133
1134
  });
1134
1135
  var ATCLookupOutputSchema = z.object({
1135
- atc_code: z.string(),
1136
- found: z.boolean(),
1136
+ atc_code: z.string().describe("The ATC code as submitted."),
1137
+ found: z.boolean().describe("Whether RxClass knows the code at level 1-4; false for unknown and for 7-character substance codes."),
1137
1138
  // Populated when found=true. Null when the code is unknown or
1138
1139
  // substance-level (RxClass byId doesn't expose the 7-char codes).
1139
- details: ATCClassEntrySchema.nullable()
1140
+ details: ATCClassEntrySchema.nullable().describe("The ATC class (code, name, level type); null when found=false.")
1140
1141
  });
1141
1142
  var ATCMembersOutputSchema = z.object({
1142
- atc_code: z.string(),
1143
+ atc_code: z.string().describe("The ATC code as submitted."),
1143
1144
  members: z.array(
1144
1145
  z.object({
1145
1146
  rxcui: z.string(),
@@ -1149,7 +1150,7 @@ var ATCMembersOutputSchema = z.object({
1149
1150
  // When the queried class is at level 5, this matches atc_code.
1150
1151
  source_atc_code: z.string()
1151
1152
  })
1152
- )
1153
+ ).describe("RxNorm drug concepts in the ATC class (all member substances for levels 1-4); empty when the code is unknown or has no RxNorm-mapped members.")
1153
1154
  });
1154
1155
  var CID10CodeSchema = z.string().regex(
1155
1156
  /^[A-Z]\d{2}(\.?\d)?$/i,
@@ -1200,36 +1201,36 @@ var CID10HitSchema = z.object({
1200
1201
  group_range: z.string().nullable()
1201
1202
  });
1202
1203
  var CID10SearchOutputSchema = z.object({
1203
- query: z.string(),
1204
- level: z.enum(["categories", "subcategories", "all"]),
1205
- total_count: z.number().int(),
1206
- shown_count: z.number().int(),
1207
- hits: z.array(CID10HitSchema),
1204
+ query: z.string().describe("The search terms as submitted."),
1205
+ level: z.enum(["categories", "subcategories", "all"]).describe("Code level searched: 3-char categories, 4-char subcategories, or all."),
1206
+ total_count: z.number().int().describe("Number of CID-10 codes matching the query, before the max_results cap."),
1207
+ shown_count: z.number().int().describe("Number of codes returned in hits (at most max_results)."),
1208
+ hits: z.array(CID10HitSchema).describe("Matching CID-10 V2008 codes with their Portuguese titles, chapter and group."),
1208
1209
  // Present only when a query word was translated to the CID-10's own wording
1209
1210
  // ("câncer" → "neoplasia maligna"); says which (src/clients/cid10-vocabulary.ts).
1210
- vocabulary_notes: z.array(z.string()).optional()
1211
+ vocabulary_notes: z.array(z.string()).optional().describe(`Present only when a query word was translated to the CID-10's own wording (e.g. "c\xE2ncer" \u2192 "neoplasia maligna"); says which.`)
1211
1212
  });
1212
1213
  var CID10LookupOutputSchema = z.object({
1213
- code: z.string(),
1214
- found: z.boolean(),
1214
+ code: z.string().describe("The CID-10 code as submitted."),
1215
+ found: z.boolean().describe("Whether the code exists in CID-10 V2008."),
1215
1216
  // Populated when found=true; null otherwise.
1216
- hit: CID10HitSchema.nullable()
1217
+ hit: CID10HitSchema.nullable().describe("The CID-10 entry (Portuguese title, chapter, group, restrictions); null when found=false.")
1217
1218
  });
1218
1219
  var CID10ChaptersOutputSchema = z.object({
1219
- chapters: z.array(CID10ChapterEntrySchema)
1220
+ chapters: z.array(CID10ChapterEntrySchema).describe("The 22 chapters of CID-10 V2008, each with its number, code range and Portuguese title.")
1220
1221
  });
1221
1222
  var CID10ChapterDetailOutputSchema = z.object({
1222
- num: z.number().int(),
1223
- found: z.boolean(),
1224
- chapter: CID10ChapterEntrySchema.nullable(),
1225
- groups: z.array(CID10GroupEntrySchema)
1223
+ num: z.number().int().describe("The chapter number as submitted."),
1224
+ found: z.boolean().describe("Whether the chapter exists in CID-10 V2008."),
1225
+ chapter: CID10ChapterEntrySchema.nullable().describe("The chapter (number, code range, Portuguese title); null when found=false."),
1226
+ groups: z.array(CID10GroupEntrySchema).describe("Groups (code-range blocks) of the chapter, each with its range and Portuguese title; empty when found=false.")
1226
1227
  });
1227
1228
  var CID10ChapterParamsSchema = z.object({
1228
1229
  num: z.number().int().min(1).max(22).describe("Chapter number (1-22). CID-10 V2008 has 22 chapters.")
1229
1230
  }).strict();
1230
1231
  var ApiError = class extends Error {
1231
- constructor(message, code, statusCode, details) {
1232
- super(message);
1232
+ constructor(message, code, statusCode, details, options) {
1233
+ super(message, options?.cause === void 0 ? void 0 : { cause: options.cause });
1233
1234
  this.code = code;
1234
1235
  this.statusCode = statusCode;
1235
1236
  this.details = details;
@@ -1332,8 +1333,16 @@ import { UpstreamError } from "@sbissoli/mcp-upstream";
1332
1333
  var HttpError = class extends Error {
1333
1334
  status;
1334
1335
  data;
1336
+ /**
1337
+ * `cause` is the package's `UpstreamError` (since piece 4 of
1338
+ * `mcp:fonte-indisponivel-nao-e-deriva`, 2026-10-22): the live contract
1339
+ * test reads the origin's `kind` through the `cause` chain
1340
+ * (`@sbissoli/mcp-live-source`) to tell "the source is down" (test
1341
+ * skipped, warning) from "the source changed" (red). The clients keep the
1342
+ * chain by passing this error as `cause` of their `ApiError`.
1343
+ */
1335
1344
  constructor(message, opts = {}) {
1336
- super(message);
1345
+ super(message, opts.cause === void 0 ? void 0 : { cause: opts.cause });
1337
1346
  this.name = "HttpError";
1338
1347
  this.status = opts.status;
1339
1348
  this.data = opts.data;
@@ -1366,19 +1375,20 @@ function describeFetchFailure(error) {
1366
1375
  async function translateUpstreamError(error, timeoutMs) {
1367
1376
  if (!(error instanceof UpstreamError)) return error;
1368
1377
  const after = error.attempts > 1 ? ` (after ${error.attempts} attempts)` : "";
1378
+ const cause = error;
1369
1379
  switch (error.kind) {
1370
1380
  case "timeout":
1371
- return new HttpError(`timeout of ${timeoutMs}ms exceeded${after}`);
1381
+ return new HttpError(`timeout of ${timeoutMs}ms exceeded${after}`, { cause });
1372
1382
  case "network":
1373
- return new HttpError(`${describeFetchFailure(error.cause)}${after}`);
1383
+ return new HttpError(`${describeFetchFailure(error.cause)}${after}`, { cause });
1374
1384
  case "aborted":
1375
- return new HttpError(`request aborted${after}`);
1385
+ return new HttpError(`request aborted${after}`, { cause });
1376
1386
  case "malformed_body":
1377
- return new HttpError(`malformed upstream response${after}`, { status: error.status });
1387
+ return new HttpError(`malformed upstream response${after}`, { status: error.status, cause });
1378
1388
  default: {
1379
1389
  const status = error.status ?? error.response?.status;
1380
1390
  const data = parseBody(error.body);
1381
- return new HttpError(`Request failed with status code ${status}${after}`, { status, data });
1391
+ return new HttpError(`Request failed with status code ${status}${after}`, { status, data, cause });
1382
1392
  }
1383
1393
  }
1384
1394
  }
@@ -1744,19 +1754,20 @@ var WHOClient = class {
1744
1754
  log.error({ status, data: responseData }, "HTTP error response");
1745
1755
  if (status === 401) {
1746
1756
  cache.delete(CACHE_PREFIX.TOKEN, TOKEN_CACHE_KEY);
1747
- throw new ApiError("Authentication failed - token expired", "AUTH_EXPIRED", status);
1757
+ throw new ApiError("Authentication failed - token expired", "AUTH_EXPIRED", status, void 0, { cause: error });
1748
1758
  }
1749
1759
  if (status === 404) {
1750
- throw new ApiError(`Resource not found: ${path}`, "NOT_FOUND", status);
1760
+ throw new ApiError(`Resource not found: ${path}`, "NOT_FOUND", status, void 0, { cause: error });
1751
1761
  }
1752
1762
  if (status === 429) {
1753
- throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status);
1763
+ throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status, void 0, { cause: error });
1754
1764
  }
1755
1765
  throw new ApiError(
1756
1766
  `WHO API error: ${message}`,
1757
1767
  "API_ERROR",
1758
1768
  status,
1759
- error.data
1769
+ error.data,
1770
+ { cause: error }
1760
1771
  );
1761
1772
  }
1762
1773
  throw error;
@@ -2763,16 +2774,17 @@ var NLMClient = class {
2763
2774
  const status = error.status;
2764
2775
  const message = extractErrorMessage(error);
2765
2776
  if (status === 404) {
2766
- throw new ApiError(`Resource not found`, "NOT_FOUND", status);
2777
+ throw new ApiError(`Resource not found`, "NOT_FOUND", status, void 0, { cause: error });
2767
2778
  }
2768
2779
  if (status === 429) {
2769
- throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status);
2780
+ throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status, void 0, { cause: error });
2770
2781
  }
2771
2782
  throw new ApiError(
2772
2783
  `NLM API error: ${message}`,
2773
2784
  "API_ERROR",
2774
2785
  status,
2775
- error.data
2786
+ error.data,
2787
+ { cause: error }
2776
2788
  );
2777
2789
  }
2778
2790
  throw error;
@@ -3303,16 +3315,17 @@ var RxNormClient = class {
3303
3315
  const status = error.status;
3304
3316
  const message = extractErrorMessage(error);
3305
3317
  if (status === 404) {
3306
- throw new ApiError(`Resource not found`, "NOT_FOUND", status);
3318
+ throw new ApiError(`Resource not found`, "NOT_FOUND", status, void 0, { cause: error });
3307
3319
  }
3308
3320
  if (status === 429) {
3309
- throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status);
3321
+ throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status, void 0, { cause: error });
3310
3322
  }
3311
3323
  throw new ApiError(
3312
3324
  `RxNorm API error: ${message}`,
3313
3325
  "API_ERROR",
3314
3326
  status,
3315
- error.data
3327
+ error.data,
3328
+ { cause: error }
3316
3329
  );
3317
3330
  }
3318
3331
  throw error;
@@ -4192,16 +4205,17 @@ var MeSHClient = class {
4192
4205
  const status = error.status;
4193
4206
  const message = extractErrorMessage(error);
4194
4207
  if (status === 404) {
4195
- throw new ApiError("Resource not found", "NOT_FOUND", status);
4208
+ throw new ApiError("Resource not found", "NOT_FOUND", status, void 0, { cause: error });
4196
4209
  }
4197
4210
  if (status === 429) {
4198
- throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status);
4211
+ throw new ApiError("Rate limit exceeded", "RATE_LIMIT", status, void 0, { cause: error });
4199
4212
  }
4200
4213
  throw new ApiError(
4201
4214
  `MeSH API error: ${message}`,
4202
4215
  "API_ERROR",
4203
4216
  status,
4204
- error.data
4217
+ error.data,
4218
+ { cause: error }
4205
4219
  );
4206
4220
  }
4207
4221
  throw error;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "medical-terminologies-mcp",
3
3
  "mcpName": "io.github.SidneyBissoli/medical-terminologies-mcp",
4
- "version": "2.3.0",
4
+ "version": "2.4.0",
5
5
  "description": "Unified MCP server for six medical terminologies (ICD-11, LOINC, RxNorm, MeSH, ATC, CID-10) with authoritative WHO ICD-10→ICD-11 mapping. 33 tools, hosted endpoint available, MIT.",
6
6
  "author": "Sidney da Silva Pereira Bissoli",
7
7
  "license": "MIT",
@@ -61,13 +61,14 @@
61
61
  "@modelcontextprotocol/server": "^2.0.0",
62
62
  "@sbissoli/mcp-provenance": "^0.4.0",
63
63
  "@sbissoli/mcp-search": "^0.9.0",
64
- "@sbissoli/mcp-upstream": "^0.4.2",
64
+ "@sbissoli/mcp-upstream": "^0.5.1",
65
65
  "pino": "^10.2.1",
66
66
  "zod": "^4.5.4"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@modelcontextprotocol/client": "^2.0.0",
70
70
  "@sbissoli/mcp-evals": "^0.2.1",
71
+ "@sbissoli/mcp-live-source": "^0.5.0",
71
72
  "@sbissoli/mcp-surface": "^0.6.0",
72
73
  "@types/node": "^26.5.1",
73
74
  "esbuild": "^0.28.2",