export_bibtex
Export BibTeX citations from NASA ADS for LaTeX or Quarto documents by providing paper bibcodes.
Instructions
Export BibTeX citations for one or more papers. Useful for adding references to LaTeX/Quarto documents.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bibcodes | Yes | List of ADS bibcodes to export |
Implementation Reference
- src/nasa_ads_mcp/server.py:463-507 (handler)Main handler function that implements the export_bibtex tool logic by querying ADS for paper details and generating BibTeX entries.async def export_bibtex(bibcodes: list[str]) -> list[TextContent]: """Export BibTeX citations for papers.""" try: bibtex_entries = [] for bibcode in bibcodes: # Get paper with BibTeX data papers = list(ads.SearchQuery(bibcode=bibcode)) if not papers: bibtex_entries.append(f"% Paper not found: {bibcode}\n") continue paper = papers[0] # Generate BibTeX entry authors_str = " and ".join(paper.author) if paper.author else "Unknown" title = paper.title[0] if paper.title else "No title" entry = f"""@ARTICLE{{{bibcode}, author = {{{authors_str}}}, title = {{{title}}}, journal = {{{paper.pub or 'Unknown'}}}, year = {paper.year}, adsurl = {{https://ui.adsabs.harvard.edu/abs/{bibcode}}}, }} """ bibtex_entries.append(entry) if not bibtex_entries: return [TextContent( type="text", text="No valid bibcodes provided" )] response = "BibTeX Citations:\n\n" + "\n".join(bibtex_entries) return [TextContent(type="text", text=response)] except Exception as e: logger.error(f"Error exporting BibTeX: {e}") return [TextContent( type="text", text=f"Error exporting BibTeX: {str(e)}" )]
- src/nasa_ads_mcp/server.py:123-140 (registration)Tool registration in the list_tools() function, defining the tool name, description, and input schema.Tool( name="export_bibtex", description=( "Export BibTeX citations for one or more papers. " "Useful for adding references to LaTeX/Quarto documents." ), inputSchema={ "type": "object", "properties": { "bibcodes": { "type": "array", "items": {"type": "string"}, "description": "List of ADS bibcodes to export", }, }, "required": ["bibcodes"], }, ),
- src/nasa_ads_mcp/server.py:129-139 (schema)Input schema definition for the export_bibtex tool, specifying bibcodes as a required array of strings.inputSchema={ "type": "object", "properties": { "bibcodes": { "type": "array", "items": {"type": "string"}, "description": "List of ADS bibcodes to export", }, }, "required": ["bibcodes"], },
- src/nasa_ads_mcp/server.py:282-283 (handler)Dispatcher in call_tool() that routes calls to the export_bibtex handler.elif name == "export_bibtex": return await export_bibtex(bibcodes=arguments["bibcodes"])