feat(mcp): port the write tools to DataHub Core's MCP server
Ports DataHub's write tools to the built-in MCP server's datahub-core-mcp-tools package. It is based on na--mcp-search (#21435, the read tools), and the server stays off until GMS has MCP_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-tools and datahub-ai-service.
Stack so far:
1–22. Merged to master as #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.
- Writes switch (#21501):
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(#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(#21502): creates a tag, idempotent by name. New here; DataHub Cloud has no equivalent.add_termsandremove_terms(#21503): the glossary-term counterparts of the tag tools, sharing their batch code.create_glossary_termandadd_related_terms(#21504).create_glossary_term_version(#21505): registered only whenENTITY_VERSIONING_ENABLEDis true.set_domainsandremove_domains(#21506).create_domain(#21507): creates a domain, idempotent by name under its parent. New here.add_ownersandremove_owners(#21508): built-in and custom ownership types, by name or URN.update_description(#21509): replace, append to or remove an asset's or a column's description.add_structured_propertiesandremove_structured_properties(#21510).save_document(#21511): creates or replaces a standalone document in the knowledge base. Also gated bySAVE_DOCUMENT_TOOL_ENABLED.update_document(#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 paths resolve the same way in every tool (a shared
column_pathsmodule): by field path, then name, then case-insensitively. update_descriptionappends to the sibling-merged description when the asset has siblings.- Structured property dates must be
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.- The Cursor Bugbot findings on this PR and the folded write-tool PRs are fixed in the two
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
- At the final tip:
./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. - GraphQL snapshot tests check every new
.gqlagainst the pinned GMS schemas (1.7.0, 1.8.0, 1.9.0 andmaster). - Each folded PR's description lists its own testing, including live runs on a local DataHub Core through the frontend's
/mcp.
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