Skip to main content
Glama

searchByAuthor

Find scientific papers by author name using Crossref's database, returning structured metadata for academic research.

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

  • The primary handler function that executes the searchByAuthor tool logic: queries Crossref API with author name, fetches works, formats them using formatWorkToJson, and returns JSON-structured 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 input schema defining parameters for the searchByAuthor tool: required '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-197 (registration)
    Registration of the 'searchByAuthor' tool via McpServer.tool() method, specifying name, 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 ), }, ], }; } } );
  • Test handler for searchByAuthor, identical logic for use in testing contexts.
    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 ), }, ], }; } },

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