Skip to content

feat(mcp): port the read tools to DataHub Core's MCP server - #21435

Open
nwadams wants to merge 14 commits into
masterfrom
na--mcp-search
Open

nwadams wants to merge 14 commits into
masterfrom
na--mcp-search

Conversation

@nwadams

@nwadams nwadams commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Ports DataHub's read tools to the built-in MCP server's datahub-core-mcp-tools package. It targets master, on top of #21332, and the server stays off until GMS has MCP_SERVER_ENABLED=true.

This PR started as the search port. The other read-tool PRs, #21436 to #21447, have been merged into it, so it now carries all 12 reviewed and approved tool ports. The write tools follow in #21501 (PRs 35–46, folded the same way).

What this does

Each port has its tool, its .gql, the helpers it needs and its tests. All are registered in the read group and are read-only.

Each folded PR's description has the details of what was taken from DataHub Cloud's tool and from the legacy mcp-server-datahub.

Review fixes in this range

  • cachetools has an upper bound: >=5.0.0,<9.
  • get_entities has a per-deployment description, like search.
  • The Cursor Bugbot findings on this PR and the folded read-tool PRs are fixed in the two fix(mcp): address review findings commits at the end of this range: view caches (no cached failures, locked), NOT (a OR b) filters, a 10,000-result paging cap, hybrid document search totals and page size, schema-field and key/value schema fields in get_entities, grep_documents and grep_entities error handling, column lineage paths and filters, and draft glossary term versions.

Testing

  • At each folded PR's tip, rebased onto master: ./gradlew :packages:datahub-core-mcp-tools:lint :packages:datahub-core-mcp-tools:testQuick :packages:datahub-ai-service:lint :packages:datahub-ai-service:testQuick. 638 core tests pass at the final tip.
  • GraphQL snapshot tests check every new .gql against the pinned GMS schemas (1.7.0, 1.8.0, 1.9.0 and master).
  • Each folded PR's description lists its own testing.

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 user guide comes with the docs PR later in the stack.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes. Not applicable: the server is off by default.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the devops PR or Issue related to DataHub backend & deployment label Nov 19, 2026
This was referenced Nov 19, 2026
@nwadams

nwadams commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Added the upper bound in 150fa59: cachetools>=5.0.0,<9. The PR is rebased onto master now that #21332 is in.

🤖 Addressed by Claude Code

@nwadams
nwadams marked this pull request as ready for review November 24, 2026 00:25
@cursor

cursor Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Expands the built-in MCP server from get_me to a full read-metadata toolkit by registering search, entity reads, lineage, dataset queries/usage, aspect history, document search/grep, entity grep, schema listing, and optional glossary version tools in register_tools, gated by env flags where needed.

The port adds the backing layer those tools share: a ReadBackend with many GraphQL documents, entity_cleaning and token-budget caps so responses fit agent context, a SQL-like filter parser for search, URN validation and parameter aliases for flaky MCP clients, versioned aspect reads via OpenAPI batchGet, and google-re2 + cachetools as new dependencies. Integration tests now expect the full tool list when the AI service starts.

Reviewed by Cursor Bugbot for commit 85b8138. 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 4 potential issues.

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 150fa59. Configure here.

nwadams and others added 12 commits November 23, 2026 20:38
`search` is the agent's entry point to the catalog: keyword search across
entities (`/q` syntax), a SQL-like `filter`, paging, sorting, and facets only
with num_results=0. It is registered in the read group, read-only and
trust-labeled, and reads through ReadBackend.search_entities, which this adds
(GraphQLReadBackend runs the new search.gql).

From DataHub Cloud's search tool:
- accepted parameter aliases (filters, limit, count, start, ...), the `a+b*`
  wildcard rewrite into `(a AND b*)`, the retry without 1-2 character words when
  a simple /q query finds nothing (with a note saying so), lastModified as
  dates, the dataset key name dropped when properties.name is set,
  retrieval-policy documents excluded, deployment-specific sort-field docs;
- explanations when a search comes back empty: a few count-only searches add
  `search_notes` saying what matches on its own (the phrase without quotes, the
  query without the filter, each top-level condition, each word), stating
  counts, never absence;
- the filter parser (AND/OR/NOT, IN, comparisons, IS [NOT] NULL, structured
  properties, WITHIN for domain, container and parent_document, compiled to
  DESCENDANTS_INCL, which GMS v1.7.0 already expands);
- view selection (the caller's default view, else the organization's), UTC
  dates from lastModified audit stamps (LAST_MODIFIED_DATES_ENABLED=false turns
  them off), clean_gql_response and the retrieval-policy exclusion.
Dropped: proposal scoping, the fieldConfiguration flag (a DataHub Cloud search
configuration; a Cloud host can still send it through SearchFlagsOverride), and
the semantic and "smart" strategies, whose only callers are DataHub Cloud's own
tools.

From legacy OSS mcp-server-datahub:
- sort_by="relevance" is the default ranking instead of failing the search;
- a host's SearchFlagsOverride is merged over the search flags (searchFlags is
  now a query variable for that);
- an empty `IN ()` list says to drop the condition; the same check covers
  `WITHIN ()`.

New here:
- an invalid filter raises a ToolError that names the filter;
- the default-view caches are keyed by the caller's server and token instead
  of the graph object: the datahub-ai-service builds a client per request, so
  a graph-keyed cache never hit (two extra GraphQL calls per search) and held
  recent clients alive. cachetools is now a declared dependency (it was only
  transitive); the ai-service lock is regenerated for that;
- log lines no longer include the query or filter, which can carry user data.

search.gql needs no version gates: every field validates on GMS 1.7.0, 1.8.0
and master.

Tests: 118 cases (filter parser, helpers, the tool against a fake
ReadBackend, empty-result notes against a counting ReadBackend, registration).
Live against a local OSS DataHub with the showcase-ecommerce data: /q orders
(1155 hits, orders tables first), a platform + entity_type filter (14
Snowflake datasets), sort_by=relevance, facets only, the filters/limit
aliases, an empty IN list (ToolError), sorting by lastModifiedAt, domain
WITHIN, /q os+orders (retried as /q orders with a note), and empty-result
notes for a nonsense word, a conflicting filter pair (3 and 17 matches, none
both) and a quoted phrase (214 without quotes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`get_entities` reads one or more entities by URN: a dataset, dashboard, glossary
term, document, data contract, assertion, query or any other type. `fields` is
a strict allowlist (published as an enum) and everything withheld is listed in
`omittedFields`, sized where that matters; named fields that came back empty
are listed in `notReturnedFields`. `schema_columns` picks columns by name from
the whole schema before the token budget, with full text. A dataset's
descriptions, tags and terms include its siblings' (the dbt model behind a
warehouse table), merged as the UI shows them. In a batch, results keep the
caller's order and a missing or malformed URN becomes {urn, error} in place; a
single missing URN, or a batch with no URN at all, raises a ToolError. It is in
the read group, read-only and trust-labeled, and reads through ReadBackend
(new `entity` and `related_documents` methods). A host can pass
`schema_field_matcher` to register_tools to rank columns its own way.

From DataHub Cloud: the tool, its projection and field allowlist, sibling
merge (sibling_merge.py), column matching (schema_matching.py), and the entity
cleaning helpers (new entity_cleaning.py: description sanitizing and caps,
documentation origins, schema-field cleaning with edited* merges, the per-entity
schema token budget, document and SQL caps). entity_details.gql,
query_entity.gql and related_documents.gql come from DataHub Cloud. Left out as
Cloud-only or not this tool's: certification (GMS has no Certifiable
interface), URL injection, the GetEntityLineage operation (get_lineage's), and
the Context-doc kill switch. Without json_repair, a malformed JSON-string URN
list is taken as one value and rejected by URN validation.

From legacy OSS mcp-server-datahub:
- assertions are read with their own document (assertion_entity.gql) and
  select error.properties, where OSS servers put an errored run's message;
- assertion key/value lists (customProperties, nativeParameters, run
  nativeResults and error properties) are capped, with <name>Total when cut
  (MAX_ASSERTION_KEY_VALUE_ENTRIES / _CHARS);
- a data contract returns at most MAX_CONTRACT_DATA_QUALITY_ASSERTIONS members,
  failing and erroring first, with dataQualityTotal;
- Dataset.properties.externalUrl and DataJob.inputOutput are selected (the
  latter is a new nameable field).

Version gates: every unmarked field validates on GMS 1.7.0, 1.8.0 and master,
including the Document arm and DataContract.structuredProperties (both older
than 1.7.0). customAssertion's fields/scope/aggregation/operator/parameters/
nativeType/nativeParameters and AssertionInfo.customProperties are
`#[since oss=1.8.0 cloud=0.3.16]`. Cloud-only: entity `documentation` on
Dataset/Dashboard/Chart/DataFlow/DataJob (cloud=0.3.4), statsSummary
percentiles, ranks, row count and size (0.3.2), GlossaryTerm.versionProperties
(0.3.9), DataContract.result (0.3.4), assertionStatus and error.displayMessage
(0.3.17), result.metric (0.3.16.3), failureSeverityConfig (0.3.17.7), each the
first Cloud release whose schema has it.

Tests: 73 new (projection, cleaning, sibling merge, the tool against a fake
ReadBackend, per-kind query routing, host matcher isolation, and what each
document selects on OSS 1.7.0/1.8.0 and Cloud). Live against a local OSS
DataHub with the showcase-ecommerce data: a Snowflake table (sibling dbt
description merged, externalUrl), a Tableau dashboard, a glossary term, a
document (title, related assets, parent lifted), a batch with a missing URN and
a bare name, fields and schema_columns, related documents, and a data job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`list_schema_fields` pages through a dataset's columns, ranking keyword matches
first (by name, description, propagated and AI documentation, label, tags,
glossary terms and structured property values) without filtering out the rest.
Matched columns get their full text; the rest a short preview. The response
says how many columns matched, how many remain after the page, and when more
matches lie beyond it, the offset to continue from. Sibling metadata (e.g. the
dbt model's column docs) is merged in and the siblings are named. A bare table
name or a missing dataset raises a ToolError. It is in the read group and
read-only, reads through ReadBackend.entity, shares get_entities' column
matcher (so a host's `schema_field_matcher` ranks both), and is skipped when
LIST_SCHEMA_FIELDS_ENABLED=false. Stacked on the get_entities change, whose
entity read, cleaning and sibling merge it reuses.

From DataHub Cloud: the tool, its notes, the parameter aliases (dataset_urn,
keyword, limit/count, start, ...), and keyword matching on column
documentation.

From legacy OSS mcp-server-datahub:
- each column's structured properties are returned by default, in Cloud's
  [{name, values}] shape, bounded by FIELD_STRUCTURED_PROPERTY_CHAR_LIMIT
  (1000) and FIELD_STRUCTURED_PROPERTY_MAX_VALUES (25); a URN-valued property
  is read from valueEntities only when values is empty, so it is not reported
  twice; null items are skipped and a 0 number is kept;
  SCHEMA_FIELD_EXTRA_ATTRS_IN_LIST_SCHEMA_FIELDS=false turns them off;
- keywords match those values whole, past the response's cut, scored once per
  column;
- remainingCount is never negative, so an offset past the end is an empty page
  with remainingCount 0.

No new GraphQL: the per-column selection is entity_details.gql's.

Tests: 18 (ranking, host matcher isolation and full text, continuation notes
under limit and budget, offset past the end, no-match and empty-schema notes,
keyword coercion, URN rejection, bounded structured properties and matching
past the cut, siblings, the enable switch). Live against a local OSS DataHub
with the showcase-ecommerce data: keywords "customer, total" on a Snowflake
orders table (4 of 15 columns matched, a continuation note at limit 3, page 2
at offset 3), an unfiltered page at offset 10 (remainingCount 0), offset 99
(empty page, remainingCount 0), a keyword matching nothing, a bare name passed
as dataset_urn, and a missing dataset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
search_documents lets an agent find the organization's own documents
(runbooks, FAQs, knowledge articles) by keyword, with a SQL-like filter over
subtype, platform, domain, container, tag, glossary term, owner and parent
document (WITHIN for nested domains, containers and documents). It returns
metadata (title, subtype, platform, source, domain, tags, terms,
lastModified as a date), not bodies: grep_documents reads those. query="*"
or num_results=0 returns facets for discovering valid filter values.

From DataHub Cloud: the tool and its description, `query` required, the
parameter aliases (filters, limit/count/..., start), facets only for
discovery searches, the default exclusions (SYSTEM product guides, bridge
documents, retrieval-policy configuration; a filter naming them opts in),
trust labels through the host's result policy, and the hybrid search: when
SEMANTIC_SEARCH_ENABLED is true (default false, as in Cloud) a semantic leg
runs next to the keyword leg (for an explicit semantic_query, or a
multi-word natural-language query), the two are merged and deduplicated
with searchType keyword/semantic/both, and a failing semantic leg falls
back to keyword results. query="*" with semantic_query is rejected.

Adapted to this package: searches go through a new
ReadBackend.search_documents (GraphQL by default), the searchFlags are a
variable built in Python so a host's SearchFlagsOverride applies (shared
with search through search_flags.request_search_flags), invalid filters and
the match-all/semantic conflict raise ToolError. Dropped: Cohere rerank and
the recall/display queries that only it uses, proposal scoping, the
includeHiddenLifecycleStages flag (only proposal scoping set it), and the
env-tunable hybrid pool (its ceiling existed for the reranker; the pool is
100). includeNonGlobalContextDocuments is not sent: it is a Cloud-only
search flag that a Cloud host can add through SearchFlagsOverride. The
legacy OSS server's search_documents is an older copy of the same code with
no OSS-only fixes to carry over.

Version gates: @min_version(cloud=0.3.16, oss=1.4.0) as in DataHub Cloud. The
semantic leg's SearchResult.score is `#[since cloud=0.3.14]` (OSS GMS has
no score); every other field validates on GMS 1.7.0, 1.8.0 and master.

Tested: unit tests against a test ReadBackend (request variables, filters
and exclusions, facets, paging, view and flag overrides, hybrid merge,
paging over the merged pool and fallback, labels) and through FastMCP with
the GraphQL backend. Live on a local OSS DataHub with the showcase-ecommerce
data (18 documents): facet discovery, "promotion attribution" and
"/q inventory+staleness" find the matching runbooks, a subtype filter, and
both errors. Semantic search is not configured on that GMS, so the hybrid
path was run directly with SEMANTIC_SEARCH_ENABLED=true: the semantic
document validated, GMS answered "Semantic search is disabled", and the
keyword results came back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
grep_documents lets an agent read inside documents it found with
search_documents: it runs an RE2 regex over each document's body and
returns excerpts with context_chars of surrounding text, absolute positions
and per-document match counts. pattern=".*" reads a body in consecutive
windows; start_offset and next_offset page through a long document.

From DataHub Cloud: the tool and its description, the 60K-character output
budget shared across documents (GREP_OUTPUT_CHAR_BUDGET; excerpts cut at
the budget are marked truncated, every document with more to show gets a
next_offset, and later documents are listed with no excerpts), excerpts
that never repeat text, a ToolError (never a result) for a pattern that
cannot compile, clamping of oversized {m,n} repetitions with a
pattern_note, skipped_urns for names, malformed URNs, missing, deleted or
unviewable documents and configuration documents (the rest are still
searched), stringified URN lists, the parameter aliases (documentUrns,
document_urns, ...; offset/start for start_offset), and trust labels.
The pattern is compiled before any document is read.

Added here: ReadBackend.document_contents (document_content.gql; a deleted
or unviewable document's info-null stub reads as missing), example and
resolve_with on the URN helpers so the errors show a document URN and point
at search_documents, and the tool is registered with the progress
heartbeat (register_tools' add() takes slow=). The google-re2 dependency is
added to the package and the service lock file. The legacy OSS server's
grep_documents is an older copy with no OSS-only fix to carry over: its
returned error dict for a bad pattern is the behavior Cloud replaced with
ToolError.

Version gates: @min_version(cloud=0.3.16, oss=1.4.0) as in DataHub Cloud;
document_content.gql validates on GMS 1.7.0, 1.8.0 and master unmarked.

Tested: unit tests against a test ReadBackend (excerpts and positions,
limits and next_offset, start_offset, skipped URNs, bad and clamped
patterns, windowed reads, the output budget across one and several
documents, configuration documents and labels) and through FastMCP with
the GraphQL backend. Live on a local OSS DataHub (showcase-ecommerce),
with google-re2 installed into the running service container: a regex
over three runbooks/references found the staleness runbook's matches, an
AOV lookup in the metrics reference with a missing URN and a name reported
both in skipped_urns, ".*" windows returned next_offset, and an unclosed
group failed as a tool error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
grep_entities lets an agent search every string in one entity's metadata
(all aspects: schema fields and their descriptions, tags, terms,
ownership, properties, ...) with an RE2 regex, when it is looking for
something without knowing which aspect holds it. Each match comes with
the value's path (e.g. schemaMetadata.fields[fieldPath=zip_code]
.description), a snippet of the deterministic "path: value" stream around
it, and stream offsets; ".*" with next_offset reads the whole entity page
by page. A pattern that matches no value is retried against whole
"path: value" lines (searched: "lines"), since agents copy that format.

From DataHub Cloud: the tool and its description, the stream and path
rendering, merged snippets for adjacent hits, the 60K JSON-character
budget per response (GREP_OUTPUT_CHAR_BUDGET, counted on the serialized
response) with max_matches (default 20) and continuation that keeps a
match spanning the cursor, ToolError for a pattern that cannot compile
(oversized {m,n} repetitions are clamped with a pattern_note), for a
missing entity, a failed read and a page nothing fits on, the urn and
offset aliases, retrieval-policy configuration kept out, and reader-policy
labels. The GREP_ENTITIES_ENABLED gate (default on) is kept.

Adapted to this package: reads go through the existing
ReadBackend.exists/aspects, the RE2 clamp and error text are shared with
grep_documents instead of copied, a missing entity raises ToolError rather
than the SDK's ItemNotFoundError, and the tool is registered with the
progress heartbeat. The legacy OSS server has no grep_entities.

Version gates: none needed; the tool reads aspects through the SDK, not
GraphQL, and DataHub Cloud sets no @min_version.

Tested: DataHub Cloud's unit tests against a test ReadBackend (value and line
search, anchors, paths, budgets, paging the full stream, continuation,
errors), plus registration through FastMCP and the env gate. Live on a
local OSS DataHub (showcase-ecommerce): status/total columns on the
Snowflake orders table, glossary-term URNs on the Postgres orders table,
owners on the dbt model, a paged ".*" read (next_offset), an unclosed
group, an unknown dataset and a bare name, each failing as a tool error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_lineage returns one direction (upstream or downstream) of any entity's
lineage, up to 1, 2 or unlimited (3+) hops, narrowed by a /q query or the
search filter language. Paging is server-side: `offset` is sent to
searchAcrossLineage as `start`, and each page reports total, returned,
hasMore and nextOffset (where the next page starts after what the token
budget let through, so following it skips nothing). Facets come with the
first page only. Each node is the get_entities projection: identity and
description by default, `fields` as the same allowlist, the rest listed in
omittedFields. With `column`, the input is the column's schemaField and each
downstream/upstream dataset carries the matching `lineageColumns`. It is in
the read group, read-only, trust-labeled, and registered with the progress
heartbeat.

From DataHub Cloud: the tool and description, server-side paging with the
derived total when GMS omits it, the per-response token budget
(select_results_within_budget, new in graphql_helpers), the existence check
(a schemaField is checked through its dataset), the rejection of a column
query filtered to charts/dashboards, `fields`, lineageColumns extraction,
facet trimming, the urn/filter/size/offset/fields aliases plus `direction`
and `depth` (direction="upstream"/"downstream" is coerced; "both" is a tool
error saying to call twice), and reader-policy labels. The GetEntityLineage
operation goes back into entity_details.gql, next to the entityPreview
fragment its nodes are read with (every .gql is validated on its own, so a
separate file would need a copy of that fragment).

From legacy OSS mcp-server-datahub: SearchFlagsOverride (6f7d9bf): a host
can merge searchFlags such as {"skipCache": true} over the lineage defaults
through the request's ToolContext (search_flags.request_search_flags).

Adapted to this package: reads go through ReadBackend (new
search_lineage; exists for the guard), a missing entity, a bad filter,
max_hops < 1 and a column on a non-dataset raise ToolError instead of
ItemNotFoundError/ValueError, and Cloud's URL injection is left out.

Version gates: none. Every selection of GetEntityLineage validates on GMS 1.7.0, 1.8.0
and master.

Tested: DataHub Cloud's get_lineage tests (guard, paging, missing total, budget
cut, facets, column-filter rejection, metric/semantic model names) against
a test ReadBackend, column extraction, the direction alias and coercion
through FastMCP, search-flag defaults and override, and the GraphQL backend's
operation. Live on a local OSS DataHub (showcase-ecommerce): the Snowflake
orders table's 37 downstream nodes paged 10 at a time by nextOffset (37
distinct: 22 datasets, 12 charts, 3 dashboards), its 4 upstreams (Postgres,
S3, two Spark jobs), fields=["ownership"], column-level lineage of
customer_id both ways (lineageColumns on the dbt, Postgres and S3 orders
tables), a dashboard filter, an offset past the end, and a bogus URN,
direction="both" and a column with a dashboard filter as tool errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Tested: 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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_dataset_queries returns the SQL queries DataHub holds for a dataset, or
for one of its columns, so an agent can learn how the table is really used
(joins, filters, aggregations) before writing SQL against it. `source`
narrows to MANUAL (written by people) or SYSTEM (from BI tools), and
`start`/`count` page. Each query comes with its statement, language, source,
name, platform and the datasets it touches (subjects deduplicated to dataset
URNs). It is in the read group and read-only.

From DataHub Cloud: the tool and description, queries.gql (listQueries with
the query fragment, including customProperties), subject deduplication, SQL
statements capped at QUERY_LENGTH_LIMIT, descriptions and each
customProperties value capped as get_entities caps them, reader-policy
labels, and the urn/offset/size aliases. queries.gql is DataHub Cloud's minus the
commented-out fields; customProperties needs no marker (QueryProperties has
it on GMS 1.7.0).

The legacy OSS server's version has no caps or aliases; it brings nothing
newer.

Adapted to this package: reads go through ReadBackend (new list_queries);
the dataset must exist, so a typo raises "not found" instead of reading as
"this table has no queries"; a name instead of a URN and a column on a
non-dataset raise ToolError. The existence check get_lineage introduced
moves to read_backend.require_existing so both tools share it.

Version gates: none. listQueries with source and orFilters, and every
selection of queries.gql, validate on GMS 1.7.0, 1.8.0 and master.

Tested: the request (entities filter on the dataset or column, start/count,
source present only when given), subject deduplication, SQL and
customProperties caps, an empty result, the error cases, and the GraphQL
backend's operation. Live on a local OSS DataHub (showcase-ecommerce): the
datapack has no Query entities (lineage references one query URN that has no
entity), so the Snowflake orders and order_details tables return total 0
with and without column/source/limit, which confirms the query runs on GMS;
a bogus URN is a tool error. Results with queries are covered by the unit
tests only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
get_dataset_usage_history returns how often a dataset was queried over the
last DAY, WEEK, MONTH or QUARTER: the total SQL query count and one
UTC-dated point per day, sorted, ready to summarize or chart. It is in the
read group and read-only.

From DataHub Cloud's integrations service (where it is registered beside
the shared tools, not in the package): the tool, its description and
dataset_usage.gql (the dataset's usageStats with totalSqlQueries per bucket,
in UTC), the closed TimeRange choice, and the response shape. Buckets
without a date or a count are left out rather than plotted as zero. The
legacy OSS server has no such tool.

Adapted to this package: reads go through ReadBackend (new dataset_usage),
and every failure is a ToolError instead of ValueError. The URN must be a
dataset URN (a name gets the search hint, another entity type says usage is
recorded for datasets only) and must exist: GMS answers dataset(urn:) with
an object even for a URN it has never seen, so a typo would otherwise read
as "never queried". It also takes the usual urn aliases.

Version gates: none. usageStats(range:, timeZone:) and totalSqlQueries
validate on GMS 1.7.0, 1.8.0 and master.

Tested: dated, sorted points and the total from a test ReadBackend
(including incomplete buckets), an unqueried dataset, missing usage, a null
or missing dataset, a non-dataset URN and a name, the GraphQL backend's
operation and variables, and registration (read-only, the four ranges in
the schema). Live on a local OSS DataHub (showcase-ecommerce): the datapack
has no usage statistics, so the Snowflake and Postgres orders tables return
totalQueryCount 0 and no points for MONTH and QUARTER (the query runs on
GMS); a bogus URN is a tool error. Non-empty history is covered by the unit
tests only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Tested: 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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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).

Tested: 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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nwadams and others added 2 commits November 25, 2026 10:10
- view_helpers: a failed read of the user's default view is no longer cached;
  the cached function raises and the public wrapper returns None, so the next
  search reads the view again instead of using the organization default for
  the cache TTL.
- view_helpers: both view caches take a lock, since searches run in worker
  threads and TTLCache is not thread-safe.
- search_filter_parser: NOT over a group pushes the negation down with
  De Morgan's laws (OR, AND, double NOT), so NOT (a OR b) is a valid filter
  instead of a ToolError.
- search: offset + num_results beyond 10,000 (the default Elasticsearch
  max_result_window) is refused with a ToolError that suggests narrowing the
  query, instead of sending a deep from/size page.
- documents: hybrid search caps num_results at 50 like keyword search, and
  its total is at least each leg's match count rather than the size of the
  merged fetch window, so callers paging on total keep paging, and the
  semantic-failure fallback keeps the keyword total.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- get_entities on a schemaField URN keeps fieldPath, parent and deprecation,
  so the caller can tell which column and dataset came back.
- A KeyValueSchema platformSchema (keySchema/valueSchema) is no longer dropped
  from schemaMetadata.
- list_schema_fields matches keywords against propagated and AI documentation
  at the full returned length, not the 120-char preview.
- grep_documents reports non-document URNs in skipped_urns instead of
  silently dropping them.
- grep_entities answers existence through aspects(), so a missing entity is a
  ToolError and a failed existence check is wrapped like a failed read.
- get_lineage rejects a chart/dashboard filter on a schemaField URN as it
  does for column=.
- get_lineage_paths_between returns only the column paths that end at the
  requested column, and no longer claims a 10-hop bound that
  searchAcrossLineage cannot apply.
- get_glossary_term_versions includes versions in hidden lifecycle stages
  (DRAFT), as the UI version list does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

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

Labels

devops PR or Issue related to DataHub backend & deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants