Skip to main content
Glama

search_mesh

Find MeSH descriptor codes and URIs for biomedical concepts by searching labels. Use this tool to identify medical terminology before retrieving detailed records or qualifiers.

Instructions

Search MeSH descriptors by label using the NLM Lookup autocomplete endpoint.

Use this to find the MeSH UI code and URI for a biomedical concept before calling get_mesh_record or get_mesh_qualifiers.

Parameters

query : str The label string to search for (e.g. "diabetes", "neoplasms"). match : str Matching strategy: "startsWith" — left-anchored (default, analogous to LCSH suggest2) "contains" — substring match anywhere in the label "exact" — exact match only limit : int Maximum number of results to return (default 10, max 50).

Returns

dict A 'results' list of {label, ui, uri} dicts, or an 'error' key. 'ui' is the MeSH unique identifier (e.g. "D003920"). 'uri' is the full RDF URI (e.g. "http://id.nlm.nih.gov/mesh/D003920").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
matchNostartsWith
limitNo

Implementation Reference

  • The search_mesh tool is defined as an MCP tool, querying the NLM descriptor lookup endpoint and formatting the results into a list of descriptors with labels, UI IDs, and URIs.
    @mcp.tool()
    def search_mesh(query: str, match: str = "startsWith", limit: int = 10) -> dict:
        """
        Search MeSH descriptors by label using the NLM Lookup autocomplete endpoint.
    
        Use this to find the MeSH UI code and URI for a biomedical concept before
        calling get_mesh_record or get_mesh_qualifiers.
    
        Parameters
        ----------
        query : str
            The label string to search for (e.g. "diabetes", "neoplasms").
        match : str
            Matching strategy:
              "startsWith" — left-anchored (default, analogous to LCSH suggest2)
              "contains"   — substring match anywhere in the label
              "exact"      — exact match only
        limit : int
            Maximum number of results to return (default 10, max 50).
    
        Returns
        -------
        dict
            A 'results' list of {label, ui, uri} dicts, or an 'error' key.
            'ui'  is the MeSH unique identifier (e.g. "D003920").
            'uri' is the full RDF URI (e.g. "http://id.nlm.nih.gov/mesh/D003920").
        """
        result = _get(
            f"{_LOOKUP_BASE}/descriptor",
            params={"label": query, "match": match, "limit": min(limit, 50)},
        )
        if "error" in result:
            return result
    
        raw = result["data"]
        if not isinstance(raw, list):
            return {"error": "Unexpected response format from NLM lookup", "data": raw}
    
        results = []
        for item in raw:
            uri   = item.get("resource", "")
            label = item.get("label", "")
            ui    = _uri_to_id(uri) if uri else ""
            results.append({"label": label, "ui": ui, "uri": uri})
        return {"results": results}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/msuicaut/mesh-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server