Skip to main content
Glama

Validate Medical Codes

validate_codes
Read-onlyIdempotent

Validate batches of medical codes against ICD-10, ICD-11, LOINC, RxNorm, MeSH, ATC, or CID-10 to flag invalid, inactive, or ICD-10-to-ICD-11 replaced codes in legacy data.

Instructions

Validate a mixed batch of medical codes against their source terminologies. Useful for retrospective analysis of legacy databases — flag codes that no longer exist, surface ICD-10 → ICD-11 replacements, and grade activity status where the terminology exposes it.

For each input { code, terminology }, returns:

  • valid: whether the code exists in the source terminology.

  • active: whether the code is currently active. Null when the source doesn't expose an explicit active/inactive distinction at category level (CID-10, ATC, ICD-11, RxNorm, MeSH all return null today; LOINC returns a real boolean).

  • title: the official label/name when available.

  • replaced_by: a successor code, populated today only for ICD-10 codes that have a primary ICD-11 mapping in the bundled WHO transition tables.

  • source: human-readable provenance of the validation (terminology + release/version).

  • error: non-null only when validation couldn't be performed (network error, upstream outage, etc.). valid: false + error: null means "code not found"; valid: false + error: set means "couldn't validate".

Terminology is required per code — auto-detection isn't supported because category codes like "A00" exist in both ICD-10 and CID-10. Accepted values: icd11, icd10, loinc, rxnorm, mesh, atc, cid10.

Hard cap of 50 codes per call; codes are validated in parallel through their respective clients, so total wall time scales with the slowest upstream + its rate limit (worst case ~10 s for a full batch hitting ICD-11).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codesYesList of code+terminology pairs to validate. Hard cap of 50 per call to keep total latency under ~10 s given upstream rate limits.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalYesNumber of codes submitted.
resultsYes
provenanceYesOne 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)
attributionYesCanonical source URLs of this response (attribution list)
error_countYesHow many couldn't be validated due to upstream/network errors.
valid_countYesHow many were confirmed valid.
invalid_countYesHow many were not found.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.0.0
    • changedInput schema / properties / codes / items / properties / terminology / enum
      Previous value: -[
      -  "icd11",
      -  "icd10",
      -  "snomed",
      -  "loinc",
      -  "rxnorm",
      -  "mesh",
      -  "atc",
      -  "cid10"
      -]New value: +[
      +  "icd11",
      +  "icd10",
      +  "loinc",
      +  "rxnorm",
      +  "mesh",
      +  "atc",
      +  "cid10"
      +]
    • changedOutput schema / properties / results / items / properties / terminology / enum
      Previous value: -[
      -  "icd11",
      -  "icd10",
      -  "snomed",
      -  "loinc",
      -  "rxnorm",
      -  "mesh",
      -  "atc",
      -  "cid10"
      -]New value: +[
      +  "icd11",
      +  "icd10",
      +  "loinc",
      +  "rxnorm",
      +  "mesh",
      +  "atc",
      +  "cid10"
      +]
  2. Changed4 schema fields changedv1.15.0
    • changedOutput schema / properties / provenance / description
      Previous value: -"One provenance block per upstream source that contributed to this response (contract v1.0; licenses are never merged)"New 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)"
    • addedOutput schema / properties / provenance / items / description
      Added value: +"Bloco de proveniência (contrato v1.1): fonte, URL, competência, extração, diagnóstico de origem, citação e licença"
    • addedOutput schema / properties / provenance / items / properties / retrieval
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": false,
      +      "properties": {
      +        "anomalies": {
      +          "description": "Anomalias superadas até o sucesso, somadas por classe, em ordem fixa; [] se nenhuma",
      +          "items": {
      +            "additionalProperties": false,
      +            "properties": {
      +              "count": {
      +                "description": "Ocorrências desta classe na chamada",
      +                "maximum": 9007199254740991,
      +                "minimum": 1,
      +                "type": "integer"
      +              },
      +              "kind": {
      +                "description": "Classe da anomalia (vocabulário fechado do contrato)",
      +                "enum": [
      +                  "timeout",
      +                  "network",
      +                  "http_4xx",
      +                  "http_5xx",
      +                  "rate_limited",
      +                  "malformed_body"
      +                ],
      +                "type": "string"
      +              }
      +            },
      +            "required": [
      +              "kind",
      +              "count"
      +            ],
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "attempts": {
      +          "description": "Tentativas somadas, incluindo as repetidas (>= requests)",
      +          "maximum": 9007199254740991,
      +          "minimum": 1,
      +          "type": "integer"
      +        },
      +        "requests": {
      +          "description": "Idas distintas à origem que compõem esta resposta (fatias, páginas)",
      +          "maximum": 9007199254740991,
      +          "minimum": 1,
      +          "type": "integer"
      +        },
      +        "unstable": {
      +          "description": "true se houve repetição (attempts > requests) ou alguma anomalia",
      +          "type": "boolean"
      +        }
      +      },
      +      "required": [
      +        "requests",
      +        "attempts",
      +        "anomalies",
      +        "unstable"
      +      ],
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "description": "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)"
      +}
    • changedOutput schema / properties / provenance / items / required
      Previous value: -[
      -  "source",
      -  "source_url",
      -  "data_vintage",
      -  "retrieved_at",
      -  "citation",
      -  "license"
      -]New value: +[
      +  "source",
      +  "source_url",
      +  "data_vintage",
      +  "retrieved_at",
      +  "retrieval",
      +  "citation",
      +  "license"
      +]
  3. Changed1 schema field changedv1.11.0
    • addedInput schema / additionalProperties
      Added value: +false
  4. Changed12 schema fields changedv1.9.1
    • removedOutput schema / properties / provenance / items / properties / data_vintage / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / provenance / items / properties / data_vintage / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / provenance / items / properties / license / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / provenance / items / properties / license / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / results / items / properties / active / anyOf
      Removed value: -[
      -  {
      -    "type": "boolean"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / results / items / properties / active / type
      Added value: +[
      +  "boolean",
      +  "null"
      +]
    • removedOutput schema / properties / results / items / properties / error / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / results / items / properties / error / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / results / items / properties / replaced_by / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / results / items / properties / replaced_by / type
      Added value: +[
      +  "string",
      +  "null"
      +]
    • removedOutput schema / properties / results / items / properties / title / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • addedOutput schema / properties / results / items / properties / title / type
      Added value: +[
      +  "string",
      +  "null"
      +]
  5. Changed3 schema fields changedv1.8.0
    • addedOutput schema / properties / attribution
      Added value: +{
      +  "description": "Canonical source URLs of this response (attribution list)",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedOutput schema / properties / provenance
      Added value: +{
      +  "description": "One provenance block per upstream source that contributed to this response (contract v1.0; licenses are never merged)",
      +  "items": {
      +    "additionalProperties": false,
      +    "properties": {
      +      "citation": {
      +        "description": "Ready-to-use citation/attribution string",
      +        "type": "string"
      +      },
      +      "data_vintage": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "Version/release of the data as exposed by the source; null when not exposed"
      +      },
      +      "license": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "description": "License / legal regime of the data"
      +      },
      +      "retrieved_at": {
      +        "description": "Real instant of the upstream extraction (ISO-8601, UTC). Responses served from cache keep the ORIGINAL fetch instant.",
      +        "type": "string"
      +      },
      +      "source": {
      +        "description": "Official upstream source of this data",
      +        "type": "string"
      +      },
      +      "source_url": {
      +        "description": "Canonical URL of the source (API base or dataset release)",
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "source",
      +      "source_url",
      +      "data_vintage",
      +      "retrieved_at",
      +      "citation",
      +      "license"
      +    ],
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "total",
      -  "valid_count",
      -  "invalid_count",
      -  "error_count",
      -  "results"
      -]New value: +[
      +  "total",
      +  "valid_count",
      +  "invalid_count",
      +  "error_count",
      +  "results",
      +  "provenance",
      +  "attribution"
      +]
  6. Changed18 schema fields changedv1.5.7
    • removedInput schema / additionalProperties
      Removed value: -false
    • removedInput schema / properties / codes / items / additionalProperties
      Removed value: -false
    • addedOutput schema / properties / error_count / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / error_count / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / invalid_count / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / invalid_count / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / results / items / properties / active / anyOf
      Added value: +[
      +  {
      +    "type": "boolean"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedOutput schema / properties / results / items / properties / active / type
      Removed value: -[
      -  "boolean",
      -  "null"
      -]
    • addedOutput schema / properties / results / items / properties / error / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedOutput schema / properties / results / items / properties / error / type
      Removed value: -[
      -  "string",
      -  "null"
      -]
    • addedOutput schema / properties / results / items / properties / replaced_by / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedOutput schema / properties / results / items / properties / replaced_by / type
      Removed value: -[
      -  "string",
      -  "null"
      -]
    • addedOutput schema / properties / results / items / properties / title / anyOf
      Added value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • removedOutput schema / properties / results / items / properties / title / type
      Removed value: -[
      -  "string",
      -  "null"
      -]
    • addedOutput schema / properties / total / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / total / minimum
      Added value: +-9007199254740991
    • addedOutput schema / properties / valid_count / maximum
      Added value: +9007199254740991
    • addedOutput schema / properties / valid_count / minimum
      Added value: +-9007199254740991
  7. Addedv1.4.0

TDQS

A4.7/5.0
Behavior5/5

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

Adds rich behavioral context beyond annotations: the 50-code hard cap, parallel validation with wall-time scaling, the null semantics of 'active' per terminology, and the precise valid/error truth table for distinguishing 'not found' from 'couldn't validate'.

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

Conciseness5/5

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

Front-loaded purpose, then a clean bulleted return-value contract, then constraints. Dense but every sentence carries load; no filler.

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?

Despite an output schema existing, the description fills the remaining gaps an agent needs: v / error semantics, per-terminology 'active' behavior, replacement-mapping coverage, and throughput/latency limits.

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 baseline is 3, but the description adds meaning beyond the schema: explains why terminology is required (A00 ambiguity), enumerates the accepted values, and documents the batch cap and latency implications.

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 (validate) and a specific resource (mixed batch of medical codes against their source terminologies), and clarifies the scope as batch/multi-terminology, distinguishing it from all the per-terminology lookup/search siblings.

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

Usage Guidelines4/5

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

Gives clear usage context ('retrospective analysis of legacy databases', flag dead codes, surface ICD-10 → ICD-11 replacements) and implicitly differentiates from single-code lookup siblings, but does not explicitly name an alternative tool or state exclusions.

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