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
| Name | Required | Description | Default |
|---|---|---|---|
| term | Yes | MeSH term to search for | |
| max_results | No | Maximum number of results |
Implementation Reference
- src/tool_handler.py:342-378 (handler)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 )
- src/tools.py:187-204 (schema)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"], }, },
- src/tool_handler.py:65-78 (registration)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, }