export_citations
Export PubMed article citations in formats like BibTeX, EndNote, or APA for use in research papers and reference managers.
Instructions
Export article citations in various formats
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pmids | Yes | List of PubMed IDs to export | |
| format | No | Citation format | bibtex |
| include_abstracts | No | Include abstracts in citations |
Implementation Reference
- src/tool_handler.py:297-340 (handler)Main handler function implementing the export_citations tool: validates PMIDs, fetches article details, formats citations using CitationFormatter, and returns MCPResponse.
async def _handle_export_citations(self, arguments: Dict[str, Any]) -> MCPResponse: """Handle citation export.""" try: pmids = arguments.get("pmids", []) if not pmids: return MCPResponse( content=[{"type": "text", "text": "PMIDs parameter is required"}], is_error=True ) format_type = CitationFormat(arguments.get("format", "bibtex")) # Get article details articles = await self.pubmed_client.get_article_details( pmids=pmids, include_abstracts=True, # Always get abstracts for citation cache=self.cache, ) if not articles: return MCPResponse( content=[{"type": "text", "text": "No articles found for the provided PMIDs"}], is_error=True, ) # Format citations citations = CitationFormatter.format_multiple_citations( articles=articles, format_type=format_type ) content = [] content.append( { "type": "text", "text": f"**Citations in {format_type.value.upper()} format**\n\n{citations}", } ) return MCPResponse(content=content) except Exception as e: logger.error(f"Error in export_citations: {e}") return MCPResponse( content=[{"type": "text", "text": f"Error: {str(e)}"}], is_error=True ) - src/tools.py:161-186 (schema)JSON schema defining the input parameters for the export_citations tool, including PMIDs (required), format (default bibtex), and include_abstracts.
{ "name": "export_citations", "description": "Export article citations in various formats", "inputSchema": { "type": "object", "properties": { "pmids": { "type": "array", "items": {"type": "string"}, "description": "List of PubMed IDs to export", }, "format": { "type": "string", "enum": ["bibtex", "endnote", "ris", "apa", "mla", "chicago", "vancouver"], "default": "bibtex", "description": "Citation format", }, "include_abstracts": { "type": "boolean", "default": False, "description": "Include abstracts in citations", }, }, "required": ["pmids"], }, }, - src/tool_handler.py:65-78 (registration)Tool handler routing map that registers 'export_citations' to its handler function _handle_export_citations.
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, }