feat(mcp): port the update_description tool
Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--mcp-owners (the previous PR in the stack); review only its own commit. It changes only the shared datahub-core-mcp-tools package and datahub-ai-service. It is one tool port, so it stays one PR even where it runs past the stack's usual 1,000-line size. Everything user-facing is behind a GMS feature flag, MCP_SERVER_ENABLED, off by default (added in #21349).
Stack so far:
1–22. Merged to master as #21332.
23–34. #21435, the read tools (PRs 24–34 merged into it).
35. #21501
36. #21502
37. #21503
38. #21504
39. #21505
40. #21506
41. #21507
42. #21508
43. #21509 ← this PR
44. #21510
45. #21511
46. #21512
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.
What this does
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.
Testing
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.
Checklist
- The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
- Tests for the changes have been added/updated (if applicable)
- Docs related to the changes have been added/updated (if applicable). The MCP docs come later in the stack.
- For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes. The release notes come later in the stack.
🤖 Generated with Claude Code