Skip to main content
Glama
chrismannina

PubMed MCP Server

by chrismannina

search_mesh_terms

Find and explore Medical Subject Headings (MeSH) terms to enhance PubMed literature searches and improve research precision.

Instructions

Search and explore MeSH (Medical Subject Headings) terms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
termYesMeSH term to search for
max_resultsNoMaximum number of results

Implementation Reference

  • The _handle_search_mesh_terms method implements the core logic for the search_mesh_terms tool. It validates the 'term' argument, performs a PubMed search using the formatted MeSH query '"{term}"[MeSH Terms]', processes results into formatted summaries with MeSH highlighting, and returns an MCPResponse.
    async def _handle_search_mesh_terms(self, arguments: Dict[str, Any]) -> MCPResponse:
        """Handle MeSH term search."""
        try:
            term = arguments.get("term", "")
            if not term:
                return MCPResponse(
                    content=[{"type": "text", "text": "MeSH term is required"}], is_error=True
                )
    
            max_results = arguments.get("max_results", 20)
    
            # Search using the MeSH term
            search_result = await self.pubmed_client.search_articles(
                query=f'"{term}"[MeSH Terms]', max_results=max_results, cache=self.cache
            )
    
            content = []
            content.append(
                {
                    "type": "text",
                    "text": f"**Articles with MeSH term: {term}**\n\n"
                    f"Total Results: {search_result.total_results:,}\n"
                    f"Showing: {search_result.returned_results}\n",
                }
            )
    
            for i, article_data in enumerate(search_result.articles, 1):
                article_text = self._format_article_summary(article_data, i, highlight_mesh=term)
                content.append({"type": "text", "text": article_text})
    
            return MCPResponse(content=content)
    
        except Exception as e:
            logger.error(f"Error in search_mesh_terms: {e}")
            return MCPResponse(
                content=[{"type": "text", "text": f"Error: {str(e)}"}], is_error=True
            )
  • The JSON schema definition for the search_mesh_terms tool in TOOL_DEFINITIONS, defining input parameters 'term' (required string) and optional 'max_results' (integer 1-100, default 20).
    {
        "name": "search_mesh_terms",
        "description": ("Search and explore MeSH (Medical Subject Headings) terms"),
        "inputSchema": {
            "type": "object",
            "properties": {
                "term": {"type": "string", "description": "MeSH term to search for"},
                "max_results": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 20,
                    "description": "Maximum number of results",
                },
            },
            "required": ["term"],
        },
    },
  • The handler_map in ToolHandler.handle_tool_call registers the 'search_mesh_terms' tool name to the _handle_search_mesh_terms handler method.
    handler_map = {
        "search_pubmed": self._handle_search_pubmed,
        "get_article_details": self._handle_get_article_details,
        "search_by_author": self._handle_search_by_author,
        "find_related_articles": self._handle_find_related_articles,
        "export_citations": self._handle_export_citations,
        "search_mesh_terms": self._handle_search_mesh_terms,
        "search_by_journal": self._handle_search_by_journal,
        "get_trending_topics": self._handle_get_trending_topics,
        "analyze_research_trends": self._handle_analyze_research_trends,
        "compare_articles": self._handle_compare_articles,
        "get_journal_metrics": self._handle_get_journal_metrics,
        "advanced_search": self._handle_advanced_search,
    }
Behavior2/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 mentions 'search and explore' but doesn't specify whether this is a read-only operation, if it requires authentication, what the response format looks like, or any rate limits. For a search tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence with zero wasted words. It's appropriately sized and front-loaded, clearly stating the core functionality without unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (search operation with 2 parameters), 100% schema coverage, but no annotations and no output schema, the description is minimally adequate. It states what the tool does but lacks details on behavior, output, or differentiation from siblings, leaving gaps for the agent to navigate.

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 description coverage is 100%, so the input schema already fully documents both parameters ('term' and 'max_results'). The description adds no additional meaning beyond what's in the schema, such as explaining search semantics or result formatting. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('search and explore') and resource ('MeSH terms'), making the purpose immediately understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'search_pubmed' or 'advanced_search', which might also involve searching medical content, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_pubmed' or 'advanced_search'. It lacks context about specific use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name alone.

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/chrismannina/pubmed-mcp'

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