feat(mcp): port the get_lineage_paths_between tool
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-lineage (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 ā this PR
31. #21443
32. #21444
33. #21445
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_lineage_paths_between shows how one entity (or column) reaches another:
every lineage path between them, with the intermediate datasets, columns,
data jobs and transformation QUERY URNs (which get_entities then reads for
their SQL). Without direction it tries downstream, then upstream. Each
direction is answered by one paths-only upstream search (up to 10 hops, 100
results): downstream searches the target's upstreams and reverses the paths,
so the bounded side of the graph is always the one walked. No path is a
normal result, not an error: metadata.noPath says why, and searchComplete is
false when the result cap or GMS's isPartial means a path may still exist;
pathsUnavailable covers a connected pair whose path details are missing. It
is in the read group, read-only, and registered with the progress heartbeat
(up to two 10-hop searches).
From DataHub Cloud: the tool and description, lineage_paths.gql (the
GetEntityLineagePaths operation: urn/type per node, paths and isPartial, no
entity preview), the no-path and pathsUnavailable answers, path reversal,
the queryEntities hint, null-safe path handling and reader-policy labels on
path nodes.
From legacy OSS mcp-server-datahub: SearchFlagsOverride (6f7d9bf) applies to
both auto-discovery searches, through the shared lineage_variables.
Adapted to this package: reads go through ReadBackend (new lineage_paths;
exists), source and target must be URNs (a name gets the search hint) and
must exist, so a typo raises "not found" instead of reading as "no path"; a
single column, or a column on a non-dataset, raises ToolError rather than
ValueError. The legacy OSS version raised ItemNotFoundError for no path;
Cloud's noPath answer replaces it.
Version gates: none. isPartial and every other selection of
lineage_paths.gql validate on GMS 1.7.0, 1.8.0 and master.
Testing
DataHub Cloud's tests (column and dataset paths with and without
queries, auto-discovery both ways, explicit direction, no path, truncated
and partial searches, pathsUnavailable, multiple paths, "null" columns,
null paths, errors propagating) through the GraphQL backend, plus a test
ReadBackend for the searched ends, column URNs, the search-flag override and
the URN/existence checks. Live on a local OSS DataHub (showcase-ecommerce):
Postgres orders to the Looker dashboard (auto-discovered downstream: two
10-node paths through the Spark jobs, S3, Snowflake, the SQL query and the
Looker view/explore/chart), Snowflake orders to the Tableau dashboard,
customer_id from Postgres to Snowflake and from Snowflake to dbt, the
dashboard-to-table pair found upstream, two no-path pairs (Postgres orders
and order_items; the Tableau and Looker dashboards) with complete searches,
and a bogus URN and a single column as tool errors.
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