Repository navigation
feat(ai): scaffold the datahub-ai-service with /health - #21334
Conversation
Add packages/datahub-ai-service, the OSS service that will serve DataHub's MCP tools at /mcp (and later other AI features). - Gradle module (:packages:datahub-ai-service) built on the shared Python package script, installing the monorepo SDK and datahub-core-mcp-tools editable. - AiServiceConfig read from the environment: DATAHUB_GMS_URL (required, base path allowed), DATAHUB_AI_HOST/PORT (0.0.0.0:9005), MCP enablement, SSE/JSON response mode, token-cache TTL and GMS timeout. A shared DATAHUB_GMS_TOKEN is refused: each caller sends their own token. - Starlette app with an unauthenticated /health that never contacts GMS, so the service starts before GMS is healthy. - `datahub-ai-service serve` CLI. - Built, linted and tested by the "DataHub AI Service" workflow; excluded from the main build like the other Python modules. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
datahub-ai-service now serves the datahub-core-mcp-tools tools (today: get_me) over stateless streamable HTTP at /mcp. - Every request carries the caller's DataHub token. An ASGI middleware in front of the MCP app checks it with GraphQL `me` and caches successful verdicts (keyed by a hash of the token) for DATAHUB_MCP_TOKEN_CACHE_TTL_SECONDS. Missing or rejected tokens get 401; when GMS is unreachable or erroring the request gets 503, never access. - Each MCP message runs with a DataHub client built from its caller's token and closed afterwards; no client is cached or shared between callers. - SSE responses by default; DATAHUB_AI_MCP_RESPONSE_MODE=json returns plain JSON bodies for proxies that can't stream. - listChanged is not advertised, since a stateless host can't send it. - Tool-call observer seam for telemetry; an observer failure never fails the call. Tests run a real HTTP server against a fake GMS: missing/garbage tokens, GMS outage, SSE and JSON modes, legacy and modern protocol clients, token caching, and two concurrent callers held in flight at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tahub-ai-service Generate scripts/release.sh for both packages with python-build/generate_release_scripts.py, so they publish to PyPI with DataHub's version like datahub-agent-context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 The frontend adds Packaging and CI: Docker image ( Note: Stack messaging says earlier PRs are not user-facing; this diff already wires compose, frontend proxy, and config flags (MCP still defaults off until enabled on GMS). Reviewed by Cursor Bugbot for commit 66f9777. Bugbot is set up for automated code reviews on this repo. Configure here. |
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>
Smart test selectionpytest smoke testsMode: shadow. The selection below is computed but not applied; this PR still runs the default matrix (
Medium confidence: a wrong tag means tests are skipped, so check the tags above against what this PR touches. Selected scopes (21 files or classes, 151 tests)
Add the commit |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 66f9777. Configure here.
| DATAHUB_GMS_BASE_PATH: ${DATAHUB_GMS_BASE_PATH:-/} | ||
| LOG_AGGREGATOR_ENDPOINT: ${LOG_AGGREGATOR_ENDPOINT:-} | ||
| # /mcp is proxied to datahub-ai-service (docker-compose.ai.yml). | ||
| DATAHUB_AI_SERVICE_URL: ${DATAHUB_AI_SERVICE_URL:-http://datahub-ai-service:9005} |
There was a problem hiding this comment.
Quickstart proxies MCP to missing service
Medium Severity
The frontend always sets DATAHUB_AI_SERVICE_URL to http://datahub-ai-service:9005, including the generated quickstart profile. datahub-ai-service is intentionally omitted from that profile, so /mcp is no longer the documented 404-when-unset path. Play instead waits on the HttpClient connect timeout and returns 503 because the hostname does not resolve.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 66f9777. Configure here.
Initial JS bundle size ➡️
|
Boot web vitals (no backend)Unauthenticated /login against the two dist/ trees from this job. No GMS — this is eager JS, not search/dataset payload. Lantern, desktop, 1x CPU. Does not forecast fleet p75; do not gate on LCP. Web-vitals A/B — base (3eaa354) (A) vs pr (66f9777) (B)Lighthouse 12.8.2, throttling simulate (cpu 1x, rtt 40 ms, 10240 kbps). Form factor: desktop. Cache: cold (fresh incognito context per run). target n=3/build, 1 warm-up discarded, alternating A,B. Boot-only (no GMS). Unauthenticated login route — eager JS/CSS/font transfer and parse, not search/dataset payload. Do not treat as a fleet p75.
|
| metric | A p50 | B p50 | Δ p50 | Δ% | A p95 | B p95 |
|---|---|---|---|---|---|---|
| fcp | 911 ms | 907 ms | -3 ms | -0.4% | 916 ms | 910 ms |
| lcp | 1355 ms | 1352 ms | -4 ms | -0.3% | 1362 ms | 1367 ms |
| cls | 0.0000 | 0.0000 | 0.0000 | — | 0.0000 | 0.0000 |
| tbt | 15 ms | 10 ms | -5 ms | -33.3% | 16 ms | 13 ms |
| tti | 1357 ms | 1354 ms | -4 ms | -0.3% | 1364 ms | 1367 ms |
| ttfb | 1 ms | 1 ms | 0 ms | -15.2% | 1 ms | 1 ms |
| transferredBytes | 1072.6 KB | 1072.6 KB | 0.0 KB | +0.0% | 1072.6 KB | 1072.6 KB |
| mainThread | 322 ms | 320 ms | -2 ms | -0.6% | 389 ms | 329 ms |
| bootup | 144 ms | 138 ms | -6 ms | -4.0% | 167 ms | 145 ms |
Resource transfer by type (p50):
| type | A bytes | B bytes | Δ bytes | A requests | B requests |
|---|---|---|---|---|---|
| document | 1.2 KB | 1.2 KB | -0.0 KB | 1 | 1 |
| script | 574.6 KB | 574.6 KB | 0.0 KB | 7 | 7 |
| stylesheet | 69.3 KB | 69.3 KB | 0.0 KB | 2 | 2 |
| image | 48.7 KB | 48.7 KB | 0.0 KB | 1 | 1 |
| media | 257.3 KB | 257.3 KB | 0.0 KB | 1 | 1 |
| font | 106.6 KB | 106.6 KB | 0.0 KB | 3 | 3 |
| other | 0.0 KB | 0.0 KB | 0.0 KB | 0 | 0 |
LCP element A: div > div.sc-pRPz > div.sc-hrcaRA > p.sc-pNWdM — Welcome to DataHub
LCP element B: div > div.sc-pRPz > div.sc-hrcaRA > p.sc-pNWdM — Welcome to DataHub
These numbers rank changes and gate regressions against the measured origin(s). They do not sum across PRs and do not forecast any fleet-wide production number.


Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on
na--mcp-tools-gms-server-info(the previous PR in the stack); review only its own commit. Nothing in these first five PRs 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 packages/datahub-ai-service, the OSS service that will serve DataHub's MCP
tools at /mcp (and later other AI features).
script, installing the monorepo SDK and datahub-core-mcp-tools editable.
base path allowed), DATAHUB_AI_HOST/PORT (0.0.0.0:9005), MCP enablement,
SSE/JSON response mode, token-cache TTL and GMS timeout. A shared
DATAHUB_GMS_TOKEN is refused: each caller sends their own token.
so the service starts before GMS is healthy.
datahub-ai-service serveCLI.main build like the other Python modules.
Testing
./gradlew :packages:datahub-ai-service:lint :packages:datahub-ai-service:testQuick: config parsing (including the refused shared token) and/healthwithout GMS.Checklist
🤖 Generated with Claude Code