Skip to main content
Glama

Harmonize Free-Text Terms to Standard Codes

harmonize_terms
Read-onlyIdempotent

Map a LIST of free-text clinical terms to standard codes in one call, with ranked candidates and a confidence label for each — the building block of a reviewable crosswalk.

Use this tool to:

  • Harmonize a column of diagnoses, drugs or lab names from a dataset to ICD-11 / RxNorm (+ ATC) / LOINC

  • Triage which terms map cleanly (exact / strong) and which need a person (needs_review)

  • Build a crosswalk you can audit: every row keeps its candidates, scores and sources

Give each term its domain: diagnosis → ICD-11; drug → RxNorm concepts (ingredients first) plus the ATC classes of the term; lab → LOINC. Up to 50 terms per call — a longer list is refused with a validation error: split it into batches of 50. Repeated term+domain pairs are looked up once. max_candidates keeps 1-5 per term (default 3).

Every candidate carries match_score (lexical, 0-1, the find_equivalent formula) and match_type: exact = same words after normalization; strong = every term word is in the title (or the matched synonym) and score ≥ 0.85; needs_review = anything else. A one-word term is exact or needs_review, never strong ("Tylenol" vs "Tylenol PM" is a different product). Synonyms, abbreviations ("MI", "HbA1c") and misspellings land in needs_review or no_candidates — the label errs toward asking a person. Candidates sharing no word with the term are dropped, as are LOINC codes named "Deprecated". For diagnoses, a candidate is also scored against the synonyms WHO matched (e.g. "hypertension NOS" for Essential hypertension), reported in matched_label; postcoordinated clusters (codes with "/" or "&") are left out — build those with icd11_postcoordination. Lab names are ambiguous without specimen and property: "glucose" matches over a thousand LOINC codes, so write "glucose serum" or expect needs_review. One failed lookup does not fail the batch: that row comes back with status "error".

Terms are searched in English and sent to the WHO and NLM APIs — de-identify the list first. For Brazilian Portuguese diagnoses use cid10_search; to check codes you already have, use validate_codes; for one term across every terminology, use find_equivalent. Record the vocabulary versions with the provenance blocks (one per source) and terminology_versions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
termsYesTerms to harmonize, each with its domain. Up to 50 per call; repeated term+domain pairs are looked up once.
max_candidatesNoCandidates kept per term, best first (1-5, default 3).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYesTerms submitted.
countsYes
rankingYes
resultsYesOne entry per submitted term, in request order.
provenanceYesOne provenance block per upstream source that contributed to this response (licenses are never merged; each block carries the origin diagnostics of ITS source)
attributionYesCanonical source URLs of this response (attribution list)
unique_lookupsYesDistinct term+domain pairs actually looked up.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedOutput schema / properties / provenance / items / properties / notices / description
      Previous value: -"Notices the source publishes alongside the data (license statements, caveats), verbatim. Absent when there is none"New value: +"Caveats the source publishes about the data, verbatim (license statements are not repeated here; see the info://licenses resource). Absent when there is none"
  2. Changed8 schema fields changed
    • changedOutput schema / properties / provenance / description
      Previous value: -"One provenance block per upstream source that contributed to this response (contract v1.1; licenses are never merged; each block carries the origin diagnostics of ITS source)"New value: +"One provenance block per upstream source that contributed to this response (licenses are never merged; each block carries the origin diagnostics of ITS source)"
    • changedOutput schema / properties / provenance / items / description
      Previous value: -"Bloco de proveniência (contrato v1.2): fonte, URL, competência, extração, diagnóstico de origem, citação e licença; e, só quando a resposta junta partes de origens ou momentos distintos, de onde veio cada parte"New value: +"Bloco de proveniência: fonte, URL, competência, extração, diagnóstico de origem, citação e licença; e, só quando há o que dizer, de onde veio cada parte, avisos da fonte, o que o servidor calculou e se o dado ainda pode mudar"
    • addedOutput schema / properties / provenance / items / properties / derivation_note
      Added value: +{
      +  "description": "What this server computed; present together with derived",
      +  "type": "string"
      +}
    • addedOutput schema / properties / provenance / items / properties / derived
      Added value: +{
      +  "description": "Present (true) only when this server computed the value (e.g. a ranking or summary statistics) instead of passing on what the source returned",
      +  "type": "boolean"
      +}
    • changedOutput schema / properties / provenance / items / properties / field_sources / description
      Previous value: -"Present only when the response joins parts from different origins or extraction instants (contract v1.2): for each group of fields, its URL, extraction instant and whether it came from cache. Absent in single-origin responses"New value: +"Present only when the response joins parts from different origins or extraction instants: for each group of fields, its URL, extraction instant and whether it came from cache. Absent in single-origin responses"
    • addedOutput schema / properties / provenance / items / properties / notices
      Added value: +{
      +  "description": "Notices the source publishes alongside the data (license statements, caveats), verbatim. Absent when there is none",
      +  "items": {
      +    "type": "string"
      +  },
      +  "minItems": 1,
      +  "type": "array"
      +}
    • changedOutput schema / properties / provenance / items / properties / retrieval / description
      Previous value: -"Origin diagnostics of THIS source in this call (contract v1.1): requests made to the upstream, attempts summed across retries, anomalies worked around (kind + count); unstable=true when any anomaly happened. null when nothing was measured (bundled dataset, or response served entirely from cache)"New value: +"Origin diagnostics of THIS source in this call: requests made to the upstream, attempts summed across retries, anomalies worked around (kind + count); unstable=true when any anomaly happened. null when nothing was measured (bundled dataset, or response served entirely from cache)"
    • addedOutput schema / properties / provenance / items / properties / revision
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Whether the data can still change at the source: current = the version in force, the source may revise it; provisional = preliminary; final = will not change. Absent when unknown",
      +  "properties": {
      +    "note": {
      +      "description": "O específico da fonte: o que revisa, quando, por quê",
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "status": {
      +      "description": "current = versão vigente, a fonte pode revisá-la; provisional = preliminar, incompleta ou sujeita a mudança (não compare como se fosse fechada); final = não muda mais, declarado pela fonte",
      +      "enum": [
      +        "current",
      +        "provisional",
      +        "final"
      +      ],
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "status",
      +    "note"
      +  ],
      +  "type": "object"
      +}
  3. Changed2 schema fields changed
    • changedOutput schema / properties / provenance / items / description
      Previous value: -"Bloco de proveniência (contrato v1.1): fonte, URL, competência, extração, diagnóstico de origem, citação e licença"New value: +"Bloco de proveniência (contrato v1.2): fonte, URL, competência, extração, diagnóstico de origem, citação e licença; e, só quando a resposta junta partes de origens ou momentos distintos, de onde veio cada parte"
    • addedOutput schema / properties / provenance / items / properties / field_sources
      Added value: +{
      +  "description": "Present only when the response joins parts from different origins or extraction instants (contract v1.2): for each group of fields, its URL, extraction instant and whether it came from cache. Absent in single-origin responses",
      +  "items": {
      +    "additionalProperties": false,
      +    "description": "Proveniência de um grupo de campos da resposta: de onde veio e quando foi extraído",
      +    "properties": {
      +      "data_vintage": {
      +        "description": "Vintage/competência da sub-fonte",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "dataset_id": {
      +        "description": "Identificador do conjunto da sub-fonte",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "fields": {
      +        "description": "Campos do payload atribuídos a esta sub-fonte",
      +        "items": {
      +          "type": "string"
      +        },
      +        "minItems": 1,
      +        "type": "array"
      +      },
      +      "retrieved_at": {
      +        "description": "ISO-8601 da extração desta sub-fonte na origem",
      +        "type": [
      +          "string",
      +          "null"
      +        ]
      +      },
      +      "served_from_cache": {
      +        "description": "true se esta sub-fonte veio do cache do servidor (retrieved_at é o da extração original); false se foi buscada nesta chamada; null se o servidor não distingue",
      +        "type": [
      +          "boolean",
      +          "null"
      +        ]
      +      },
      +      "source_url": {
      +        "description": "URL canônica da sub-fonte que originou estes campos",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "fields",
      +      "source_url",
      +      "dataset_id",
      +      "data_vintage",
      +      "retrieved_at"
      +    ],
      +    "type": "object"
      +  },
      +  "minItems": 1,
      +  "type": "array"
      +}
  4. Added

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the read-only/idempotent annotations: 50-term hard cap with a validation-error failure mode, dedup of repeated term+domain pairs, per-row error isolation (one failed lookup does not fail the batch), English-only searching, and an outbound third-party API call (WHO/NLM) with an explicit de-identify warning. This is unusually rich operational disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with a one-sentence summary and organized into bullets, so the structure is good. It is nonetheless long, and a sizeable middle block defines output fields (match_score, match_type, matched_label) that an existing output schema may already carry.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a batch mapping tool with nested-ish term objects, external API calls and a multi-state response, the description supplies limits, error semantics, dedup behavior, terminology routing and provenance guidance. An agent can invoke and interpret it without guessing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds nuance the schema lacks: domain-to-terminology routing detail (drug -> ingredients first plus ATC classes), the one-word-term rule, and why lab terms need specimen/property. It mostly restates schema-level constraints like the 50 cap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (map a LIST of free-text clinical terms to standard codes) and frames it as the batch building block of a reviewable crosswalk. Clearly separable from siblings like find_equivalent (single term) and validate_codes (existing codes).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit 'Use this tool to' bullets cover the three mapping scenarios, and the closing paragraph names alternatives with the exact condition that selects each: cid10_search for Brazilian Portuguese diagnoses, validate_codes for existing codes, find_equivalent for one term across all terminologies. When-to-use and when-not-to-use are both covered.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.