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}
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It identifies the external endpoint ('NLM Lookup autocomplete'), documents default behaviors (startsWith matching, limit 10), and details the return structure including error handling and field definitions ('ui', 'uri'). Minor gap: does not explicitly state rate limits or timeout behavior.

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?

Uses a structured docstring format (Parameters/Returns sections) that efficiently organizes information. The purpose and usage guidelines are front-loaded in the first two sentences. The Returns section is necessary given the absence of an output schema, though it adds length. No redundant or tautological statements.

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?

Given zero schema descriptions and no output schema, the description provides comprehensive coverage: parameter semantics, return value structure, sibling relationships, and endpoint details. The inclusion of example values and URI formats (e.g., 'http://id.nlm.nih.gov/mesh/D003920') provides sufficient context for an agent to invoke the tool correctly without additional discovery.

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

Parameters5/5

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

Schema description coverage is 0%, requiring the description to fully compensate. It excellently documents all three parameters: query includes realistic examples ('diabetes', 'neoplasms'), match explains all three enum-like options with behavioral context ('analogous to LCSH suggest2'), and limit specifies constraints ('max 50'). Completely compensates for the schema's lack of descriptions.

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?

The description opens with a precise action ('Search MeSH descriptors'), resource ('MeSH descriptors'), and method ('NLM Lookup autocomplete endpoint'). It clearly distinguishes itself from siblings by stating it finds codes 'before calling get_mesh_record or get_mesh_qualifiers', establishing the correct workflow sequence.

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 states when to use the tool ('Use this to find the MeSH UI code and URI...') and names specific sibling alternatives to use afterwards ('before calling get_mesh_record or get_mesh_qualifiers'). This provides clear workflow guidance and prevents incorrect tool selection.

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

Install Server

Other Tools

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