Skip to main content
Glama
ElliotPadfield

Unpaywall MCP Server

unpaywall_get_by_doi

Fetch Unpaywall metadata for academic papers using a DOI to retrieve open access information and PDF links for research purposes.

Instructions

Fetch Unpaywall metadata for a DOI (accepts DOI, DOI URL, or 'doi:' prefix). Requires an email address via env UNPAYWALL_EMAIL or the optional 'email' argument.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doiYesDOI string or DOI URL, e.g. 10.1038/nphys1170 or https://doi.org/10.1038/nphys1170
emailNoEmail to identify your requests to Unpaywall (optional override)

Implementation Reference

  • Executes the 'unpaywall_get_by_doi' tool: validates DOI and email arguments, normalizes the DOI, fetches metadata from Unpaywall API, and returns the JSON response.
    if (tool === TOOL_GET_BY_DOI) {
      const args = (req.params.arguments ?? {}) as Partial<GetByDoiArgs>;
      const rawDoi = (args.doi ?? "").toString().trim();
      if (!rawDoi) {
        return {
          content: [
            { type: "text", text: "Missing required argument: 'doi'" },
          ],
          isError: true,
        };
      }
    
      const email = (args.email || process.env.UNPAYWALL_EMAIL || "").toString().trim();
      if (!email) {
        return {
          content: [
            {
              type: "text",
              text: "Unpaywall requires an email. Set UNPAYWALL_EMAIL env var for the server or pass 'email' in the tool arguments.",
            },
          ],
          isError: true,
        };
      }
    
      const doi = normalizeDoi(rawDoi);
      const data = await fetchUnpaywallByDoi(doi, email);
      return {
        content: [{ type: "json", json: data }],
      };
    }
  • src/index.ts:136-149 (registration)
    Registers the 'unpaywall_get_by_doi' tool in the listTools response, providing name, description, and input schema.
    {
      name: TOOL_GET_BY_DOI,
      description:
        "Fetch Unpaywall metadata for a DOI (accepts DOI, DOI URL, or 'doi:' prefix). Requires an email address via env UNPAYWALL_EMAIL or the optional 'email' argument.",
      inputSchema: {
        type: "object",
        properties: {
          doi: { type: "string", description: "DOI string or DOI URL, e.g. 10.1038/nphys1170 or https://doi.org/10.1038/nphys1170" },
          email: { type: "string", description: "Email to identify your requests to Unpaywall (optional override)" },
        },
        required: ["doi"],
        additionalProperties: false,
      },
    },
  • Input schema (JSON Schema) defining the parameters for the 'unpaywall_get_by_doi' tool: required 'doi' string and optional 'email'.
    inputSchema: {
      type: "object",
      properties: {
        doi: { type: "string", description: "DOI string or DOI URL, e.g. 10.1038/nphys1170 or https://doi.org/10.1038/nphys1170" },
        email: { type: "string", description: "Email to identify your requests to Unpaywall (optional override)" },
      },
      required: ["doi"],
      additionalProperties: false,
    },
  • Helper function that performs the actual API fetch to Unpaywall for a given DOI and email, with timeout and error handling.
    async function fetchUnpaywallByDoi(doi: string, email: string) {
      const controller = new AbortController();
      const timeout = setTimeout(() => controller.abort(), 20_000);
      try {
        const url = `https://api.unpaywall.org/v2/${encodeURIComponent(doi)}?email=${encodeURIComponent(email)}`;
        const resp = await fetch(url, { signal: controller.signal, headers: { "Accept": "application/json" } });
        if (!resp.ok) {
          const text = await resp.text().catch(() => "");
          throw new Error(`Unpaywall HTTP ${resp.status}: ${text.slice(0, 400)}`);
        }
        return await resp.json();
      } finally {
        clearTimeout(timeout);
      }
    }
  • Utility function to normalize DOI input by removing common URL prefixes and 'doi:' prefix.
    function normalizeDoi(input: string): string {
      let doi = input.trim();
      // Strip common DOI URL prefixes
      doi = doi.replace(/^https?:\/\/(dx\.)?doi\.org\//i, "");
      // Strip leading 'doi:' prefix
      doi = doi.replace(/^doi:/i, "");
      return doi.trim();
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the tool requires an email address (via env or argument) for identification to Unpaywall, implying authentication needs. However, it lacks details on rate limits, error handling, or response format, leaving gaps in behavioral context.

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 appropriately sized and front-loaded, with two sentences that efficiently convey purpose, input formats, and requirements without any wasted words. Every sentence adds essential information, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers authentication needs and input formats but lacks details on output (metadata structure), error cases, or performance constraints, which would be helpful for an AI agent.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal value beyond the schema by mentioning the 'doi:' prefix as an accepted format and noting the email requirement, but does not provide additional syntax or usage details for parameters.

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 specific action ('Fetch Unpaywall metadata') and resource ('for a DOI'), distinguishing it from sibling tools like fetching PDF text or searching titles. It specifies the exact input formats accepted (DOI, DOI URL, or 'doi:' prefix), making the purpose unambiguous.

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

Usage Guidelines4/5

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

The description provides clear context on when to use this tool (for fetching metadata by DOI) and mentions an alternative (using the 'email' argument vs. env variable), but does not explicitly state when not to use it or differentiate from siblings like 'unpaywall_get_fulltext_links' beyond the metadata focus.

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/ElliotPadfield/unpaywall-mcp'

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