Repository navigation
feat(mcp): port the get_aspect_history tool - #21445
Conversation
b87a231 to
40817cc
Compare
d514532 to
2c2f0e1
Compare
PR SummaryOverview Reads go through a new The legacy test suite is ported (~53 tests) covering anchoring, gaps, paging, budget trimming, and transport errors. Reviewed by Cursor Bugbot for commit b1579ee. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2c2f0e1. Configure here.
2c2f0e1 to
b1579ee
Compare
40817cc to
b1579ee
Compare

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-dataset-usage-history(the previous PR in the stack); review only its own commit. It changes only the shareddatahub-core-mcp-toolspackage anddatahub-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
masteras #21332.23. #21435
24. #21436
25. #21437
26. #21438
27. #21439
28. #21440
29. #21441
30. #21442
31. #21443
32. #21444
33. #21445 ← this PR
34. #21447
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_aspect_history returns the retained versions of an asset's governance
aspects, newest first: ownership, tags, terms, domains, descriptions
(datasetProperties, editableDatasetProperties), schemaMetadata,
editableSchemaMetadata, structuredProperties, deprecation, status and
upstreamLineage. It answers "what changed and when, and who changed it":
each version carries its value, its audit stamp and an allowlisted part of
its system metadata. It batches up to 10 URNs x 8 aspects, pages per pair
(page.nextFromVersion), and fits every pair into one response budget. It is
in the read group and read-only.
From the legacy OSS server (DataHub Cloud has no such tool): the tool and its
OpenAPI client, with the follow-ups merged there. History is anchored on
the newest stored row (systemMetadata.version - 1), so a pruned window like
6..25 is reachable and history[0] never repeats the current value; gaps
inside the window are skipped; an aspect never written costs no probes; a
404 from batchGet keeps its own diagnostic. The compact-lineage follow-up:
an oversized current upstreamLineage comes back as compactLineage (each
dataset listed once, columns as [datasetIndex, fieldPath], cut on whole
entries with totals), continuation pages give history priority over the
current value, and a pair that cannot advance its cursor is dropped rather
than returned without history.
Adapted to this package: reads go through ReadBackend (new aspect_versions;
GraphQLReadBackend posts to /openapi/v3/entity/{entity}/batchGet with one
If-Version-Match per aspect through the caller's own DataHub session), and
existence through require_existing. Bad arguments are ToolErrors instead of
ValueErrors, and a call where no pair can be read (a URN that does not
exist, only aspects without history) fails instead of returning only error
entries; when some pairs can be read, the others still carry a per-pair
error. Aspect names outside the allowlist are refused before any request,
naming the allowed ones; URN problems use the package's messages (a name
gets the search hint). A stringified list is coerced like other tools'
lists and malformed JSON is no longer repaired. Takes the usual urns
aliases plus aspect_name / aspects. Registered with the progress heartbeat:
it can step through ~30 rounds of batchGet.
Version gates: none. The legacy tool said OSS 1.4.0 / Cloud 0.3.16; the
v3 EntityController at v1.7.0 serves POST /{entityName}/batchGet with a
per-aspect If-Version-Match header, which is all this needs.
Testing
the legacy suite ported (53 tests): anchoring and pruned windows,
gaps, fallback scans, probe budget, paging, batching per entity type, budget
trimming and dropped pairs, compact lineage, argument bounds, transport
errors and 404, against a fake GMS session through GraphQLReadBackend; plus
a host-bound ReadBackend, the no-readable-pair errors, and registration
(read-only, array parameters). Live on a local OSS DataHub with auth on
(showcase-ecommerce): schemaMetadata, ownership, editableDatasetProperties,
editableSchemaMetadata, globalTags and glossaryTerms across 10 datasets
return their current value with audit stamp; the datapack wrote each
aspect once (systemMetadata.version 1), so there is no history to page and
the multi-version path is covered by unit tests only. Aspects never written
come back as aspectAbsent. The Snowflake order_details upstreamLineage
(53K characters) comes back as compactLineage with all 12 upstreams and 108
column mappings in 23K. A bogus URN and an aspect without history are tool
errors; a stringified list and the aliases work.
Checklist
🤖 Generated with Claude Code