Skip to main content
Glama

Match Terms to a Value Set

match_value_set
Read-onlyIdempotent

Maps free-text terms to matching codes from a supplied value set, ranking only validated allowed codes by lexical and synonym matches so field contents can be standardized.

Instructions

For each free-text term, pick the best code FROM A VALUE SET YOU PROVIDE — the question "which code of this value set fits this field?".

Send terms (up to 50) and value_set: the allowed codes as { code, terminology } pairs (up to 100; any of icd11, icd10, cid10, loinc, rxnorm, mesh, atc, icf, mixed if needed). Only those codes can be suggested — never a code outside the set.

How it works: every member is first confirmed at its source (the validate_codes logic), giving its official title and FHIR coding; members that do not exist or cannot be checked are listed in value_set.unconfirmed and never ranked. Then each term is scored against each confirmed member's title AND the synonyms its source publishes (ICD-11/ICF inclusions and index terms, LOINC related names, MeSH entry terms): match_score (lexical, 0-1), match_type (exact / strong / needs_review, the harmonize_terms rules) and matched_label (the synonym that scored, or null when the title did). Members sharing no word with the term are left out; a term with none left is no_candidates.

Lexical only: a synonym the source does NOT publish ("gait speed" for "walking speed") lands in needs_review or no_candidates — review those with a person. Each member is looked up live (cached), so a large set of ICD-11/ICF codes takes a few seconds.

When NOT to use: with no value set, map terms with harmonize_terms; to check a list of codes, use validate_codes.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "terms": "<terms>",
      "value_set": "<value_set>"
    },
    "name": "match_value_set"
  }
}

Input Schema

NameRequiredDescriptionDefault
termsYesFree-text terms to place in the value set (e.g. the field contents of your data). Up to 50.
value_setYesThe allowed codes, as code+terminology pairs (any of the validate_codes terminologies, mixed if needed). Only these codes can be suggested. Up to 100; each is confirmed at its source before ranking.
max_candidatesNoRanked members returned per term (1-10, default 3).

Output Schema

NameRequiredDescriptionDefault
countsYesHow many terms landed in each class (by their best member).
resultsYesOne entry per term, in request order.
value_setYesWhat happened to the value set before ranking.
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)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv4.1.0

TDQS

A4.6/5.0
Behavior4/5

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

Well beyond the annotations, it discloses the internal pipeline: members are confirmed at source first, unconfirmed ones go to value_set.unconfirmed and are never ranked, scoring is lexical against published titles/synonyms, and members sharing no word with the term are dropped. It also flags the lexical-only limitation ('gait speed' vs 'walking speed') and gives an honest latency note ('a large set of ICD-11/ICF codes takes a few seconds'). The only thing not spelled out is caching/rate-limit nuance beyond the parenthetical '(cached)'.

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 the purpose, then inputs, mechanism, caveat, and exclusions in that order; each block is skimmable. It runs long and repeats the value-set constraint in caps and again in the schema-aligned paragraph, which is minor redundancy rather than 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?

An output schema exists, yet the description still names the three returned signals (match_score, match_type, matched_label) and the two failure shapes (unconfirmed members, no_candidates), which is what an agent needs to interpret a partial result. Combined with the latency warning and the human-review advice, nothing material is missing for a live, open-world scoring tool.

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 real meaning: value_set is a hard constraint ('only those codes can be suggested — never a code outside the set'), the mixed-terminology allowance is stated, and the 50/100 caps are restated with their rationale (live lookups per member). max_candidates is not discussed, keeping it from a 5.

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 ('for each free-text term, pick the best code from a value set you provide') and frames the exact question it answers. It is clearly separable from harmonize_terms (no value set) and validate_codes (code checking) named later in the text.

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?

Explicitly covers when to use it (constrain mapping to an allowed code list) and a 'When NOT to use' block naming both alternatives with the conditions that select them. Nothing about routing is left to inference.

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