Skip to main content
Glama
botanicastudios

Crossref MCP Server

getWorkByDOI

Retrieve scientific papers using their DOI identifiers to access structured metadata for academic research and citation purposes.

Instructions

Retrieve a specific scientific paper by its DOI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doiYesThe DOI to look up

Implementation Reference

  • mcp-server.js:199-281 (registration)
    MCP server.tool() registration for 'getWorkByDOI', including description, input schema, and full inline handler implementation that fetches Crossref API and returns formatted JSON.
    server.tool(
      "getWorkByDOI",
      "Retrieve a specific scientific paper by its DOI",
      {
        doi: z.string().describe("The DOI to look up"),
      },
      async ({ doi }) => {
        try {
          // Remove any URL prefix if present
          const cleanDoi = doi.replace(/^https?:\/\/doi.org\//, "");
    
          // Use the direct Crossref API endpoint
          const url = `${CROSSREF_API_BASE}/works/${cleanDoi}`;
          const response = await fetch(url, {
            headers: {
              "User-Agent": "Crossref MCP Server",
            },
          });
    
          if (!response.ok) {
            throw new Error(`API request failed with status ${response.status}`);
          }
    
          const data = await response.json();
          const work = data.message;
    
          if (!work) {
            return {
              content: [
                {
                  type: "text",
                  text: JSON.stringify(
                    {
                      status: "not_found",
                      query: { doi },
                      message: `No work found with DOI: ${doi}`,
                    },
                    null,
                    2
                  ),
                },
              ],
            };
          }
    
          const formattedWork = formatWorkToJson(work);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    status: "success",
                    query: { doi },
                    result: formattedWork,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    status: "error",
                    message: error.message,
                    query: { doi },
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      }
    );
  • Input schema definition using Zod for the 'doi' parameter.
    {
      doi: z.string().describe("The DOI to look up"),
    },
  • The core handler logic for getWorkByDOI: cleans DOI, fetches data from Crossref API, handles not found and errors, formats result with helper, returns standardized MCP text content with JSON.
    async ({ doi }) => {
      try {
        // Remove any URL prefix if present
        const cleanDoi = doi.replace(/^https?:\/\/doi.org\//, "");
    
        // Use the direct Crossref API endpoint
        const url = `${CROSSREF_API_BASE}/works/${cleanDoi}`;
        const response = await fetch(url, {
          headers: {
            "User-Agent": "Crossref MCP Server",
          },
        });
    
        if (!response.ok) {
          throw new Error(`API request failed with status ${response.status}`);
        }
    
        const data = await response.json();
        const work = data.message;
    
        if (!work) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    status: "not_found",
                    query: { doi },
                    message: `No work found with DOI: ${doi}`,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
    
        const formattedWork = formatWorkToJson(work);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  status: "success",
                  query: { doi },
                  result: formattedWork,
                },
                null,
                2
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  status: "error",
                  message: error.message,
                  query: { doi },
                },
                null,
                2
              ),
            },
          ],
        };
      }
    }
  • Supporting utility function formatWorkToJson that transforms raw Crossref work data into a clean, structured JSON object with fields like title, authors, published dates, DOI, etc.
    export const formatWorkToJson = (work) => {
      if (!work) return { error: "No data available" };
    
      return {
        title: work.title?.[0] || null,
        authors: work.author
          ? work.author.map((a) => ({
              given: a.given || null,
              family: a.family || null,
              name: `${a.given || ""} ${a.family || ""}`.trim(),
            }))
          : [],
        published: work.published
          ? {
              dateParts: work.published["date-parts"]?.[0] || [],
              dateString: work.published["date-parts"]?.[0]?.join("-") || null,
            }
          : null,
        type: work.type || null,
        doi: work.DOI || null,
        url: work.URL || null,
        container: work["container-title"]?.[0] || null,
        publisher: work.publisher || null,
        issue: work.issue || null,
        volume: work.volume || null,
        abstract: work.abstract || null,
      };
    };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the retrieval action but doesn't mention error handling (e.g., invalid DOI), rate limits, authentication needs, or what happens if the paper isn't found. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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 gets straight to the point with zero wasted words. It's appropriately sized for this simple lookup tool and front-loads the essential information.

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 the lack of annotations and output schema, the description is insufficiently complete. It doesn't explain what format the paper is returned in (metadata, full text, citation), error conditions, or any limitations. For a retrieval tool with no structured output documentation, more context is needed.

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 the 'doi' parameter adequately. The description adds no additional parameter semantics beyond what's in the schema, maintaining the baseline score for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('Retrieve') and resource ('specific scientific paper by its DOI'), making the purpose immediately understandable. It doesn't explicitly distinguish from sibling tools (searchByAuthor, searchByTitle), but the DOI-based retrieval is inherently different from author/title searches.

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?

No guidance is provided about when to use this tool versus the sibling search tools. The description implies it's for DOI-based lookups, but there's no explicit comparison or mention of alternatives, leaving the agent to infer usage context.

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/botanicastudios/crossref-mcp'

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