Skip to main content
Glama

mesh_search

Read-onlyIdempotent

Find MeSH (Medical Subject Headings) terms for indexing medical literature or refining PubMed searches. Enter a term like 'diabetes' to retrieve matching descriptors with IDs.

Instructions

Search for MeSH (Medical Subject Headings) descriptors.

Use this tool to:

  • Find MeSH terms for indexing medical literature

  • Look up subject headings for PubMed searches

  • Find controlled vocabulary terms

Returns matching descriptors with MeSH IDs and labels.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch term (e.g., "diabetes", "heart failure")
matchNoMatch type: exact, contains, or startswith. Default: containscontains
max_resultsNoMaximum number of results (1-100). Default: 25

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
matchYes
total_countYes
descriptorsYes

Implementation Reference

  • The main handler function for the mesh_search tool. Parses input params via MeSHSearchParamsSchema, calls the MeSH client to search descriptors, builds structured output (query, match, total_count, descriptors), formats results as text, and returns a CallToolResult with both text and structured content.
    async function handleMeSHSearch(args: Record<string, unknown>): Promise<CallToolResult> {
      try {
        const params = MeSHSearchParamsSchema.parse(args);
        const client = getMeSHClient();
        const results = await client.searchDescriptors(params.query, params.match, params.max_results);
    
        const structured: MeSHSearchOutput = {
          query: params.query,
          match: params.match,
          total_count: results.length,
          descriptors: results.map((r) => ({
            id: r.id,
            uri: r.uri,
            label: r.label,
          })),
        };
    
        return {
          content: [{ type: 'text', text: formatSearchResults(params.query, results) }],
          structuredContent: structured,
        };
      } catch (error) {
        return handleToolError(error);
      }
    }
  • Input schema (MeSHSearchParamsSchema) for the mesh_search tool: defines 'query' (string, required), 'match' (enum: exact/contains/startswith, optional, default 'contains'), and 'max_results' (capped at 25).
    export const MeSHSearchParamsSchema = z.object({
      query: z.string().min(1).describe('Search term (e.g., "diabetes", "heart failure")'),
      match: z
        .enum(['exact', 'contains', 'startswith'])
        .optional()
        .default('contains')
        .describe('Match type: exact, contains, or startswith. Default: contains'),
      max_results: maxResults(25),
    });
  • Output schema (MeSHSearchOutputSchema) for the mesh_search tool: defines 'query', 'match', 'total_count', and array of 'descriptors' with id/uri/label.
    export const MeSHSearchOutputSchema = z.object({
      query: z.string(),
      match: z.enum(['exact', 'contains', 'startswith']),
      total_count: z.number().int(),
      descriptors: z.array(
        z.object({
          id: z.string(),
          uri: z.string(),
          label: z.string(),
        }),
      ),
    });
  • Tool definition/registration object for 'mesh_search' with name, description, inputSchema, outputSchema, and annotations.
    const meshSearchTool: Tool = {
      name: 'mesh_search',
      description: `Search for MeSH (Medical Subject Headings) descriptors.
    
    Use this tool to:
    - Find MeSH terms for indexing medical literature
    - Look up subject headings for PubMed searches
    - Find controlled vocabulary terms
    
    Returns matching descriptors with MeSH IDs and labels.`,
      inputSchema: buildInputSchema(MeSHSearchParamsSchema),
      outputSchema: buildOutputSchema(MeSHSearchOutputSchema),
      annotations: READ_ONLY_TOOL_ANNOTATIONS,
    };
  • Helper function that formats search results into a markdown table (MeSH ID | Label) for display.
    function formatSearchResults(query: string, results: MeSHSearchResult[]): string {
      const lines: string[] = [];
    
      lines.push(`## MeSH Search Results for "${query}"`);
      lines.push('');
    
      if (results.length === 0) {
        lines.push('No descriptors found.');
        return lines.join('\n');
      }
    
      lines.push(`Found ${results.length} descriptor(s):`);
      lines.push('');
      lines.push('| MeSH ID | Label |');
      lines.push('|---------|-------|');
    
      for (const result of results) {
        lines.push(`| ${result.id} | ${result.label} |`);
      }
    
      return lines.join('\n');
    }
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, openWorldHint=true. The description adds that it returns matching descriptors with MeSH IDs and labels, which aligns with annotations and provides minor additional behavioral context.

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?

The description is concise with 6 sentences, front-loaded with the main action, and uses bullet points for clarity. Every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description adequately covers purpose and usage, and the presence of an output schema (not shown) reduces the need to explain return values. However, it omits details about behavior for no results or pagination, leaving minor gaps.

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

Parameters3/5

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

Schema coverage is 100% with descriptions for all three parameters (query, match, max_results). The description does not add parameter-specific meaning beyond what the schema provides, so a baseline score of 3 is appropriate.

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 clearly states the tool searches for MeSH descriptors, with specific use cases (indexing, PubMed searches, controlled vocabulary). This differentiates it from sibling tools like atc_lookup or rxnorm_search.

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?

The description provides explicit when-to-use scenarios (Find MeSH terms, look up subject headings). While it does not mention when not to use or alternatives, the context is clear enough for an agent to select it over other search tools.

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/SidneyBissoli/medical-terminologies-mcp'

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