feat(mcp): port the list_schema_fields tool
Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--mcp-get-entities (the previous PR in the stack); review only its own commit. It changes only the shared datahub-core-mcp-tools package and datahub-ai-service. It is one tool port, so it stays one PR even where it runs past the stack's usual 1,000-line size. Everything user-facing is behind a GMS feature flag, MCP_SERVER_ENABLED, off by default (added in #21349).
Stack so far:
1ā22. Merged to master as #21332.
23. #21435
24. #21436
25. #21437 ā this PR
26. #21438
27. #21439
28. #21440
29. #21441
30. #21442
31. #21443
32. #21444
33. #21445
34. #21447
35. #21501
36. #21502
37. #21503
38. #21504
39. #21505
40. #21506
41. #21507
42. #21508
43. #21509
44. #21510
45. #21511
46. #21512
What this does
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.
Testing
18 tests; live: keyword ranking and paging, offsets past the end, bare-name rejection, missing dataset.
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