get_mesh_tree
Retrieve the MeSH hierarchy for a descriptor to understand its classification, identify parent categories, and determine appropriate specificity for subject analysis.
Instructions
Retrieve the MeSH tree hierarchy for a descriptor: its tree numbers, the full name of each top-level category, and its immediate broader (parent) descriptors.
Use this to understand where a heading sits within the MeSH hierarchy, helping to determine whether the heading is specific enough for the work or whether a broader heading would be more appropriate.
MeSH tree number top-level categories: A Anatomy B Organisms C Diseases D Chemicals and Drugs E Analytical, Diagnostic and Therapeutic Techniques and Equipment F Psychiatry and Psychology G Phenomena and Processes H Disciplines and Occupations I Anthropology, Education, Sociology and Social Phenomena J Technology, Industry, and Agriculture K Humanities L Information Science M Named Groups N Health Care V Publication Characteristics Z Geographicals
Parameters
descriptor : str The MeSH UI code (e.g. "D003920") or full URI returned by search_mesh.
Returns
dict Contains: - ui : MeSH unique identifier - label : Preferred heading label - treeNumbers : List of tree number strings - categories : List of {letter, name} dicts for top-level categories - broader : List of {label, ui} dicts for parent descriptors
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| descriptor | Yes |
Implementation Reference
- src/mesh_mcp/server.py:344-422 (handler)The get_mesh_tree tool implementation, which retrieves the MeSH tree hierarchy for a given descriptor UI.
@mcp.tool() def get_mesh_tree(descriptor: str) -> dict: """ Retrieve the MeSH tree hierarchy for a descriptor: its tree numbers, the full name of each top-level category, and its immediate broader (parent) descriptors. Use this to understand where a heading sits within the MeSH hierarchy, helping to determine whether the heading is specific enough for the work or whether a broader heading would be more appropriate. MeSH tree number top-level categories: A Anatomy B Organisms C Diseases D Chemicals and Drugs E Analytical, Diagnostic and Therapeutic Techniques and Equipment F Psychiatry and Psychology G Phenomena and Processes H Disciplines and Occupations I Anthropology, Education, Sociology and Social Phenomena J Technology, Industry, and Agriculture K Humanities L Information Science M Named Groups N Health Care V Publication Characteristics Z Geographicals Parameters ---------- descriptor : str The MeSH UI code (e.g. "D003920") or full URI returned by search_mesh. Returns ------- dict Contains: - ui : MeSH unique identifier - label : Preferred heading label - treeNumbers : List of tree number strings - categories : List of {letter, name} dicts for top-level categories - broader : List of {label, ui} dicts for parent descriptors """ _CATEGORY_NAMES = { "A": "Anatomy", "B": "Organisms", "C": "Diseases", "D": "Chemicals and Drugs", "E": "Analytical, Diagnostic and Therapeutic Techniques and Equipment", "F": "Psychiatry and Psychology", "G": "Phenomena and Processes", "H": "Disciplines and Occupations", "I": "Anthropology, Education, Sociology and Social Phenomena", "J": "Technology, Industry, and Agriculture", "K": "Humanities", "L": "Information Science", "M": "Named Groups", "N": "Health Care", "V": "Publication Characteristics", "Z": "Geographicals", } record = get_mesh_record(descriptor) if "error" in record: return record return { "ui": record["ui"], "label": record.get("label", ""), "treeNumbers": record.get("treeNumbers", []), "categories": [ {"letter": c, "name": _CATEGORY_NAMES.get(c, "Unknown")} for c in record.get("treeCategories", []) ], "broader": record.get("broader", []), }