feat(mcp): port the glossary term version read tools

Merged
NW
2d ago
+0-0

Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--mcp-get-aspect-history (the previous PR in the stack); review only its own commit. It changes only the shared datahub-core-mcp-tools package and datahub-ai-service. It is one tool port, so it stays one PR even where it runs past the stack's usual 1,000-line size. Everything user-facing is behind a GMS feature flag, MCP_SERVER_ENABLED, off by default (added in #21349).

Stack so far:

1–22. Merged to master as #21332.
23. #21435
24. #21436
25. #21437
26. #21438
27. #21439
28. #21440
29. #21441
30. #21442
31. #21443
32. #21444
33. #21445
34. #21447 ← this PR
35. #21501
36. #21502
37. #21503
38. #21504
39. #21505
40. #21506
41. #21507
42. #21508
43. #21509
44. #21510
45. #21511
46. #21512

What this does

get_glossary_term_versions lists every version of a versioned glossary
term, newest first, from a term URN (its version set is looked up) or a
version set URN: each version's term URN, name, definition, version tag,
whether it is the latest, its comment and when it was created.
compare_glossary_term_versions diffs two terms (typically two versions of
one concept) on name, definition, source, custom properties, owners, tags
and deprecation, and returns both summaries with the fields that changed.
Both are in the read group and read-only, and are registered only when
ENTITY_VERSIONING_ENABLED is true (default off, as in DataHub Cloud).

From DataHub Cloud's glossary_versioning module: both tools, their
descriptions and response shapes, and is_entity_versioning_enabled. The
write tools of the same module (create_glossary_term_version,
add_related_terms) are not ported here; the module and its GraphQL
document are where they go. The legacy OSS server has no such tools.

Adapted to this package: the queries move from inline strings into
glossary_versioning.gql (without the owner, group and tag display fields
the tools never read), and reads go through ReadBackend (new
glossary_term_version, version_set_history, glossary_terms). Errors are
ToolErrors instead of ValueErrors. A URN that does not exist is "not
found" instead of "not versioned" (a term) or an empty history (a version
set: GMS answers versionSet(urn:) for any URN); compare checks both URNs
are glossary term URNs before reading and treats the stub entities(urns:)
returns for an unknown URN as not found. GraphQLReadBackend.exists checks
a version set by its own key aspect: VersionSetUrn.entity_type is the
versioned entity's type, so the SDK's exists() reported every version set
missing.

Version gates: @min_version(oss="1.10.0", cloud="0.3.16") on both tools,
and #[since oss=1.10.0 cloud=0.3.16] on GlossaryTerm.versionProperties in
the document. Glossary term versioning (#20631) merged to master on
2026-10-27, after releases/v1.9.0 was cut; no release tag contains it yet
(v1.9.0rc1-rc5 do not), so 1.10.0 is the next release that will. DataHub
Cloud marked the tools Cloud-only (0.3.16).

Testing

DataHub Cloud's read tests ported (by version set and by term URN, an
unversioned term, an unsupported URN, a diff, identical terms, a missing
term) plus a missing term or version set, the stub entity, non-term URNs
in compare, a host-bound ReadBackend, the version gate, and registration
on, off and by default. The documents validate on GMS 1.7.0, 1.8.0 and
master. Live on a local OSS DataHub with auth on, through an in-memory MCP
client with the flag set and GMS version detection left out (this dev GMS
reports v1.9.0rc1, below the gate, so the service's version filter hides
the tools there): on a run-unique two-version term created for the test,
both URN forms return v2 (latest) then v1 with their comments, and compare
reports the name and definition changes; an unknown term, an unknown
version set and a showcase term that is not versioned are tool errors;
with the flag off the tools are not listed. The test terms and version set
were deleted afterwards.

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). The MCP docs come later in the stack.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes. The release notes come later in the stack.

šŸ¤– Generated with Claude Code