Repository navigation
feat(mcp): filter tools by the connected GMS version - #21337
Conversation
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>
PR SummaryOverview
datahub-ai-service now passes a Reviewed by Cursor Bugbot for commit 38464ed. Bugbot is set up for automated code reviews on this repo. Configure here. |
b57b0a0 to
c947395
Compare
6b43890 to
38464ed
Compare
…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>
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>
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 shareddatahub-core-mcp-toolspackage anddatahub-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:
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.
no module-level registry and two servers filter independently.
only for real releases, so unreleased builds keep their tools.
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
Checklist
🤖 Generated with Claude Code