search_europepmc
Search academic papers from Europe PMC to find relevant research articles using specific queries and return paper metadata.
Instructions
Search academic papers from Europe PMC.
Args: query: Search query string (e.g., 'machine learning'). max_results: Maximum number of papers to return (default: 10). Returns: List of paper metadata in dictionary format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| max_results | No |
Implementation Reference
- paper_search_mcp/server.py:905-915 (handler)The 'search_europepmc' function in 'server.py' acts as the MCP tool handler. It calls the 'async_search' helper function, delegating the actual work to the 'europepmc_searcher' instance.
async def search_europepmc(query: str, max_results: int = 10) -> List[Dict]: """Search academic papers from Europe PMC. Args: query: Search query string (e.g., 'machine learning'). max_results: Maximum number of papers to return (default: 10). Returns: List of paper metadata in dictionary format. """ papers = await async_search(europepmc_searcher, query, max_results) return papers if papers else [] - The 'EuropePMCSearcher.search' method performs the actual API call to the Europe PMC service to retrieve paper results.
def search(self, query: str, max_results: int = 10, **kwargs) -> List[Paper]: """ Search Europe PMC for biomedical literature. Args: query: Search query string max_results: Maximum results to return (Europe PMC default: 25, max: 1000) **kwargs: Additional parameters: - year: Filter by publication year - has_fulltext: Filter by full text availability (True/False) - open_access: Filter by open access status (True/False) - source: Filter by source (e.g., 'MED', 'PMC', 'AGR') Returns: List[Paper]: List of found papers with metadata """ papers = [] try: # Prepare search parameters params = { 'query': query, 'pageSize': min(max_results, 100), # Use pageSize parameter 'format': 'json', 'resultType': 'core', } # Add optional filters if 'year' in kwargs: params['year'] = kwargs['year'] if 'has_fulltext' in kwargs: params['has_fulltext'] = 'y' if kwargs['has_fulltext'] else 'n' if 'open_access' in kwargs: params['open_access'] = 'y' if kwargs['open_access'] else 'n' if 'source' in kwargs: params['source'] = kwargs['source'] # Europe PMC supports sorting if 'sort' in kwargs: params['sort'] = kwargs['sort'] # Make API request response = self.session.get(f"{self.BASE_URL}/search", params=params, timeout=30) response.raise_for_status() data = response.json() # Parse results result_list = data.get('resultList', {}).get('result', []) for item in result_list: try: paper = self._parse_item(item) if paper: papers.append(paper) if len(papers) >= max_results: break except Exception as e: logger.warning(f"Error parsing Europe PMC item: {e}") continue logger.info(f"Europe PMC search returned {len(papers)} papers for query: {query}") except requests.RequestException as e: logger.error(f"Europe PMC search request error: {e}") except Exception as e: logger.error(f"Unexpected error in Europe PMC search: {e}") return papers