feat(mcp): add DataHub's built-in MCP server, off by default
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. Shipsget_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. ReadBackendandResultPolicyseams, 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/mcpwith 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
/configreportsauthentication.enabledandmcpServer.enabled. - New feature flag
MCP_SERVER_ENABLED(defaultfalse), also exposed in the GraphQL app config. - The frontend proxies
/mcpto the service whenDATAHUB_AI_SERVICE_URLis 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-serviceimage with locked dependencies, built in CI and bydocker-unified. - The service runs in
datahub-devand the debug profiles. It isn't in the released quickstart compose yet, because no releaseddatahub-ai-serviceimage exists.
Tests (#21353)
- Smoke tests for MCP through the frontend's
/mcp, with auth on and off.
Fixes added while merging
fix(mcp): thegqldirectory 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):listChangedstays off with FastMCP 4.2.5, which servessubscriptions/listen. On the 2026-07-28 protocol that handler alone turnslistChangedon.build(docker): moved our compose placeholders one line down indocker/build.gradle, so the branch merges with currentmasterwithout 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.shand.github/scripts/test_resolve_image_builds.sh- Java tests for the touched classes:
AppConfigResolverTest,ConfigServletTest,AiServiceControllerTestandPropertiesCollectorConfigurationTest. - 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