feat(mcp): add DataHub's built-in MCP server, off by default

Merged
NW
4d ago
+7825-30

Adds a built-in MCP server to DataHub Core: the datahub-core-mcp-tools library, the datahub-ai-service that serves it, and the frontend route, image, quickstart wiring and smoke tests around them. It's off by default: /mcp answers 404 until GMS has MCP_SERVER_ENABLED=true.

This PR started as the first of a stack. PRs #21333 to #21353 have been merged into it, so it now carries all 22 reviewed parts plus three fixes. The tool ports continue from #21435.

What this does

packages/datahub-core-mcp-tools (#21332, #21333, #21337–#21343)

  • A Python library of MCP tools. The host sets a DataHub client per request, and register_tools(mcp, ...) adds the tools to a server the caller passes in. Ships get_me.
  • Reads the GMS version and deployment from /config, and hides tools the connected GMS can't serve.
  • Compiles each tool's GraphQL for the exact GMS version (#[since] markers), and CI checks the packaged GraphQL against pinned GMS schemas.
  • Tool groups and tool-aware server instructions.
  • Safe cancellation, progress reports on slow tools, shared limits and truncation, and mapping of errors to ToolError.
  • ReadBackend and ResultPolicy seams, so a host can change how tools read and label results.

packages/datahub-ai-service (#21334, #21335, #21344, #21346, #21347)

  • A FastAPI service with /health, serving MCP at /mcp with caller-scoped DataHub clients.
  • Bounds every GMS request and never replays one GMS may already have run.
  • Follows GMS's auth mode. With auth on, callers bring a token and act as themselves. With auth off, calls run as the system user, and requests that look like DNS rebinding are refused.

GMS, frontend and UI (#21345, #21349, #21350)

  • GMS /config reports authentication.enabled and mcpServer.enabled.
  • New feature flag MCP_SERVER_ENABLED (default false), also exposed in the GraphQL app config.
  • The frontend proxies /mcp to the service when DATAHUB_AI_SERVICE_URL is set, with its own in-flight limit and stream timeouts.

Build, release and deployment (#21336, #21348, #21351, #21352)

  • PyPI release scripts for both packages.
  • A datahub-ai-service image with locked dependencies, built in CI and by docker-unified.
  • The service runs in datahub-dev and the debug profiles. It isn't in the released quickstart compose yet, because no released datahub-ai-service image exists.

Tests (#21353)

  • Smoke tests for MCP through the frontend's /mcp, with auth on and off.

Fixes added while merging

  • fix(mcp): the gql directory is now a package, so the "Test packages are correct" check passes.
  • fix(ai): the image build's source-install step mounts the index credentials, as the lock install already did.
  • fix(mcp): listChanged stays off with FastMCP 4.2.5, which serves subscriptions/listen. On the 2026-07-28 protocol that handler alone turns listChanged on.
  • build(docker): moved our compose placeholders one line down in docker/build.gradle, so the branch merges with current master without a conflict.

Testing

  • Run against the branch merged with current master: ./gradlew :packages:datahub-core-mcp-tools:lint :packages:datahub-core-mcp-tools:testQuick :packages:datahub-ai-service:lint :packages:datahub-ai-service:testQuick
  • .github/scripts/check_quickstart_compose.sh and .github/scripts/test_resolve_image_builds.sh
  • Java tests for the touched classes: AppConfigResolverTest, ConfigServletTest, AiServiceControllerTest and PropertiesCollectorConfigurationTest.
  • Each folded PR was reviewed and approved on its own, with its own testing notes.

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). User docs come with the settings and tool PRs later in the stack.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes. Not applicable: the server is off by default.

šŸ¤– Generated with Claude Code