Skip to main content
Glama

searchByAuthor

Find scientific papers in the Crossref database by entering an author's name. Specify the number of results to retrieve structured metadata for research publications efficiently.

Instructions

Search for scientific papers by author in Crossref

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
authorYesThe author name to search for
rowsNoNumber of results to return

Implementation Reference

  • Core execution logic for the searchByAuthor tool: queries Crossref API with author name, handles response, formats results using formatWorkToJson, and returns structured JSON content.
    async ({ author, rows }) => { try { const url = `${CROSSREF_API_BASE}/works?query.author=${encodeURIComponent( author )}&rows=${rows}&select=${CROSSREF_SELECT_FIELDS}`; 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 works = data.message?.items || []; if (works.length === 0) { return { content: [ { type: "text", text: JSON.stringify( { status: "no_results", query: { author, rows }, results: [], }, null, 2 ), }, ], }; } const formattedWorks = works.map((work) => formatWorkToJson(work)); return { content: [ { type: "text", text: JSON.stringify( { status: "success", query: { author, rows }, count: formattedWorks.length, results: formattedWorks, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { status: "error", message: error.message, query: { author, rows }, }, null, 2 ), }, ], }; } }
  • Zod schema defining input parameters for the searchByAuthor tool: author (string) and optional rows (number, default 5).
    { author: z.string().describe("The author name to search for"), rows: z .number() .optional() .default(5) .describe("Number of results to return"), },
  • mcp-server.js:110-196 (registration)
    MCP server.tool call that registers the searchByAuthor tool, including description, input schema, and handler function.
    server.tool( "searchByAuthor", "Search for scientific papers by author in Crossref", { author: z.string().describe("The author name to search for"), rows: z .number() .optional() .default(5) .describe("Number of results to return"), }, async ({ author, rows }) => { try { const url = `${CROSSREF_API_BASE}/works?query.author=${encodeURIComponent( author )}&rows=${rows}&select=${CROSSREF_SELECT_FIELDS}`; 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 works = data.message?.items || []; if (works.length === 0) { return { content: [ { type: "text", text: JSON.stringify( { status: "no_results", query: { author, rows }, results: [], }, null, 2 ), }, ], }; } const formattedWorks = works.map((work) => formatWorkToJson(work)); return { content: [ { type: "text", text: JSON.stringify( { status: "success", query: { author, rows }, count: formattedWorks.length, results: formattedWorks, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { status: "error", message: error.message, query: { author, rows }, }, null, 2 ), }, ], }; } } );
  • Utility function to format individual Crossref work objects into a standardized JSON structure, used by the searchByAuthor handler to process API results.
    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, }; };
  • Test implementation of searchByAuthor handler, nearly identical to main but used for testing purposes.
    searchByAuthor: async ({ author, rows = 5 }) => { try { const url = `https://api.crossref.org/works?query.author=${encodeURIComponent( author )}&rows=${rows}`; const response = await fetch(url, { headers: { "User-Agent": "Crossref MCP Server Test", }, }); if (!response.ok) { throw new Error(`API request failed with status ${response.status}`); } const data = await response.json(); const works = data.message?.items || []; if (works.length === 0) { return { content: [ { type: "text", text: JSON.stringify( { status: "no_results", query: { author, rows }, results: [], }, null, 2 ), }, ], }; } const formattedWorks = works.map((work) => formatWorkToJson(work)); return { content: [ { type: "text", text: JSON.stringify( { status: "success", query: { author, rows }, count: formattedWorks.length, results: formattedWorks, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( { status: "error", message: error.message, query: { author, rows }, }, null, 2 ), }, ], }; } },

Other Tools

Related 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