Skip to content

feat(mcp): filter tools by the connected GMS version - #21337

Merged
nwadams merged 21 commits into
na--ai-service-releasefrom
na--mcp-version-filter
Nov 23, 2026
Merged

nwadams merged 21 commits into
na--ai-service-releasefrom
na--mcp-version-filter

Conversation

@nwadams

@nwadams nwadams commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on na--ai-service-release (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:

  1. feat(mcp): add DataHub's built-in MCP server, off by default #21332
  2. feat(mcp): read GMS version and deployment from /config #21333
  3. feat(ai): scaffold the datahub-ai-service with /health #21334
  4. feat(ai): serve MCP at /mcp with caller-scoped DataHub clients #21335
  5. build(ai): add PyPI release scripts for datahub-core-mcp-tools and datahub-ai-service #21336
  6. feat(mcp): filter tools by the connected GMS version #21337 ← this PR
  7. feat(mcp): compile GraphQL for the exact GMS version with #[since] markers #21338
  8. test(mcp): validate packaged GraphQL against pinned GMS schemas #21339
  9. feat(mcp): tool groups and tool-aware server instructions #21340
  10. feat(mcp): deliver tool cancellation safely and report progress on slow tools #21341
  11. feat(mcp): shared limits, truncation, list coercion and ToolError mapping #21342
  12. feat(mcp): ReadBackend and ResultPolicy retrieval seams #21343
  13. feat(ai): bound GMS requests and never replay one GMS may have run #21344
  14. feat(gms): report whether authentication is enabled in /config #21345
  15. feat(ai): follow GMS's auth mode on /mcp #21346
  16. feat(ai): refuse DNS-rebinding requests to /mcp while GMS auth is off #21347
  17. feat(ai): datahub-ai-service docker image and locked dependencies #21348
  18. feat(mcp): keep the MCP server off until MCP_SERVER_ENABLED is set #21349
  19. feat(frontend): proxy /mcp to the datahub-ai-service #21350
  20. ci(ai): build the datahub-ai-service image on every relevant PR #21351
  21. feat(docker): run datahub-ai-service in quickstart and datahub-dev #21352
  22. test(smoke): MCP through the frontend's /mcp route #21353
  23. feat(mcp): port the read tools to DataHub Core's MCP server #21435
  24. feat(mcp): port the get_entities tool #21436
  25. feat(mcp): port the list_schema_fields tool #21437
  26. feat(mcp): port the search_documents tool #21438
  27. feat(mcp): port the grep_documents tool #21439
  28. feat(mcp): port the grep_entities tool #21440
  29. feat(mcp): port the get_lineage tool #21441
  30. feat(mcp): port the get_lineage_paths_between tool #21442
  31. feat(mcp): port the get_dataset_queries tool #21443
  32. feat(mcp): port the get_dataset_usage_history tool #21444
  33. feat(mcp): port the get_aspect_history tool #21445
  34. feat(mcp): port the glossary term version read tools #21447
  35. feat(mcp): port the write tools to DataHub Core's MCP server #21501
  36. feat(mcp): add the create_tag tool #21502
  37. feat(mcp): port add_terms and remove_terms #21503
  38. feat(mcp): port create_glossary_term and add_related_terms #21504
  39. feat(mcp): port the create_glossary_term_version tool #21505
  40. feat(mcp): port set_domains and remove_domains #21506
  41. feat(mcp): add the create_domain tool #21507
  42. feat(mcp): port add_owners and remove_owners #21508
  43. feat(mcp): port the update_description tool #21509
  44. feat(mcp): port add_structured_properties and remove_structured_properties #21510
  45. feat(mcp): port the save_document tool #21511
  46. feat(mcp): port the update_document tool #21512

What this does

Add VersionFilterMiddleware to datahub-core-mcp-tools and install it in
datahub-ai-service. Tools/list hides tools whose @min_version the connected GMS
doesn't meet, and tools/call refuses them, so a client with a stale list
can't call them either.

  • The requirement travels with the registered tool function, so there is
    no module-level registry and two servers filter independently.
  • Deployment type (serverEnv) is always honored; the version is compared
    only for real releases, so unreleased builds keep their tools.
  • GMS info comes from a host-supplied callable; datahub-ai-service uses a
    GmsServerInfoCache (60 s) on its configured GMS URL. If /config can't be
    read, tools are left unfiltered and their own calls report the failure.

Testing

  • Unit tests: gated tools hidden from tools/list and refused on tools/call, deployment type always honored, unreleased builds keep their tools, unreadable /config leaves tools unfiltered.
  • Checked against a running DataHub Core instance.

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

Add VersionFilterMiddleware to datahub-core-mcp-tools and install it in
datahub-ai-service. Tools/list hides tools whose @min_version the connected GMS
doesn't meet, and tools/call refuses them, so a client with a stale list
can't call them either.

- The requirement travels with the registered tool function, so there is
  no module-level registry and two servers filter independently.
- Deployment type (serverEnv) is always honored; the version is compared
  only for real releases, so unreleased builds keep their tools.
- GMS info comes from a host-supplied callable; datahub-ai-service uses a
  GmsServerInfoCache (60 s) on its configured GMS URL. If /config can't be
  read, tools are left unfiltered and their own calls report the failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nwadams
nwadams requested a review from lakshay-nasa November 16, 2026 23:09
@cursor

cursor Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Adds version-aware MCP tool gating so clients only see and invoke tools their connected GMS actually supports.

VersionFilterMiddleware uses each tool’s existing @min_version metadata to trim tools/list and reject tools/call with a clear ToolError. Deployment type (serverEnv) is always enforced; numeric version checks apply only for real releases—unreleased builds keep tools allowed for that deployment type. If GMS info can’t be read, listing stays unfiltered (fail-open) so underlying tool calls surface the real GMS failure.

datahub-ai-service now passes a server_info callable into build_mcp_server (defaulting to cached /config via GmsServerInfoCache) and registers the middleware on the FastMCP stack between caller identity and telemetry. Unit tests cover availability rules, list/call behavior, and independent filtering per server instance.

Reviewed by Cursor Bugbot for commit 38464ed. Bugbot is set up for automated code reviews on this repo. Configure here.

@nwadams
nwadams force-pushed the na--ai-service-release branch from b57b0a0 to c947395 Compare November 19, 2026 00:10
@nwadams
nwadams force-pushed the na--mcp-version-filter branch from 6b43890 to 38464ed Compare November 19, 2026 00:10
…rkers

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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every packaged .gql is compiled for, and validated against, GMS's GraphQL
schema at v1.7.0 (the supported floor), v1.8.0 (the latest release) and the
checkout's own master.

- tests/graphql_schemas.json pins each release to its commit; add the
  releases just before and at each new #[since] gate.
- scripts/export_graphql_schemas.py concatenates the SDL from
  datahub-graphql-core at each pinned commit (fetching the tag in shallow
  CI clones and checking it still matches the pin) into build/; the
  exportGraphqlSchemas task runs it before the test tasks. Snapshots are
  generated, not committed.
- get_me's query moves to gql/get_me.gql, loaded with load_gql_document.
- A real gate is covered: Query.getRootDataProducts, new in 1.8.0, is
  dropped for 1.7.0 and kept for 1.8.0, and is invalid on 1.7.0 without its
  marker.
- The DataHub AI Service workflow also runs when the GraphQL schema changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nwadams and others added 4 commits November 23, 2026 14:53
CI's package check compares find_packages with find_namespace_packages, and the
gql directory had no __init__.py. Make it a package and declare its .gql files
as its own package data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Installing metadata-ingestion and the two packages from source resolves their
build requirements from the configured index. In CI that index needs the netrc
secret, which only the lock install step mounted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FastMCP 4.2.5 serves subscriptions/listen, and on the 2026-07-28 protocol the
SDK advertises listChanged whenever that handler is registered, overriding the
notification options. Drop the handler: the server never sends change
notifications, and an in-process bus can't reach clients on another replica.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
master now adds its own placeholder right after __SYSTEM_CLIENT_SECRET__.
Keeping ours one line further down lets both changes merge without a
conflict. The replacements are independent, so their order doesn't matter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
datahub-project-web-react (Preview) — 66f97775 Deployed Nov 23, 2026 by github-actions[bot]
Preview — 66f97775 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants