get_doi_schema_xml
Retrieve the raw DataCite Metadata Schema XML for a given DOI to inspect the complete, canonical metadata record.
Instructions
Fetch the raw DataCite Metadata Schema XML for a DOI (base64-decoded). Useful for inspecting the complete, canonical metadata record.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doi | Yes |
Implementation Reference
- src/tools/get-doi-schema-xml.ts:13-66 (handler)The registerTool function that registers the 'get_doi_schema_xml' tool with the MCP server. The handler normalizes the DOI, fetches the record via the DataCite API (with caching), base64-decodes the XML from the response attributes, and returns it. Handles 404 errors and other API errors.
export function registerTool(server: McpServer): void { server.tool( "get_doi_schema_xml", "Fetch the raw DataCite Metadata Schema XML for a DOI (base64-decoded). Useful for inspecting the complete, canonical metadata record.", GetDoiSchemaXmlSchema.shape, async (params) => { const input = GetDoiSchemaXmlSchema.parse(params); const doi = normalizeDoi(input.doi); try { const record = await getCached<DoiRecord>( doiCache, doi, () => dataciteClient .get<DoiResponse>(`/dois/${encodeURIComponent(doi)}`, { detail: true }) .then((r) => r.data) ); if (!record.attributes.xml) { return { content: [ { type: "text" as const, text: JSON.stringify( { doi, xml: null, message: "No XML available for this DOI." }, null, 2 ), }, ], }; } const xml = Buffer.from(record.attributes.xml, "base64").toString("utf-8"); return { content: [ { type: "text" as const, text: JSON.stringify({ doi, xml }, null, 2), }, ], }; } catch (err) { if (err instanceof DataCiteError && err.statusCode === 404) { throw notFound(doi); } const msg = err instanceof Error ? err.message : String(err); throw apiError(msg); } } ); } - src/tools/get-doi-schema-xml.ts:9-11 (schema)Zod schema defining the input: a single required 'doi' string.
const GetDoiSchemaXmlSchema = z.object({ doi: z.string().min(1), }); - src/tools/index.ts:10-22 (registration)Import and registration of get_doi_schema_xml in the central tools index.
import { registerTool as registerGetDoiSchemaXml } from "./get-doi-schema-xml.js"; export function registerAllTools(server: McpServer): void { registerSearchDois(server); registerGetDoi(server); registerFormatCitation(server); registerGetDoiMetrics(server); registerGetRelatedWorks(server); registerSearchByPerson(server); registerListRepositories(server); registerGetRepository(server); registerGetDoiSchemaXml(server); } - Type declaration for the registerTool export.
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; export declare function registerTool(server: McpServer): void;