Skip to main content
Glama

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
NameRequiredDescriptionDefault
bibcodesYesList of ADS bibcodes to export

Implementation Reference

  • 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)}" )]
  • 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"], }, ),
  • 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"], },
  • Dispatcher in call_tool() that routes calls to the export_bibtex handler.
    elif name == "export_bibtex": return await export_bibtex(bibcodes=arguments["bibcodes"])

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/prtc/nasa-ads-mcp'

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