Skip to main content
Glama

export_citation

Export a PubMed citation in APA, MLA, Chicago, BibTeX, or RIS format by providing the PubMed ID.

Instructions

Export citation in various formats (APA, MLA, Chicago, BibTeX, RIS)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pmidYesPubMed ID
formatNoCitation format (default: apa)

Implementation Reference

  • src/index.ts:374-391 (registration)
    Tool registration for 'export_citation' with input schema (pmid required, optional format with enum of apa/mla/chicago/bibtex/ris)
    {
      name: 'export_citation',
      description: 'Export citation in various formats (APA, MLA, Chicago, BibTeX, RIS)',
      inputSchema: {
        type: 'object',
        properties: {
          pmid: {
            type: 'string',
            description: 'PubMed ID'
          },
          format: {
            type: 'string',
            enum: ['apa', 'mla', 'chicago', 'bibtex', 'ris'],
            description: 'Citation format (default: apa)'
          }
        },
        required: ['pmid']
      }
  • Handler function for export_citation: validates PMID, fetches article details, and formats citation
    async function handleExportCitation(args: any) {
      const { pmid, format = 'apa' } = args;
    
      if (!isValidPMID(pmid)) {
        throw new Error(`Invalid PMID format: ${pmid}`);
      }
    
      const article = await eutilsClient.getArticleDetails(pmid);
      const citation = formatCitation(article, format as any);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              pmid,
              format,
              citation
            }, null, 2)
          }
        ]
      };
    }
  • Switch case dispatching to handleExportCitation
    case 'export_citation':
      return await handleExportCitation(args);
  • formatCitation helper function that dispatches to individual formatters (APA, MLA, Chicago, BibTeX, RIS) based on style
    export function formatCitation(
      article: {
        authors: Array<{ lastName: string; foreName?: string; initials?: string }>;
        title: string;
        journal: string;
        publicationDate: string;
        volume?: string;
        issue?: string;
        pages?: string;
        doi?: string;
      },
      style: 'apa' | 'mla' | 'chicago' | 'bibtex' | 'ris'
    ): string {
      const year = article.publicationDate.split('-')[0];
      const authorList = article.authors.slice(0, 20); // Limit to first 20 authors
    
      switch (style) {
        case 'apa':
          return formatAPACitation(article, authorList, year);
        case 'mla':
          return formatMLACitation(article, authorList, year);
        case 'chicago':
          return formatChicagoCitation(article, authorList, year);
        case 'bibtex':
          return formatBibTeXCitation(article, authorList, year);
        case 'ris':
          return formatRISCitation(article, authorList, year);
        default:
          return formatAPACitation(article, authorList, year);
      }
    }
  • RIS citation formatter helper (one of the five format styles supported)
    function formatRISCitation(article: any, authors: any[], year: string): string {
      let ris = 'TY  - JOUR\n';
    
      authors.forEach(a => {
        ris += `AU  - ${a.lastName}, ${a.foreName || a.initials}\n`;
      });
    
      ris += `TI  - ${article.title}\n`;
      ris += `JO  - ${article.journal}\n`;
      ris += `PY  - ${year}\n`;
    
      if (article.volume) ris += `VL  - ${article.volume}\n`;
      if (article.issue) ris += `IS  - ${article.issue}\n`;
      if (article.pages) ris += `SP  - ${article.pages.split('-')[0]}\n`;
      if (article.pages && article.pages.includes('-')) {
        ris += `EP  - ${article.pages.split('-')[1]}\n`;
      }
      if (article.doi) ris += `DO  - ${article.doi}\n`;
    
      ris += 'ER  - \n';
    
      return ris;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden. It implies a simple read operation (export citation) but does not disclose if the operation is idempotent, requires authentication, or has rate limits. However, the tool is straightforward enough that an agent might infer basic behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that conveys all essential information without redundancy. It is front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with two parameters and no output schema. The description explains inputs and outputs adequately, though it does not specify the return format (e.g., plain text string) or any post-processing expectations. Given the simplicity, this is a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema covers 100% of parameters with descriptions. The description adds value by specifying the default format ('apa'), which is not indicated in the schema enum. It also lists the available formats, reinforcing the parameter options.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: exporting citations. It lists specific output formats (APA, MLA, Chicago, BibTeX, RIS) and the required input (PubMed ID). This distinguishes it from sibling tools like 'get_article_details' which do not offer citation export.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool over alternatives. For example, it doesn't mention if it should be used when a formatted citation string is needed, or if other tools like 'get_cited_by' should be used for related tasks. No exclusions or alternative suggestions are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Augmented-Nature/PubMed-MCP-Server'

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