feat(mcp): compile GraphQL for the exact GMS version with #[since] markers
Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--mcp-version-filter (the previous PR in the stack); review only its own commit. These PRs build out the shared datahub-core-mcp-tools package and datahub-ai-service; nothing is wired into quickstart, the frontend or Helm yet, so they change no running DataHub. The later PRs that expose MCP are all behind a GMS feature flag, MCP_SERVER_ENABLED, off by default.
Stack so far:
- #21332
- #21333
- #21334
- #21335
- #21336
- #21337
- #21338 ā this PR
- #21339
- #21340
- #21341
- #21342
- #21343
- #21344
- #21345
- #21346
- #21347
- #21348
- #21349
- #21350
- #21351
- #21352
- #21353
- #21435
- #21436
- #21437
- #21438
- #21439
- #21440
- #21441
- #21442
- #21443
- #21444
- #21445
- #21447
- #21501
- #21502
- #21503
- #21504
- #21505
- #21506
- #21507
- #21508
- #21509
- #21510
- #21511
- #21512
What this does
Replace the old "try newer fields, turn them all off on the first error"
approach with exact version gates. A selection newer than GMS 1.7.0 carries
a #[since oss=X.Y.Z cloud=0.A.B.C] comment on its first line; a side left
out means the selection never runs there.
The compiler works on the graphql-core AST: it drops each unsupported
marked selection with its subtree, then fragments and variable definitions
nothing uses any more, and reports the dropped variables so they aren't
sent. A selection set left empty, a malformed marker, or a marker that
doesn't share its line with exactly one selection is a compile error.
Results are cached per (document, deployment, version).
When GMS reports no real release (unreleased builds) or nothing is known,
every version-gated selection is kept and the SDK strips what the server
lacks at runtime. A schema error on a known version is raised, never
retried with fewer fields.
execute_graphql compiles marked queries for the GmsServerInfo in the
request's tool context; datahub-ai-service puts it there for every MCP message.
Testing
- 20 compiler tests: dropped selections with their subtrees, unused fragments and variables (including a variable used only by a removed selection), empty selection sets and malformed markers as errors, unknown versions keeping everything, caching.
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). Docs come later in the stack, with the user-facing pieces.
- For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes. Not applicable: nothing user-facing changes yet.
š¤ Generated with Claude Code