Repository navigation
Conversation
PR SummaryOverview Governance and labeling: Organization and ownership: Descriptions and structured metadata: Knowledge-base documents: Tests: Reviewed by Cursor Bugbot for commit 99f89b4. Bugbot is set up for automated code reviews on this repo. Configure here. |
150fa59 to
b1579ee
Compare
6d05cb5 to
3a55569
Compare
add_tags attaches one or more existing tags to assets, or to dataset columns when column_paths pairs a column with an asset, in one batch write; remove_tags takes them off. Both answer with success, how many entities (or columns) the call covered, and a note that this is only the URNs given, so an agent working through "all tables in X" does not report done after one batch. They are the first tools in the Write metadata group (ToolType.MUTATION); remove_tags is @destructive. Writes switch: register_tools now reads TOOLS_IS_MUTATION_ENABLED. It defaults to true in OSS (DataHub Cloud defaults it off); false registers no mutation tool at all, including ones behind other flags. Each write runs with the caller's own token, so GMS still enforces the caller's privileges. From DataHub Cloud's tools/tags.py: both tools, their descriptions and response shape, the per-call scope note (PER_CALL_SCOPE_NOTE, now in graphql_helpers), and @min_version(oss="1.4.0", cloud="0.3.16"). Not ported: propose_tags. From the legacy OSS server (d05ef3d): tag_urns, entity_urns and column_paths are StrList / OptionalNullableItemStrList, so a bare string or a JSON-stringified array is accepted while the schema stays a plain array. Adapted to this package: the add and remove code is shared with the glossary term tools to come (label_writes.batch_modify_labels; DataHub Cloud duplicates it per label kind), and the mutations live in tags.gql. Errors are ToolErrors that say what to do: a tag name instead of a tag URN points at search(filter="entity_type = tag"); a malformed asset URN, a column paired with a non-dataset, or a column_paths length mismatch fails before anything is written (one bad entry fails the whole call). Tag existence is checked through ReadBackend.exists, one URN at a time: DataHub Cloud's entities(urns:) check passed tags that do not exist, because GMS answers an unknown URN with a stub. Only add_tags checks it; removing a reference to a tag that was since deleted is how it gets cleaned up, and GMS allows that. New graphql_helpers.execute_write runs a mutation once (never retried): when GMS answers with errors the message carries GMS's reason (e.g. "Unauthorized ..."); when no answer arrives (timeout, dropped connection, 5xx) it says the write may or may not have been applied and what to check. Tested: unit tests for assets, columns and mixed batches, removal of a deleted tag, a missing tag, bad arguments (bare tag name, a term URN, empty lists, a malformed asset URN, length mismatch, a column on a dashboard) writing nothing, a false result, a refused write reported once, an unknown outcome, existence read through a host-bound ReadBackend, stringified list arguments through an MCP client with plain array schemas, the write group and annotations, and the switch unset, true and false (false lists only read-only tools, with the versioning and inventory flags on). tags.gql validates on GMS 1.7.0, 1.8.0 and master. Live on a local OSS DataHub with auth on, through the frontend's /mcp: a run-unique tag added to the ORDERS dataset and its order_total column (with stringified list arguments), confirmed in GraphQL, then removed (confirmed gone); a missing tag, a bare tag name and a missing dataset are tool errors (the last one GMS's "Entity does not exist"); a temporary non-admin user's PAT gets "DataHub rejected batchAddTags: Unauthorized ..." and the dataset is unchanged. In memory, the switch unset or true lists add_tags and remove_tags; false lists 14 tools, none of them writes. The test tag was deleted afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_tag(name, description?, color?) makes a tag and returns
{urn, created}, so an agent asked to tag something with a tag that does
not exist yet can create it and pass the urn to add_tags. It is
idempotent by name: calling it again returns the same tag with
created=false instead of making a second one. add_tags' description now
points at it.
New in OSS; neither DataHub Cloud nor the legacy OSS server has it.
How it decides:
- The name is the tag's id (urn:li:tag:<name>), so names containing
"(", ")" or "," are refused before anything is read or written. A color
that is not hex (#RGB or #RRGGBB, "#" optional) is refused too.
- A tag with that id is returned as is (matched: "id").
- Otherwise a best-effort search for the name returns a tag whose display
name equals it in any case (matched: "name"), e.g. "pii_data" returns a
tag named "PII_Data". A failed search does not block the create; a
merely similar name ("PII data") does not count.
- Otherwise createTag with the name as id. If GMS answers that the tag
already exists (made concurrently), that tag is returned with
created=false.
- CreateTagInput has no color, so setTagColor follows the create. If it
fails, the call still succeeds with the created URN, created=true and a
color_error (partial success).
- Description and color apply only to a new tag; for an existing one the
result notes they were not applied.
A write that gets no reply says its outcome is unknown and that calling
create_tag again is safe. Nothing is retried automatically.
Also: a ReadBackend.tags_named read (findTagsByName in tags.gql) for the
name lookup, and an @idempotent marker that sets MCP idempotentHint on
write tools (explicit true or false; read-only tools leave it out, as the
spec gives it no meaning there). create_tag, add_tags and remove_tags are
idempotent; create_tag is not destructive. createTag, setTagColor and
search(input: {type: TAG}) all exist on GMS 1.7.0;
@min_version(oss="1.4.0", cloud="0.3.16") as for the other tag tools.
Tested: unit tests for a new tag (id, description, normalized color as a
second write), an existing id (no writes, note), an existing display name
in another case, a similar name that does not count, a failed name
search, reserved characters and a blank name, a bad color, a color
failure as partial success, a concurrently created tag, a refused create,
and the annotations. Live on a local OSS DataHub with auth on, through
the frontend's /mcp: a run-unique tag created with a description and
color "1890ff" (GraphQL shows colorHex #1890FF); the same name again
returns it with created=false and notes the color was not applied; the
same name upper-cased returns it by display name; "pii_data" returns the
showcase tag "PII_Data"; "a,b" is refused; a temporary non-admin user's
PAT gets "DataHub rejected createTag: Unauthorized ..." and no tag is
made. The created tag was added to the ORDERS dataset and its
order_status column with add_tags and removed with remove_tags (checked
in GraphQL both times), then deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
add_terms attaches one or more existing glossary terms to assets, or to dataset columns when column_paths pairs a column with an asset, in one batch write; remove_terms takes them off. They answer like add_tags and remove_tags (success, entities covered, the per-call scope note), are in the Write metadata group, idempotent, and remove_terms is @destructive. TOOLS_IS_MUTATION_ENABLED=false hides both. From DataHub Cloud's tools/terms.py: both tools (registered as add_terms and remove_terms, the names DataHub Cloud and the legacy server publish and the server instructions already route to), their descriptions and response shape, and @min_version(oss="1.4.0", cloud="0.3.16"). Not ported: propose_glossary_terms. From the legacy OSS server (d05ef3d): term_urns, entity_urns and column_paths accept a bare string or a JSON-stringified array, with plain array schemas. Adapted to this package: the tools are a glossary-term LabelKind over the add/remove code add_tags and remove_tags already use, so they get the same behavior: ToolErrors that point at search(filter="entity_type = glossaryTerm") for a term name or a non-term URN, input checks that fail the whole call before anything is written, term existence read through ReadBackend.exists on add only (DataHub Cloud's entities(urns:) check passed terms that do not exist; removing a reference to a deleted term stays possible), GMS's reason on a refused write, and an unknown-outcome message instead of a retry. The mutations live in glossary_terms.gql. Tested: unit tests for an asset and a column in one call (termUrns, resources), removal, a missing term, a term name and a tag URN refused as terms, and through an MCP client stringified list arguments, the registered names, annotations and group. glossary_terms.gql validates on GMS 1.7.0, 1.8.0 and master. Live on a local OSS DataHub with auth on, through the frontend's /mcp: a run-unique glossary term (created for the test) added to the ORDERS dataset and its order_status column with term_urns as a bare string, confirmed in GraphQL, then removed (confirmed gone); a tag URN and a missing term are tool errors; a temporary non-admin user's PAT gets "DataHub rejected batchRemoveTerms: Unauthorized ...". The test term was deleted afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_glossary_term(name, description, parent_node_urn?, id?) adds a term
to the business glossary, optionally under a glossary node, and returns
its term_urn for add_terms. add_related_terms relates a term to other
terms: "isA" (inherits from, e.g. CreditCardNumber isA PII) or "hasA"
(contains). Both are in the Write metadata group and not destructive;
add_related_terms is idempotent (GMS skips a relationship that exists).
add_terms' description and its "term not found" message now point at
create_glossary_term. TOOLS_IS_MUTATION_ENABLED=false hides both.
From DataHub Cloud's tools/glossary_versioning.py, where both live: the
tools, their descriptions and response shapes, and
@min_version(oss="1.4.0", cloud="0.3.16"). They need no versioning and
DataHub Cloud registers them without ENTITY_VERSIONING_ENABLED, so here they
get their own module, glossary.py; the module docstring of
glossary_versioning.py now says only create_glossary_term_version goes
there. The legacy OSS server has neither tool.
Relationship kinds: DataHub Core's TermRelationshipType has only isA and
hasA, so on Core (register_tools with is_oss=True) the parameter is an
enum of those two and asking for one of the five kinds only DataHub
Cloud's schema has (synonymOf, antonymOf, translatesTo, hasValue,
isRelatedTo) gets a validation error that names the two Core supports.
DataHub Cloud builds this same package, so with is_oss=False the tool is
registered as DataHub Cloud has it: all seven kinds in the enum, DataHub Cloud's
description of each, every kind passed to addRelatedTerms as is. Both
variants share the checks and the write. "Inherits" / "Contains" (the
UI's labels), other spellings of isA / hasA and any case of a kind's name
are accepted.
Adapted to this package: ToolErrors instead of RuntimeErrors, mutations
in glossary_terms.gql, related_term_urns as a StrList. Arguments are
checked before writing: term and node URNs by type (with a glossary-URN
example rather than a dataset one), an id containing "(", ")" or ",", a
blank name, a term related to itself, duplicates dropped. A parent node
must exist (ReadBackend.exists): GMS records any parent URN it is given,
so a missing node would leave the term outside the visible hierarchy.
create_glossary_term always sends an id, a UUID when none is given (GMS
would generate the same kind), so a create that gets no reply still names
the term to check instead of inviting a retry that could make a
duplicate; GMS's own refusals (same name at the same level, privileges,
missing related terms) reach the caller as they are.
Tested: unit tests for a term under a node, the generated id named in an
unknown outcome, a missing node, a non-node parent and a bare name,
unusable ids and names, a duplicate name, isA with duplicates dropped,
invalid relationships writing nothing, a false result, and through an
MCP client the Core enum schema, the "Inherits" alias, a Cloud-only kind
refused, the annotations, and the Cloud variant's seven-kind enum and
description with synonymOf passed through. glossary_terms.gql validates
on GMS 1.7.0, 1.8.0 and master. Live on a local OSS DataHub with auth
on, through the frontend's /mcp, under a run-unique glossary node made
for the test: a term created with an id and one without (UUID URN), both
under the node; the same name again gets GMS's "already exists at this
level"; a missing parent node is refused; add_related_terms with
"Inherits" stores isRelatedTerms (checked in the aspect) and a second
call succeeds without change; synonymOf is refused as not on Core; a
missing related term gets GMS's "does not exist"; a temporary non-admin
user's PAT gets "Unauthorized" from both tools. The test node and terms
were deleted afterwards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_glossary_term_version creates a new version of a glossary term concept: a new GlossaryTerm linked into a VersionSet, after an existing term (whose set is looked up; an unversioned term becomes v1 of a new set), into a given version set, or as the first version of a new one. It returns the version set and the new term's URN. With a previous term, the new version inherits its parent and metadata and, where DataHub defines a DRAFT stage for glossary terms, starts there, so the previous version stays the latest visible one until the new one is published. It is in the Write metadata group, not destructive and not idempotent, and is registered with the version read tools only when ENTITY_VERSIONING_ENABLED is true (and TOOLS_IS_MUTATION_ENABLED is not false). From DataHub Cloud's tools/glossary_versioning.py: the tool, its description and response shape, and always sending an id (a UUID when none is given) so the new term's URN is known. The description no longer points at Cloud-only lifecycle tools for publishing. The legacy OSS server has no such tool. Version gates: @min_version(oss="1.10.0", cloud="0.3.16"), the same as the version read tools: createGlossaryTermVersion came with glossary term versioning (#20631), after releases/v1.9.0 was cut (DataHub Cloud marked the tool Cloud-only). The mutation is in glossary_versioning.gql with #[since oss=1.10.0 cloud=0.3.16] on its root field. The compiler cannot drop a whole operation, so the mutation also selects __typename: on older GMS the marker drops the real field, and with it $input and its input type, leaving a valid no-op operation, so the document still validates on GMS 1.7.0 and 1.8.0 for the read tools that share it. Adapted to this package: ToolErrors instead of ValueErrors and RuntimeErrors; arguments checked before writing (both a version set and a previous term, a non-term previous URN, a non-version-set URN, a blank version, an id containing "(", ")" or ","); the previous term or version set must exist (ReadBackend, require_existing; a version set by its own key aspect) and a parent node must be an existing glossary node. GMS's refusals reach the caller as they are; a write that gets no reply names the term URN to check instead of inviting a retry. The id, parent-node and term-URN checks are shared with create_glossary_term and add_related_terms (glossary.py; both its Core and its Cloud variant), and compare_glossary_term_versions now uses the same term-URN check (its message gains a glossary term example and a search hint). Tested: unit tests for a version in a given set (input, no generic exists call), a version after a term (the sent id is the returned URN), invalid arguments writing nothing, a missing previous term, a refused write, an unknown outcome naming the term, the version gate on all three versioning tools, and registration with the flag on, off and unset (the writes switch off hides it too). 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 would hide the tool), on test terms under a run-unique glossary node: v2 after an unversioned term made that term v1 of a new set and linked the new term as v2 (isLatest false, comment and parent inherited, checked in GraphQL; get_glossary_term_versions lists only the published v1 until v2 is published); a new concept got its own set; both options and a missing previous term are tool errors; a temporary non-admin user's PAT gets "DataHub rejected createGlossaryTermVersion: Unauthorized ...". The test terms, version sets and node were deleted afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
set_domains(domain_urn, entity_urns) puts assets in a domain, replacing the domain each one had (an asset belongs to at most one); remove_domains (entity_urns) takes them out of their domain. Both are one batchSetDomain write over all the assets (remove sends a null domain), answer with the number of assets covered and the per-call scope note, and are in the Write metadata group, destructive (a set replaces the previous domain) and idempotent. TOOLS_IS_MUTATION_ENABLED=false hides both. From DataHub Cloud's tools/domains.py: the tools, their descriptions and response shapes (domain_urn, entities_updated, the scope note), the destructive marker and @min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server: entity_urns as a StrList, so a bare URN or a JSON-stringified list is accepted while the schema stays an array (d05ef3d). propose_domain is not ported. Adapted to this package: ToolErrors instead of ValueErrors and RuntimeErrors; the write goes through execute_write (one attempt; no reply means "may or may not have been applied", with what to check); batchSetDomain is in domains.gql, valid on GMS 1.7.0, 1.8.0 and master. The domain must be a domain URN that exists, checked through ReadBackend (DataHub Cloud ran its own entity query); the asset URNs get the same checks add_tags gives them (label_writes.require_entity_urns, now public), so a name or malformed URN fails the whole call, with a search hint, before anything is written. DataHub Cloud's examples used dataFlow and dashboard URNs that do not parse; they are replaced. Tested: unit tests for a set over two assets (input, scope note, the one existence check), remove sending a null domain with no domain check, invalid arguments writing nothing (a name, a tag URN, a missing domain, no assets, a bad asset URN), a false result, a refused write, an unknown outcome, the domain check going through a bound ReadBackend, and through an MCP client a stringified list and the annotations and group. Live on a local OSS DataHub with auth on, through the frontend's /mcp, with a run-unique domain made for the test: set on a dbt and a Postgres orders dataset (both read back in the domain), again with a stringified list; a missing domain, a tag URN and a bare name are tool errors; remove left the Postgres dataset without a domain and a second remove succeeded; a temporary non-admin user's PAT got "DataHub rejected batchSetDomain: Unauthorized ..." from both tools. Both datasets' domains were restored (the dbt one to its original domain) and the test domain was deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_domain(name, description?, parent_domain?) makes a domain, at the
top level or under an existing domain, and returns {urn, created}. It is
idempotent by name: calling it again with a name that already exists
under the same parent returns that domain with created=false (and a note
when a description was given, since it only applies to a new domain),
while the same name under a different parent is a different domain. It
is in the Write metadata group, not destructive and idempotent.
set_domains' description and its missing-domain message now point at it,
for the create-then-assign flow. TOOLS_IS_MUTATION_ENABLED=false hides
it. New in this package: neither DataHub Cloud nor the legacy OSS server has
it. @min_version(oss="1.4.0", cloud="0.3.16") like the other domain
tools; createDomain and listDomains (with parentDomain) are on GMS 1.7.0.
How it finds an existing domain:
- GMS refuses a second domain with the same name among a parent's direct
children ("... already exists in this domain"). On that refusal the
tool looks the domain up among the parent's children (listDomains with
the parent, or the top-level domains; exact name, as GMS compares) and
returns it. This covers domains made elsewhere, e.g. in the UI.
- GMS's name check runs on the search index, which lags writes: live, two
quick creates of the same name with random ids both passed it and made
two domains. So the tool derives the id from the parent and name (a
UUID5) instead of letting GMS pick a random one, and first reads that
URN's domainProperties directly (ReadBackend.aspects, not search): a
repeated call finds its domain at once. A domain at that id that was
since renamed or moved does not block a new one, which gets a random
id. A known id also lets a create that gets no reply name the URN a
retry will return.
- The parent must be an existing domain (ReadBackend), checked before
writing: GMS's own refusal of a missing parent does not say which URN.
No locks: two concurrent first calls can still race, as in the UI.
ReadBackend gains domains_named(name, parent_domain, count) for the
lookup (findDomainsByName in domains.gql); the test fakes implement it.
Tested: unit tests for a domain under a parent (input, parent check), a
repeated call answered by the direct read with no second write, a domain
moved away from its id not blocking a new one, a duplicate under the same
parent (GMS's refusal, then the lookup under that parent, ignoring a
similar name), a top-level duplicate looked up at the top level, the same
name under another parent created, a conflict whose domain is not found,
invalid arguments creating nothing (blank name, missing parent, non-domain
parent), an unknown outcome naming the URN, other refusals passed on, and
the annotations and set_domains' pointer through an MCP client. Live on a
local OSS DataHub with auth on, through the frontend's /mcp, with
run-unique names: a top-level domain created and the same call again
returned it with created=false and the description note; "Campaigns"
under it created, again returned it; "Campaigns" under a second domain
was a new domain; a domain made directly through GraphQL with a random
id (as the UI does) was found through GMS's name check and returned with
created=false; a missing parent and a bare name are tool errors; a
temporary non-admin user's PAT got "DataHub rejected createDomain:
Unauthorized ..."; the child read back with its parent; set_domains
accepted the new domain; after deleting a domain, creating it again
works. Every test domain was deleted and the dataset's domain removed
again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
add_owners(owner_urns, entity_urns, ownership_type) makes users and
groups owners of assets with one ownership type; remove_owners
(owner_urns, entity_urns, ownership_type?) takes them off, of one type
or of any. Each is one batch write over all the assets, answering with
the number covered and the per-call scope note. The type is a built-in
(TECHNICAL_OWNER, BUSINESS_OWNER, DATA_STEWARD; also by value, by URN,
or spelled as in the UI, e.g. "technical owner") or a custom type by
its name, case-insensitive, or its URN. Both are in the Write metadata
group and idempotent; remove_owners is destructive.
TOOLS_IS_MUTATION_ENABLED=false hides both.
From DataHub Cloud's tools/owners.py: the tools, their descriptions and
response shapes, built-in and custom type resolution (exact-name match on
listOwnershipTypes, an ambiguous name refused), owner entity types from
the URN, the destructive marker on remove_owners and
@min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server:
ownership_type published as a single-type {"type": "string"} schema
rather than anyOf [enum, string], which constrains nothing and which
Gemini and several OpenAI-compatible endpoints reject, failing the whole
tool list (41ff2dd); owner_urns and entity_urns as StrLists (d05ef3d).
propose_owners is not ported.
Adapted to this package: ToolErrors instead of ValueErrors and
RuntimeErrors; writes through execute_write (one attempt; no reply means
"may or may not have been applied"); mutations and the type lookup in
owners.gql, valid on GMS 1.7.0, 1.8.0 and master. Reads go through
ReadBackend: owner existence (DataHub Cloud ran its own entities query) and a
new ownership_types_named lookup (the test fakes implement it). Owner
URNs must be user or group URNs (a name or another entity's URN is
refused with a search hint) and, for add_owners, exist; remove_owners
does not require that, since removing a deleted user's ownership is how
it gets cleaned up (DataHub Cloud checked both). Duplicate owners are
dropped. Asset URNs get the checks add_tags gives them. A custom type
not found says that search can miss a type made seconds ago and to pass
its URN. The built-in examples now pass strings, as clients do.
A new test in test_mcp_server checks that no registered tool publishes a
parameter whose anyOf/oneOf branches differ in type (nullable is fine),
with every gate open, so a union added later fails there.
Tested: unit tests for a user and a group added to two assets (input
shape, the existence checks), built-in types in four spellings with no
lookup, a custom type by exact name among similar ones, an unknown and
an ambiguous custom type writing nothing, removing any type without an
existence check, removing one type, invalid arguments writing nothing,
a false result, a refused write, an unknown outcome, and through an MCP
client the published ownership_type schemas, stringified lists and the
annotations. Live on a local OSS DataHub with auth on, through the
frontend's /mcp: a user and a group added as technical owners of the
Postgres orders dataset, the same add again ("technical owner", bare and
stringified lists) changed nothing; a data steward added to the dbt
orders dataset and then removed by type left its original owners as they
were; a custom ownership type made for the test (run-unique name) was
used and removed by name in other cases once search had indexed it (two
seconds); a missing user, a bare name and an unknown type are tool
errors; removing all, then again, succeeded; a temporary non-admin
user's PAT got "DataHub rejected batchAddOwners / batchRemoveOwners:
Unauthorized to update owners ...". Both datasets' owners were checked
equal to the originals and the custom type was deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
update_description(entity_urn, operation?, description?, column_path?)
replaces, appends to or removes the description of an asset, or of one
of a dataset's columns. It is in the Write metadata group, destructive
and not idempotent (an append adds its text again).
TOOLS_IS_MUTATION_ENABLED=false hides it.
From DataHub Cloud's tools/descriptions.py: the tool, its operations,
description and response shape, the destructive marker and
@min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server:
GraphQL answers an unset aspect with an explicit null, so a null
entity, editableProperties, properties or schemaMetadata reads as no
description instead of raising and being swallowed as a failed read
(e0507ea). propose_description is not ported.
Fixed while porting:
- Append extends the description DataHub shows: the one edited in
DataHub when set, else the one from the source system. DataHub Cloud read
only the edited one for most assets and only the source one for
columns, so appending to an asset documented only at the source, or
to a column with an edited description, replaced the shown text with
the appended text alone.
- A failed read now fails an append before anything is written; DataHub Cloud
treated it as an empty description, which overwrote it the same way.
An append for a type the read does not cover, a missing entity, or a
column not in the schema is refused.
- GMS's updateDescription refuses charts, dashboards, data flows and data
jobs ("Unsupported resource type"), which DataHub Cloud's description
listed; for those the tool uses updateChart / updateDashboard /
updateDataFlow / updateDataJob with editableProperties, as the UI does.
- The description says that "remove" clears the edited description, so
a source-system description comes back into view.
Adapted to this package: ToolErrors instead of ValueErrors and
RuntimeErrors; the entity URN is checked (a name gets a search hint) and
column_path is only accepted for datasets; writes go through
execute_write (one attempt; an append that gets no reply warns that
appending again would add the text twice); the read goes through a new
ReadBackend.description_sources (the test fakes implement it). The
mutations and getDescriptionSources are in descriptions.gql, valid on GMS
1.7.0, 1.8.0 and master.
Tested: unit tests for replace on an asset and a column, remove, a chart
through its own mutation, append to the edited, the source and a
glossary term description and with null aspects, append to a column
(edited field info, source field, null edited description), appends that
cannot read the description writing nothing (missing entity, unsupported
type, a dataset without a schema), a failed read never becoming a
replace, the read going through a bound ReadBackend, invalid arguments,
a false result, a refused write, an unknown outcome on append, and the
annotations through an MCP client. Live on a local OSS DataHub with auth
on, through the frontend's /mcp: on the dbt order_history dataset an
append extended its description, then replace and remove (the source
description showed again); on a column of the dbt orders dataset with
only a source description, two appends extended it and remove cleared
the edited one; a Looker chart's description was replaced and appended
to (updateChart); a run-unique tag made for the test got an append; a
column not in the schema (append, and replace through GMS), a column on
a chart and a missing dataset are errors; a temporary non-admin user's
PAT got "DataHub rejected updateDescription / updateChartDescription:
Unauthorized ...". The dataset's description was restored to its
original text, the chart's editable aspect deleted again (it had none),
the column's edited description left empty (it had none; the source
description shows as before), and the tag deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rties
add_structured_properties(property_values, entity_urns) sets typed
structured property values on assets (the given values replace that
property's values; other properties are left as they are);
remove_structured_properties(property_urns, entity_urns) takes
properties off assets. GMS has no batch form, so each asset is one
write; every argument is checked before the first. Both are in the Write
metadata group, destructive and idempotent.
TOOLS_IS_MUTATION_ENABLED=false hides both.
From DataHub Cloud's tools/structured_properties.py: the tools, their
descriptions and response messages, value conversion by the property's
value type (number, string, URN, ISO 8601 date, rich text), the
destructive marker on remove and @min_version(oss="1.4.0",
cloud="0.3.16"). From the legacy OSS server: values published as a
single {"type": "string"} schema while still accepting numbers at
runtime, since Gemini accepts only one type and several OpenAI-compatible
endpoints reject multi-type unions (41ff2dd, 01054c4); the examples pass
numbers as numeric strings; entity_urns and property_urns as StrLists
(d05ef3d). The schema test added with add_owners now also flags a `type`
list with more than one non-null type (01054c4).
propose_structured_properties is not ported.
Fixed while porting:
- A property that does not exist is refused. GMS answers it with
exists=false and a placeholder string definition, which DataHub Cloud's
check (entity is null) let through; live, such a write returned
success and stored nothing.
- A partial failure says which assets were updated and which were not,
with GMS's reason for each (DataHub Cloud listed only the failures, so a
caller could not tell what had changed), and that a retry is safe.
- A single-valued property given several values, and an empty value
list, are refused before writing.
- add_structured_properties is marked destructive (it replaces values).
- remove_structured_properties does not require the property to exist,
as removing tags does not: removing a reference to a deleted property
is how it gets cleaned up.
Adapted to this package: ToolErrors instead of ValueErrors and
RuntimeErrors; writes through execute_write (one attempt each; no reply
is reported per asset as "may or may not have been applied"); asset URNs
get the checks add_tags gives them; the definition read goes through a
new ReadBackend.structured_property (the test fakes implement it). The
mutations and getStructuredPropertyDefinition are in
structured_properties.gql, valid on GMS 1.7.0, 1.8.0 and master.
Tested: unit tests for four typed properties on two assets (the inputs
sent), invalid values writing nothing (no properties, a non-property
key, a missing property as GMS answers it, no values, a non-number, two
values for a single-valued property, a non-URN, a non-ISO date), a bad
asset URN, a partial failure (one applied, one refused, one without a
reply), remove with duplicates and no definition reads, an empty result,
the read through a bound ReadBackend, and through an MCP client the
published value schema, an integer value, a bare entity URN and the
annotations. Live on a local OSS DataHub with auth on, through the
frontend's /mcp: a run-unique multi-valued property made for the test
and the showcase dataQualityScore set on the Postgres and S3 orders
datasets (read back), an integer score accepted; a non-number, two
values for a single-valued property, a non-URN, a missing property and
a value outside GMS's allowed values are errors; a missing dataset among
two got "applied to 1 of 2" with GMS's reason; remove took the test
property off both, and again; a temporary non-admin user's PAT got
"Not authorized to update properties" from both tools. Both datasets'
properties were checked equal to the originals and the test property
was deleted (soft, then hard, as this GMS requires).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
save_document(document_type, title, content, urn?, topics?,
related_documents?, related_assets?, parent_urn?) saves a standalone
document (an insight, decision, FAQ, ...) to DataHub's knowledge base.
Without `urn` it creates a new document, owned by the caller, under
`parent_urn` or else under a shared folder the tool keeps ("Shared",
optionally with a subfolder per author). With the `urn` of a stored
document it replaces that document's title, body and type in place and
keeps everything else: parent, owners, status, visibility, created
stamp, and the topics and related links not passed. It is in the Write
metadata group, destructive and not idempotent (each create is a new
document). TOOLS_IS_MUTATION_ENABLED=false or SAVE_DOCUMENT_TOOL_ENABLED
=false hides it.
From DataHub Cloud's tools/save_document.py and
document_edit_policy.py: the tool and its description, `parent_urn` for
new documents (a parent must exist; setting it on an update is refused,
moves are update_document's), the in-place update that fixes the
re-parenting of the legacy OSS server's version (it rebuilt the
document on every update, which moved it into the shared folder and
reset its status, created stamp and visibility), restoring a
soft-deleted shared folder (also legacy OSS c978c57), DocumentSettings
stamped with the caller on every save, certification left out of the
upsert, the retrieval-policy configuration guard, the host edit policy
(entry point datahub.mcp.document_edit_policy) and its pre-approval
validator, and the gates with DataHub Cloud's defaults:
SAVE_DOCUMENT_TOOL_ENABLED on, SAVE_DOCUMENT_RESTRICT_UPDATES off (when
on, only documents inside the shared folder may be updated),
SAVE_DOCUMENT_ORGANIZE_BY_USER off, SAVE_DOCUMENT_PARENT_TITLE "Shared".
@min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server:
topics, related_documents and related_assets as OptionalStrLists (a
bare or stringified list is accepted; "" and "null" count as omitted)
(d05ef3d, 01054c4). DataHub Cloud's MemorySynthesizer helper
(create_user_scoped_document) is not a tool and is not ported.
version_requirements gains @pre_approval_validator, which sets the
attribute approval hosts read.
Fixed while porting, so a failed or partial save never creates a
duplicate or re-parents a document:
- A failed read of the document to update (existence or fetch) stops
the call; DataHub Cloud could fall through to creating it again in the
shared folder.
- A shared folder that cannot be created or restored stops the save,
instead of saving the document under a missing (hidden) folder.
- Writes are single attempts: a refusal gives GMS's reason (the
validator's message for a rejected aspect), and no reply says the
save may or may not have been applied, naming the URN; for a create
it says to retry with urn=<that URN>, which updates instead of making
a second document.
- related_documents must be document URNs and related_assets URNs;
blank topics are dropped; SDK usage errors become tool errors.
Adapted to this package: reads go through ReadBackend (existence,
folder status and the shared-folder ancestry via aspects); the caller is
read with getDocumentAuthor in document_writes.gql (valid on GMS 1.7.0,
1.8.0 and master); loguru; ToolErrors throughout.
Tested: unit tests against a fake catalog with real SDK documents: a new
document in the shared folder (owner, tags from topics, related asset,
settings actor), new URNs per create, a missing shared folder created
first, a soft-deleted one restored, a folder that cannot be created
stopping the save, a new document under a given parent, invalid
arguments writing nothing, a create without a reply naming the URN to
retry with; an update in place keeping parent, status, visibility,
related assets and owners with no folder touched, an update replacing
the lists it is given, a refused update written once with its original
parent and never turned into a create, an update without a reply, an
update whose document cannot be read (exists or get) writing nothing, an
unknown URN created at that URN, SAVE_DOCUMENT_RESTRICT_UPDATES, a
locked field refused by the pre-approval validator and the tool, the
registration (annotations, group, stringified lists) and the gate on and
off. Live on a local OSS DataHub with auth on, through the frontend's
/mcp, with run-unique titles: a new insight landed in a newly created
"Shared" folder with its tag, related asset and owner; a document
created under another test document as parent, then updated through
save_document in place (same URN, title, body and type replaced, parent
and owners kept); parent_urn on an update, a missing parent and a
dataset URN as a related document are errors; a given unknown URN was
created there; a temporary non-admin user's PAT got "DataHub rejected
saving ...: ... unauthorized to modify entity" for a create and an
update, and the update left the document unchanged. All test documents
and the shared folder (absent before the test) were hard-deleted
(deleteDocument only soft-deletes).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
update_document(urn, command, ...) changes part of an existing document
without sending it whole: update_content applies anchored {old_str,
new_str, replace_all_matches?} edits to the body; replace_content
replaces the body (allow_deleting_content=true is required when there
is one); append_content adds to the end; update_properties changes
title, topics, related documents, related assets or status
(PUBLISHED / UNPUBLISHED) without the body; move puts the document,
with what is nested under it, under another document. Every command but
move edits the stored document in place, keeping its parent, owners and
visibility. It is in the Write metadata group, destructive and not
idempotent, and is registered with save_document behind the same gates
(TOOLS_IS_MUTATION_ENABLED, SAVE_DOCUMENT_TOOL_ENABLED, both on by
default).
From DataHub Cloud's tools/update_document.py: the commands and their
argument checks (an argument of another command names the command that
owns it; a missing or empty required one shows its shape), the anchored
edit rules, the replace guard, moves through GMS's moveDocument (which
refuses a missing parent and a loop under the document's own
descendant; an upsert of documentInfo would not), the
SAVE_DOCUMENT_RESTRICT_UPDATES guardrail (off by default) also applied
to a move's target, the configuration-document guard, the host edit
policy with its pre-approval validator, lastModified stamped with the
caller, certification left out of the upsert, and
@min_version(oss="1.4.0", cloud="0.3.16"). The legacy OSS server's
version lacks move and the in-place guarantees; its separate
MCP_UPDATE_DOCUMENT_ENABLED gate is not ported (DataHub Cloud dropped it: the
two tools ship together).
So a failed update never re-parents a document or creates one: a
missing document is refused (use save_document to create); a failed
read stops the call before any write; a refused or failed move writes
nothing else; a content or property write is one upsert of the stored
document in its own folder, never retried, with GMS's reason on a
refusal and "may or may not have been applied" when there is no reply
(for an append, a warning that appending again would add the text
twice). SDK usage errors become tool errors.
Adapted to this package: shared helpers from save_document.py (write
handling, the caller, guards); existence read through ReadBackend;
moveDocument in document_writes.gql (valid on GMS 1.7.0, 1.8.0 and
master); ToolErrors throughout.
Tested: unit tests for anchored edits (one and replace-all) changing only
the body, edits that do not anchor (missing, ambiguous, no old_str)
writing nothing, the replace guard, append, update_properties leaving the
body (tags, status, settings actor), move through moveDocument with no
other write, a refused move changing nothing, arguments that do not fit
the command, a missing document not created, a failed read, a refused
update written once in its own folder, an append without a reply, the
shared-folder guardrail, a locked field refused before approval and by
the tool, and registration with save_document behind one gate. Live on a
local OSS DataHub with auth on, through the frontend's /mcp, on
run-unique test documents: an anchored edit, ambiguous and missing
anchors refused, replace refused then confirmed, append, title, topic and
status changed, all with the parent and owner unchanged; a foreign
argument and a missing document are errors; a temporary non-admin user's
PAT got "unauthorized to modify entity" for an append and "DataHub
rejected moveDocument: Unauthorized" for a move, and the document was
unchanged; a move to another folder worked, a move under the document's
own child got "would create a circular parent reference" and a move
under a missing document "does not exist", both leaving the parent as
it was. All test documents and the shared folder (absent before) were
hard-deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- create_domain: when the derived id holds a renamed or moved domain, try the next derived id (parent/name#1, #2, ...) instead of a random uuid4, so a retry after a lost reply lands on the same domain; give up with an error after ten. - create_domain: when GMS refuses the derived id itself ("This Domain already exists!"), re-read that id and return it with created=false if it holds the requested name and parent. - remove_domains: the unknown-outcome hint now says why a retry is safe for an unset, not a set. - remove_owners: a blank ownership_type means any type, as when it is omitted. - create_tag: a soft-deleted tag at the id is reported as an error instead of being returned as the existing tag. - update_description append: the sibling read must return every live sibling the dataset's siblings aspect names; a null or partial result now stops the append instead of appending to the local text alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- update_document update_properties writes each field through a field-scoped write (updateDocumentContents with only a title, updateDocumentRelatedEntities, updateDocumentStatus, and the globalTags aspect for topics) instead of upserting the document as read, so a concurrent body, parent or link edit is never reverted; a failure partway says which fields were already applied - update_document rejects a blank title and an edit without new_str (which would have deleted old_str) - save_document: topics=[] clears the topics, like the other lists - save_document refuses to save over a folder, which would replace its Folder subtype and drop it and its subtree from the sidebar - save_document leaves the stored semanticContent (embedding vectors) out of an in-place save, so the old body's vectors are not re-indexed - save_document accepts parent_urn with urn when the document does not exist yet or already has that parent, and the unknown-outcome hint names parent_urn, so retrying a create keeps its parent instead of using the shared folder - with SAVE_DOCUMENT_RESTRICT_UPDATES, save_document creates documents only inside the shared folder - write_document treats a GraphError, or an OperationalError whose recorded status is below 500, as a refusal rather than an unknown outcome Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7383f0c to
99f89b4
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 99f89b4. Configure here.
| # text would build the write on less than DataHub shows. | ||
| raise RuntimeError( | ||
| f"the sibling read did not return {', '.join(sorted(missing))}" | ||
| ) |
There was a problem hiding this comment.
Sibling cap blocks description append
Medium Severity
description_sources requires every live sibling from the siblings aspect to appear in GetEntitySiblings, but that query is capped at count: 5. A dataset with more than five siblings always fails the completeness check, so update_description with append refuses to write even though the UI itself only merges five.
Reviewed by Cursor Bugbot for commit 99f89b4. Configure here.
| properties = (get_read_backend().aspects(urn) or {}).get("domainProperties") | ||
| if not isinstance(properties, dict): | ||
| return None | ||
| return properties.get("name") == name and properties.get("parentDomain") == parent |
There was a problem hiding this comment.
Deleted domains treated as existing
Medium Severity
_holds treats a derived domain id as a successful match whenever domainProperties name and parent line up, and never reads status.removed. A soft-deleted domain at that id is returned as created=false, so later set_domains can assign assets to a removed domain.
Reviewed by Cursor Bugbot for commit 99f89b4. Configure here.


Ports DataHub's write tools to the built-in MCP server's
datahub-core-mcp-toolspackage. It is based onna--mcp-search(#21435, the read tools), and the server stays off until GMS hasMCP_SERVER_ENABLED=true(added in #21349).This PR started as the tags port. The other write-tool PRs, #21502 to #21512, have been merged into it, so it now carries all 12 reviewed and approved write-tool ports. It changes only
datahub-core-mcp-toolsanddatahub-ai-service.Stack so far:
1–22. Merged to
masteras #21332.23–34. #21435, the read tools (PRs 24–34 merged into it).
35–46. #21501 ← this PR, the write tools (PRs 36–46 merged into it).
47–55. #21587, MCP settings: model, API and UI.
56–60. #21588, telemetry, metrics, usage events and the stdio server.
61–64. #21589, docs, release notes and smoke tests.
65–68. #21590, settings enforcement and the tool catalog.
69–70. #21591, the home page module.
71–74. #21623, the ingestion tools.
What this does
Each port has its tool, its
.gql, the helpers it needs and its tests. All are in the Write metadata group and run with the caller's own token, so GMS still enforces the caller's privileges.register_toolsreadsTOOLS_IS_MUTATION_ENABLED. It defaults to true in DataHub Core (DataHub Cloud defaults it off). False registers no write tool at all, including ones behind other flags.add_tagsandremove_tags(feat(mcp): port the write tools to DataHub Core's MCP server #21501): attach tags to assets or dataset columns in one batch write, or take them off. A sharedexecute_writeruns each mutation once and says whether the write may or may not have been applied when no answer arrives.create_tag(feat(mcp): add the create_tag tool #21502): creates a tag, idempotent by name. New here; DataHub Cloud has no equivalent.add_termsandremove_terms(feat(mcp): port add_terms and remove_terms #21503): the glossary-term counterparts of the tag tools, sharing their batch code.create_glossary_termandadd_related_terms(feat(mcp): port create_glossary_term and add_related_terms #21504).create_glossary_term_version(feat(mcp): port the create_glossary_term_version tool #21505): registered only whenENTITY_VERSIONING_ENABLEDis true.set_domainsandremove_domains(feat(mcp): port set_domains and remove_domains #21506).create_domain(feat(mcp): add the create_domain tool #21507): creates a domain, idempotent by name under its parent. New here.add_ownersandremove_owners(feat(mcp): port add_owners and remove_owners #21508): built-in and custom ownership types, by name or URN.update_description(feat(mcp): port the update_description tool #21509): replace, append to or remove an asset's or a column's description.add_structured_propertiesandremove_structured_properties(feat(mcp): port add_structured_properties and remove_structured_properties #21510).save_document(feat(mcp): port the save_document tool #21511): creates or replaces a standalone document in the knowledge base. Also gated bySAVE_DOCUMENT_TOOL_ENABLED.update_document(feat(mcp): port the update_document tool #21512): partial edits, property changes and moves for an existing document, behind the same gates.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
column_pathsmodule): by field path, then name, then case-insensitively.update_descriptionappends to the sibling-merged description when the asset has siblings.YYYY-MM-DD.save_documentstampscreatedandlastModified, refuses a deleted parent and keeps the document's semantic text in step.update_documentmakes content edits through theupdateDocumentContentsmutation.create_glossary_term_versionsays how to publish the new version.fix(mcp): address review findingscommits at the end of this range:create_domainretries return the same domain,create_tagrefuses a soft-deleted tag, appends stop when sibling text can't be read,remove_ownerstreats a blank type as any type,update_document's property edits write only the fields they change, andsave_documentkeeps folders, clears empty topics, drops stale embeddings and tells refusals apart from unknown outcomes.Testing
./gradlew :packages:datahub-core-mcp-tools:lint :packages:datahub-core-mcp-tools:testQuick :packages:datahub-ai-service:lint :packages:datahub-ai-service:testQuick. Tests pass: 894 in the core package and 85 in the service. Lint passes in CI; it doesn't run cleanly in my local environment, because its fastmcp is newer than the locked version..gqlagainst the pinned GMS schemas (1.7.0, 1.8.0, 1.9.0 andmaster)./mcp.Checklist
🤖 Generated with Claude Code