Skip to main content
Glama
ElliotPadfield

Unpaywall MCP Server

unpaywall_get_fulltext_links

Retrieve open-access PDF links and metadata for academic papers by providing a DOI, enabling access to scholarly literature for research.

Instructions

Given a DOI, return best open-access links (best PDF URL and open URL) plus Unpaywall locations metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doiYesDOI string or DOI URL
emailNoEmail to identify your requests to Unpaywall (optional override)

Implementation Reference

  • Executes the unpaywall_get_fulltext_links tool: validates args, normalizes DOI, fetches Unpaywall data, extracts best PDF/open URLs and metadata.
    if (tool === TOOL_GET_FULLTEXT_LINKS) {
      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 or pass 'email'." }], isError: true };
      }
      const doi = normalizeDoi(rawDoi);
      const obj = await fetchUnpaywallByDoi(doi, email);
      const best = obj?.best_oa_location ?? null;
      const locations: any[] = Array.isArray(obj?.oa_locations) ? obj.oa_locations : [];
      const pickPdfFrom = (locs: any[]) => locs.find(l => l?.url_for_pdf) || locs.find(l => l?.url);
      const bestPdfUrl = best?.url_for_pdf || best?.url || (pickPdfFrom(locations)?.url_for_pdf || pickPdfFrom(locations)?.url) || null;
      const bestOpenUrl = best?.url || (locations.find(l => l?.url)?.url) || null;
      const result = {
        doi: obj?.doi ?? doi,
        title: obj?.title ?? null,
        is_oa: obj?.is_oa ?? null,
        oa_status: obj?.oa_status ?? null,
        best_pdf_url: bestPdfUrl,
        best_open_url: bestOpenUrl,
        best_oa_location: best,
        oa_locations: locations,
      };
      return { content: [{ type: "json", json: result }] };
    }
  • Input schema definition for the unpaywall_get_fulltext_links tool, registered in ListTools response.
    {
      name: TOOL_GET_FULLTEXT_LINKS,
      description: "Given a DOI, return best open-access links (best PDF URL and open URL) plus Unpaywall locations metadata.",
      inputSchema: {
        type: "object",
        properties: {
          doi: { type: "string", description: "DOI string or DOI URL" },
          email: { type: "string", description: "Email to identify your requests to Unpaywall (optional override)" },
        },
        required: ["doi"],
        additionalProperties: false,
      },
    },
  • src/index.ts:133-195 (registration)
    Registration of all tools including unpaywall_get_fulltext_links in the ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            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,
            },
          },
          {
            name: TOOL_SEARCH_TITLES,
            description: "Search Unpaywall for article titles matching a query. Supports optional is_oa filter and pagination (50 results per page).",
            inputSchema: {
              type: "object",
              properties: {
                query: { type: "string", description: "Title search query (supports phrase, boolean operators per Unpaywall docs)" },
                is_oa: { type: "boolean", description: "If true, only return OA results; if false, only closed; omit for all" },
                page: { type: "integer", minimum: 1, description: "Page number (50 results per page)" },
                email: { type: "string", description: "Email to identify your requests to Unpaywall (optional override)" },
              },
              required: ["query"],
              additionalProperties: false,
            },
          },
          {
            name: TOOL_GET_FULLTEXT_LINKS,
            description: "Given a DOI, return best open-access links (best PDF URL and open URL) plus Unpaywall locations metadata.",
            inputSchema: {
              type: "object",
              properties: {
                doi: { type: "string", description: "DOI string or DOI URL" },
                email: { type: "string", description: "Email to identify your requests to Unpaywall (optional override)" },
              },
              required: ["doi"],
              additionalProperties: false,
            },
          },
          {
            name: TOOL_FETCH_PDF_TEXT,
            description: "Download and extract text from best OA PDF for a DOI, or from a provided PDF URL.",
            inputSchema: {
              type: "object",
              properties: {
                doi: { type: "string", description: "DOI string or DOI URL. Used if pdf_url is not provided." },
                pdf_url: { type: "string", description: "Direct PDF URL to download and parse (takes precedence over DOI)." },
                email: { type: "string", description: "Email to identify requests to Unpaywall (required when resolving via DOI)." },
                truncate_chars: { type: "integer", minimum: 1000, description: "Max characters of extracted text to return (default 20000)." },
              },
              required: [],
              additionalProperties: false,
            },
          },
        ],
      };
    });
  • Helper function to fetch Unpaywall metadata by DOI, used by the tool handler.
    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);
      }
    }
  • Helper function to normalize DOI input by stripping prefixes.
    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 of behavioral disclosure. It describes what the tool returns (links and metadata) but does not mention rate limits, authentication needs (though 'email' is optional), error handling, or data freshness. It adds basic context but lacks details on operational traits like performance or constraints.

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, efficient sentence that front-loads the core functionality ('return best open-access links') and includes key details (PDF URL, open URL, metadata) without waste. Every word earns its place, 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.

Completeness4/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 reasonably complete. It specifies the input (DOI) and output (links and metadata), but without an output schema, it could benefit from more detail on return values (e.g., structure or examples). It covers the essentials but has minor gaps in output clarification.

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 ('doi' as required string and 'email' as optional override). The description adds no additional meaning beyond what the schema provides, such as format examples or usage tips for parameters. Baseline 3 is appropriate when schema does the heavy lifting.

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 ('return best open-access links') and resource ('given a DOI'), distinguishing it from siblings like 'unpaywall_fetch_pdf_text' (which extracts text) and 'unpaywall_search_titles' (which searches titles). It explicitly mentions the output includes 'best PDF URL and open URL' plus metadata, making the purpose highly specific and differentiated.

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 implies usage context by specifying 'given a DOI' for retrieving open-access links, but it does not explicitly state when to use this tool versus alternatives like 'unpaywall_get_by_doi' (which might return different data) or 'unpaywall_fetch_pdf_text' (which focuses on text extraction). It provides clear context but lacks explicit exclusions or named alternatives.

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