Skip to content

feat(mcp): port the get_aspect_history tool - #21445

Merged
nwadams merged 0 commit into
na--mcp-get-dataset-usage-historyfrom
na--mcp-get-aspect-history
Nov 24, 2026
Merged

nwadams merged 0 commit into
na--mcp-get-dataset-usage-historyfrom
na--mcp-get-aspect-history

Conversation

@nwadams

@nwadams nwadams commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

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 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 ← 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

  • 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

This was referenced Nov 19, 2026
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Adds the read-only MCP tool get_aspect_history, which returns retained governance aspect versions (newest first) for up to 10 URNs × 8 allowlisted aspects per call, with paging, response budgeting, and compactLineage for oversized current upstreamLineage values.

Reads go through a new ReadBackend.aspect_versions on GraphQLReadBackend, backed by VersionedOpenApiClient posting to OpenAPI v3 batchGet with per-aspect If-Version-Match. Validation uses ToolError, require_existing, and the usual URN/aspect list aliases; the tool is registered in the MCP server as slow (progress heartbeat).

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

@nwadams nwadams closed this Nov 24, 2026
@nwadams
nwadams force-pushed the na--mcp-get-aspect-history branch from 2c2f0e1 to b1579ee Compare November 24, 2026 01:41
@nwadams
nwadams merged commit b1579ee into na--mcp-get-dataset-usage-history Nov 24, 2026
@nwadams
nwadams force-pushed the na--mcp-get-dataset-usage-history branch from 40817cc to b1579ee Compare November 24, 2026 01:41
@nwadams
nwadams deleted the na--mcp-get-aspect-history branch November 24, 2026 01:41

This branch was successfully deployed

1 active deployment
Preview — b1579ee1 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants