Skip to content

feat(frontend): proxy /mcp to the datahub-ai-service - #21350

Merged
nwadams merged 8 commits into
na--mcp-server-flagfrom
na--frontend-mcp-route
Nov 23, 2026
Merged

nwadams merged 8 commits into
na--mcp-server-flagfrom
na--frontend-mcp-route

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--mcp-server-flag (the previous PR in the stack); review only its own commit. This PR changes GMS, the frontend, Docker or CI, not only the new Python packages. Everything user-facing is behind a GMS feature flag, MCP_SERVER_ENABLED, off by default (added in #21349).

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
  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 ← this PR
  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

Serve MCP at /mcp, the same URL shape as DataHub Cloud, by proxying
GET/POST/DELETE /mcp and /mcp/* from the frontend to datahub-ai-service
(DATAHUB_AI_SERVICE_URL; /mcp is 404 while it is unset).

  • No frontend authentication: datahub-ai-service follows GMS's auth mode and checks
    the caller's Authorization header, which is forwarded unchanged. The
    session cookie and X-DataHub-Actor are never forwarded, so a logged-in
    browser tab can't call /mcp with its cookie. OPTIONS answers 405 with no
    CORS headers, so cross-site browser calls fail their preflight. A token
    in the URL (?token=) is refused with 400.
  • Only the headers MCP needs are forwarded: Authorization, Content-Type,
    Accept, Origin, User-Agent, Last-Event-ID and every Mcp-* header (the
    stateless protocol routes on Mcp-Method / Mcp-Name / Mcp-Param-*).
    X-Forwarded-Host is overwritten with the Host the client used, and
    X-Forwarded-Proto set, for datahub-ai-service's DNS-rebinding check.
  • Responses stream through a non-blocking publisher with an idle timeout
    (frontend.aiProxy.streamIdleTimeoutSeconds, 600), so slow calls hold no
    blocking-I/O thread; gzip is bypassed so SSE isn't buffered. Response
    headers wait up to frontend.aiProxy.timeoutSeconds (600).
  • /mcp has its own admission limit (frontend.aiProxy.maxInFlight, 128), not
    tied to readiness, held until the response finishes streaming and
    released exactly once, including when the client goes away.
  • datahub-ai-service unreachable: 503 with a JSON-RPC error body.

Tests run against a local HTTP server: header forwarding and stripping,
404/400/405/503, a first SSE event delivered while the next is held back,
the permit held for the whole stream, and released on client disconnect.
Live through a local OSS frontend: legacy and modern clients, Claude Code
with no token (GMS auth off), and 403 for a rebinding request.

Testing

8 controller tests vs a local HTTP server (streaming, permit release on disconnect). Live through the OSS frontend: legacy + modern clients, Claude Code with no token, rebinding 403.

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

@nwadams
nwadams requested a review from lakshay-nasa November 16, 2026 23:30
@cursor

cursor Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Adds /mcp on the DataHub UI host by proxying GET/POST/DELETE to datahub-ai-service when DATAHUB_AI_SERVICE_URL is set (AiServiceController); otherwise /mcp returns 404. The proxy forwards only MCP-relevant headers (including Authorization and Mcp-*), drops cookies/session actor, refuses ?token= and OPTIONS without CORS, streams responses with a separate in-flight cap, and returns JSON-RPC 503 when the AI service is down.

Docker and dev stacks gain docker-compose.ai.yml, default frontend URL to the AI container, GMS MCP_SERVER_ENABLED (off by default), quickstart/debug profile wiring, and Gradle quickstart generation for AI port/image env placeholders. CI treats datahub-ai-service as a seventh quickstart image (path rules, resolver tests, security scan) and adds an image job (size, non-root, health without GMS). Smoke tests exercise MCP through the frontend (legacy/modern protocol, auth/rebinding). Minor MCP tools tweak disables misleading listChanged / subscriptions/listen on stateless HTTP.

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

@github-actions github-actions Bot added the product PR or Issue related to the DataHub UI/UX label Nov 16, 2026
This was referenced Nov 16, 2026
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.59794% with 13 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...-frontend/app/controllers/AiServiceController.java 86.59% 7 Missing and 6 partials ⚠️

📢 Thoughts on this report? Let us know!

@meticulous

meticulous Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Meticulous is testing this change with Agent swarm instead of replaying recorded sessions. View Agent swarm.

Last updated for commit 86b7f85 feat(frontend): proxy /mcp to the datahub-ai-service. This comment will update as new commits are pushed.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Initial JS bundle size ➡️

Base (edd5c90) This PR Diff
index.html (/login) 301 KB 301 KB +0 KB (+0.0%)
Logged-in shell 1015 KB 1015 KB +0 KB (+0.0%)
/search 1.19 MB 1.19 MB +0 KB (+0.0%)
/ (home) 1.19 MB 1.19 MB +0 KB (+0.0%)

index.html is the login page; logged-in pages add the shell. Gzip of the JS loaded before first paint. Codecov reports total bundle including lazy chunks — these intentionally differ.

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>
@nwadams nwadams closed this Nov 23, 2026
@nwadams
nwadams merged commit 66f9777 into na--mcp-server-flag Nov 23, 2026
1 check was pending
@nwadams
nwadams deleted the na--frontend-mcp-route branch November 23, 2026 20:09
@github-actions

Copy link
Copy Markdown
Contributor

Smart test selection

pytest smoke tests

Mode: shadow. The selection below is computed but not applied; this PR still runs the default matrix (p0).

  • Selection: smart: tests for the tagged features, plus always-run modules, this PR's changed tests, and the plumbing sample if the PR changes the pytest harness
  • Size: 151 of 822 tests in 2 batches, predicted longest batch ~5 min
  • Tags: change-type: build, ci, docs, pytest-plumbing, test-infra, tooling; feature-dev: authentication, feature-flags; technical-layer: spring-config
  • Confidence: MEDIUM (26 changed files)
  • Classifier reasoning: Adds a frontend /mcp proxy to datahub-ai-service that forwards Authorization headers without frontend auth, plus MCP_SERVER_ENABLED flag and Spring/Play config; CI, Gradle/Docker image builds, and AGENTS.md are non-product change-types.

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)
  • tests/e2e/authorization/test_self_entity_auth.py
  • tests/e2e/cli/user_groups_cmd/test_user_cmd.py
  • tests/e2e/delete/delete_test.py
  • tests/e2e/dev_tooling/test_dev_tooling.py
  • tests/e2e/domains/domain_entities_batching_test.py
  • tests/e2e/entity_versioning/test_versioning_ingest.py
  • tests/e2e/frontend/test_static_asset_encodings.py
  • tests/e2e/glossary/glossary_children_count_test.py
  • tests/e2e/lineage/test_lineage_sdk.py
  • tests/e2e/mcp/mcp_test.py
  • tests/e2e/openapi/v3/test_scroll_entities.py
  • tests/e2e/patch/test_domain_patches.py
  • tests/e2e/read_only/test_services_up.py
  • tests/e2e/restli/test_restli_batch_ingestion.py
  • tests/e2e/schema_fields/test_schemafields.py
  • tests/e2e/search/test_search_projection.py::TestSearchProjection
  • tests/e2e/service_accounts/test_service_accounts.py
  • tests/e2e/test_authentication_e2e.py
  • tests/e2e/test_e2e.py
  • tests/e2e/tokens/revokable_access_token_test.py
  • tests/e2e/tokens/session_access_token_test.py

Add the run-all-tests:pytest label to run the full pytest suite on this PR.

commit 66f9777 · workflow run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ 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}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frontend /mcp points at missing service

High Severity

The frontend always sets DATAHUB_AI_SERVICE_URL to http://datahub-ai-service:9005, including on the quickstart and debug-min profiles where datahub-ai-service is not started. A configured URL makes /mcp proxy instead of 404, so those installs wait on connect then return 503. The generated CLI compose also freezes that URL as a literal, so it cannot be cleared or overridden.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 66f9777. Configure here.

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

product PR or Issue related to the DataHub UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants