Skip to main content
Glama
alexwade

DataCite MCP Server

by alexwade

format_citation

Format a DOI into a citation string. Select from APA, MLA, Chicago, Harvard, IEEE, Vancouver, BibTeX, or CSL JSON style and specify a locale.

Instructions

Format a DOI as a citation string. Supports APA, MLA, Chicago, Harvard, IEEE, Vancouver, BibTeX, and CSL JSON styles.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doiYes
styleNoapa
localeNoen-US

Implementation Reference

  • The registerTool function that registers and implements the 'format_citation' tool. It takes a DOI and optional style/locale, normalizes the DOI, builds an appropriate Accept header, fetches the citation from doi.org, and returns the formatted citation as JSON.
    export function registerTool(server: McpServer): void {
      server.tool(
        "format_citation",
        "Format a DOI as a citation string. Supports APA, MLA, Chicago, Harvard, IEEE, Vancouver, BibTeX, and CSL JSON styles.",
        FormatCitationSchema.shape,
        async (params) => {
          const input = FormatCitationSchema.parse(params);
          const doi = normalizeDoi(input.doi);
          const accept = getAcceptHeader(input.style, input.locale);
          const url = `https://doi.org/${doi}`;
    
          try {
            const citation = await dataciteClient.getText(url, accept);
    
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify({ citation: citation.trim(), style: input.style, doi }, null, 2),
                },
              ],
            };
          } catch (err) {
            const msg = err instanceof Error ? err.message : String(err);
            throw apiError(msg);
          }
        }
      );
    }
  • Zod schema defining the input for format_citation: doi (required string), style (enum with default 'apa'), and locale (string, default 'en-US').
    const FormatCitationSchema = z.object({
      doi: z.string().min(1),
      style: z
        .enum(["apa", "mla", "chicago", "harvard", "ieee", "vancouver", "bibtex", "citeproc-json"])
        .default("apa"),
      locale: z.string().default("en-US"),
    });
  • Import and registration of format_citation in the central tool registration index.
    import { registerTool as registerFormatCitation } from "./format-citation.js";
    import { registerTool as registerGetDoiMetrics } from "./get-doi-metrics.js";
    import { registerTool as registerGetRelatedWorks } from "./get-related-works.js";
    import { registerTool as registerSearchByPerson } from "./search-by-person.js";
    import { registerTool as registerListRepositories } from "./list-repositories.js";
    import { registerTool as registerGetRepository } from "./get-repository.js";
    import { registerTool as registerGetDoiSchemaXml } from "./get-doi-schema-xml.js";
    
    export function registerAllTools(server: McpServer): void {
      registerSearchDois(server);
      registerGetDoi(server);
      registerFormatCitation(server);
  • Helper function getAcceptHeader that maps style names to HTTP Accept headers (e.g., bibtex -> application/x-bibtex, citeproc-json -> application/vnd.citationstyles.csl+json, or text/x-bibliography with style/locale parameters).
    function getAcceptHeader(style: string, locale: string): string {
      if (style === "bibtex") return "application/x-bibtex";
      if (style === "citeproc-json") return "application/vnd.citationstyles.csl+json";
      return `text/x-bibliography; style=${style}; locale=${locale}`;
    }
  • Helper function normalizeDoi that strips URL/DOI prefixes and lowercases the prefix portion.
    export function normalizeDoi(input: string): string {
      let doi = input.trim();
    
      // Strip URL prefixes
      if (doi.toLowerCase().startsWith("https://doi.org/")) {
        doi = doi.slice("https://doi.org/".length);
      } else if (doi.toLowerCase().startsWith("http://doi.org/")) {
        doi = doi.slice("http://doi.org/".length);
      } else if (doi.toLowerCase().startsWith("doi:")) {
        doi = doi.slice("doi:".length);
      }
    
      // Lowercase only the prefix (registrant prefix, e.g. "10.5061")
      const slashIndex = doi.indexOf("/");
      if (slashIndex !== -1) {
        const prefix = doi.slice(0, slashIndex).toLowerCase();
        const suffix = doi.slice(slashIndex + 1);
        doi = `${prefix}/${suffix}`;
      } else {
        doi = doi.toLowerCase();
      }
    
      return doi;
    }
Behavior2/5

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

No annotations provided; description does not disclose behavior such as external API calls, error handling, or rate limits. The tool likely fetches metadata to format, but this is not stated.

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?

Two concise sentences, the first states the purpose and the second lists supported styles. No fluff or repetition.

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

Completeness2/5

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

Given no annotations, no output schema, and 0% param coverage, the description is insufficient. It does not explain the output format, error scenarios, or whether the tool makes network calls.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It partially describes 'doi' and 'style' (via the supported styles list) but completely omits 'locale'. Does not explain the format or validation for any parameter.

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?

Clearly states the action ('Format'), the resource ('a DOI as a citation string'), and lists supported citation styles (APA, MLA, Chicago, etc.). Differentiates from siblings like get_doi which retrieve metadata rather than format citations.

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

Usage Guidelines3/5

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

Implies usage when a citation string is needed for a DOI, but lacks explicit guidance on when to use this tool versus alternatives. No mention of prerequisites, limitations, or when not to use it.

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/alexwade/datacite-mcp'

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