Skip to main content
Glama
alexwade

DataCite MCP Server

by alexwade

get_related_works

Explore the relationship graph for a DOI by retrieving citations, references, versions, and parts. Specify relation type and page size to filter results.

Instructions

Explore the relationship graph for a DOI — citations, references, versions, and parts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
doiYes
relation_typeNoall
page_sizeNo

Implementation Reference

  • Main handler: registers the 'get_related_works' tool on the MCP server. The async callback fetches the base DOI record, then resolves citations (via DataCite /citations endpoint), references (via /references endpoint with fallback to relatedIdentifiers), versions, parts/part-of by filtering relatedIdentifiers by relation type. Results are deduplicated by DOI, formatted via formatDoiSummary, and returned as JSON.
    export function registerTool(server: McpServer): void {
      server.tool(
        "get_related_works",
        "Explore the relationship graph for a DOI — citations, references, versions, and parts.",
        RelatedWorksSchema.shape,
        async (params) => {
          const input = RelatedWorksSchema.parse(params);
          const doi = normalizeDoi(input.doi);
    
          try {
            // Fetch the base record for its relatedIdentifiers
            const record = await getCached<DoiRecord>(
              doiCache,
              doi,
              () =>
                dataciteClient
                  .get<DoiResponse>(`/dois/${encodeURIComponent(doi)}`, { detail: true })
                  .then((r) => r.data)
            );
    
            const relatedIdentifiers = record.attributes.relatedIdentifiers ?? [];
            const rt = input.relation_type;
    
            let works: DoiRecord[] = [];
            let total = 0;
    
            if (rt === "citations" || rt === "all") {
              // Fetch works that cite this DOI via DataCite events / relatedIdentifiers
              try {
                const citationResp = await getCached<SearchResponse>(
                  searchCache,
                  `citations:${doi}:${input.page_size}`,
                  () =>
                    dataciteClient.get<SearchResponse>(`/dois/${encodeURIComponent(doi)}/citations`, {
                      "page[size]": input.page_size,
                      detail: true,
                    })
                );
                const citationWorks = citationResp.data ?? [];
                works = [...works, ...citationWorks];
                total += citationResp.meta?.total ?? citationWorks.length;
              } catch {
                // Citations endpoint may not exist; skip gracefully
              }
            }
    
            if (rt === "references" || rt === "all") {
              try {
                const refResp = await getCached<SearchResponse>(
                  searchCache,
                  `references:${doi}:${input.page_size}`,
                  () =>
                    dataciteClient.get<SearchResponse>(`/dois/${encodeURIComponent(doi)}/references`, {
                      "page[size]": input.page_size,
                      detail: true,
                    })
                );
                const refWorks = refResp.data ?? [];
                works = [...works, ...refWorks];
                total += refResp.meta?.total ?? refWorks.length;
              } catch {
                // Fallback: filter relatedIdentifiers
                const refDois = relatedIdentifiers
                  .filter((ri) => REFERENCE_RELATION_TYPES.includes(ri.relationType))
                  .slice(0, input.page_size)
                  .map((ri) => ri.relatedIdentifier);
    
                for (const relDoi of refDois) {
                  try {
                    const relRecord = await getCached<DoiRecord>(
                      doiCache,
                      normalizeDoi(relDoi),
                      () =>
                        dataciteClient
                          .get<DoiResponse>(`/dois/${encodeURIComponent(normalizeDoi(relDoi))}`, {
                            detail: true,
                          })
                          .then((r) => r.data)
                    );
                    works.push(relRecord);
                  } catch {
                    // skip individual failures
                  }
                }
                total += refDois.length;
              }
            }
    
            if (rt === "versions" || rt === "all") {
              const versionDois = relatedIdentifiers
                .filter((ri) => VERSION_RELATION_TYPES.includes(ri.relationType))
                .slice(0, input.page_size)
                .map((ri) => ri.relatedIdentifier);
    
              for (const relDoi of versionDois) {
                try {
                  const relRecord = await getCached<DoiRecord>(
                    doiCache,
                    normalizeDoi(relDoi),
                    () =>
                      dataciteClient
                        .get<DoiResponse>(`/dois/${encodeURIComponent(normalizeDoi(relDoi))}`, {
                          detail: true,
                        })
                        .then((r) => r.data)
                  );
                  works.push(relRecord);
                } catch {
                  // skip
                }
              }
              total += versionDois.length;
            }
    
            if (rt === "parts" || rt === "part-of" || rt === "all") {
              const partDois = relatedIdentifiers
                .filter((ri) => PART_RELATION_TYPES.includes(ri.relationType))
                .slice(0, input.page_size)
                .map((ri) => ri.relatedIdentifier);
    
              for (const relDoi of partDois) {
                try {
                  const relRecord = await getCached<DoiRecord>(
                    doiCache,
                    normalizeDoi(relDoi),
                    () =>
                      dataciteClient
                        .get<DoiResponse>(`/dois/${encodeURIComponent(normalizeDoi(relDoi))}`, {
                          detail: true,
                        })
                        .then((r) => r.data)
                  );
                  works.push(relRecord);
                } catch {
                  // skip
                }
              }
              total += partDois.length;
            }
    
            // Deduplicate by DOI
            const seen = new Set<string>();
            const unique = works.filter((w) => {
              const id = w.attributes?.doi ?? w.id;
              if (seen.has(id)) return false;
              seen.add(id);
              return true;
            });
    
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      doi,
                      relation_type: input.relation_type,
                      works: unique.map(formatDoiSummary),
                      total,
                    },
                    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);
          }
        }
      );
    }
  • RelatedWorksSchema: Zod schema defining input validation — doi (required string), relation_type (enum: citations, references, versions, parts, part-of, all; default 'all'), and page_size (int, 1-50, default 10).
    const RelatedWorksSchema = z.object({
      doi: z.string().min(1),
      relation_type: z
        .enum(["citations", "references", "versions", "parts", "part-of", "all"])
        .default("all"),
      page_size: z.number().int().min(1).max(50).default(10),
    });
  • Registration entry point: imports registerTool as registerGetRelatedWorks from './get-related-works.js' and calls it inside registerAllTools at line 17.
    import { registerTool as registerGetRelatedWorks } from "./get-related-works.js";
    import { registerTool as registerSearchByPerson } from "./search-by-person.js";
    import { registerTool as registerListRepositories } from "./list-repositories.js";
    import { registerTool as registerGetRepository } from "./get-repository.js";
    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);
  • formatDoiSummary helper: transforms a DoiRecord into a plain object with doi, title, creators (first 3), year, resource_type, publisher, abstract_snippet (truncated to 300 chars), view/download/citation counts.
    export function formatDoiSummary(record: DoiRecord): object {
      const a = record.attributes;
      const title = a.titles?.[0]?.title ?? "(no title)";
      const creators = (a.creators ?? []).slice(0, 3).map(formatCreator);
      const firstDesc = a.descriptions?.[0]?.description ?? "";
      const abstract_snippet = firstDesc.length > 300 ? firstDesc.slice(0, 300) + "…" : firstDesc;
    
      return {
        doi: a.doi ?? record.id,
        title,
        creators,
        year: a.publicationYear,
        resource_type: a.types?.resourceTypeGeneral ?? a.resourceTypeGeneral,
        publisher: a.publisher,
        abstract_snippet: abstract_snippet || undefined,
        view_count: a.viewCount,
        download_count: a.downloadCount,
        citation_count: a.citationCount,
      };
    }
  • getCached helper: generic LRU cache wrapper used heavily by the handler to cache DataCite API responses for DOI records, citations, references, and other search results.
    export async function getCached<T extends {}>(
      cache: LRUCache<string, T>,
      key: string,
      fetcher: () => Promise<T>
    ): Promise<T> {
      const hit = cache.get(key);
      if (hit !== undefined) return hit;
      const value = await fetcher();
      cache.set(key, value);
      return value;
    }
Behavior2/5

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

No annotations are provided, so the description carries full weight. It only says 'Explore' (implying read-only) but does not disclose pagination (page_size parameter exists but not mentioned), rate limits, authentication needs, or any side effects. The return structure is also unclear without an output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (13 words), front-loaded with the core verb and resource. No filler sentences. However, it sacrifices completeness for brevity; a slightly longer but more informative description would be better.

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 three parameters, no output schema, and no annotations, the description is insufficient. It doesn't address pagination, result format, or how relation_type filters results. For a graph exploration tool, more details are needed for effective usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 0% description coverage; the description only implicitly covers relation_type by listing enum values. It does not explain that 'doi' is required, that 'all' is the default relation_type, or that page_size controls pagination. The added value over the schema is minimal.

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 tool explores the relationship graph for a DOI, listing specific relationship types (citations, references, versions, parts) that match the relation_type enum. This verb+resource combination distinguishes it from siblings like get_doi (metadata) or get_doi_metrics (metrics).

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 on when to use or avoid this tool versus alternatives. With siblings like search_dois, get_doi, or format_citation, explicit context about when to explore relationships vs. retrieve metadata would be helpful. No exclusions or comparisons are mentioned.

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/alexwade/datacite-mcp'

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